com.twilio.voice.CallException Java Examples

The following examples show how to use com.twilio.voice.CallException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VoiceFirebaseMessagingService.java    From voice-quickstart-android with MIT License 5 votes vote down vote up
/**
 * Called when message is received.
 *
 * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
 */
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    Log.d(TAG, "Received onMessageReceived()");
    Log.d(TAG, "Bundle data: " + remoteMessage.getData());
    Log.d(TAG, "From: " + remoteMessage.getFrom());

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        boolean valid = Voice.handleMessage(this, remoteMessage.getData(), new MessageListener() {
            @Override
            public void onCallInvite(@NonNull CallInvite callInvite) {
                final int notificationId = (int) System.currentTimeMillis();
                handleInvite(callInvite, notificationId);
            }

            @Override
            public void onCancelledCallInvite(@NonNull CancelledCallInvite cancelledCallInvite, @Nullable CallException callException) {
                handleCanceledCallInvite(cancelledCallInvite);
            }
        });

        if (!valid) {
            Log.e(TAG, "The message was not a valid Twilio Voice SDK payload: " +
                    remoteMessage.getData());
        }
    }
}