Skip to content

Customize Call Module Notifications

Kristiyan Petrov edited this page Mar 6, 2019 · 14 revisions
  • Incoming calls can be displayed as notification or activities.
  • All call notifications (ongoing calls or incoming calls) may be customized inside the following method onCreateNotification(callInfo, callNotificationType, callNotificationStyle)

N.B. All the notifications have a default behaviour which will be triggered when action.execute(); is called

  • Ongoing call notification will put the application in foreground.
  • Incoming call notification will show the dialing activity, answer the call or decline the call.

BandyerSDK.Builder builder = new BandyerSDK.Builder(this, getString(R.string.app_id))

builder.withCallEnabled(new CallNotificationListener() {
	
        @Override
      	public void onIncomingCall(@NonNull IncomingCall incomingCall, boolean isDnd, boolean isScreenLocked) {
		if (!isDnd || isScreenLocked) // display ringing activity
			startActivity(incomingCall.asActivityIntent(App.this));
		else // display incoming call as system notification
			incomingCall.asNotification(App.this).show();
		}

	@Override
	public void onCallActivityStartedFromNotificationAction(@NonNull CallInfo callInfo,
								@NonNull CallIntentOptions callIntentOptions) {                                           
		callIntentOptions.withChatCapability().withWhiteboardCapability();
	}

	@Override
	public void onCreateNotification(@NonNull CallInfo callInfo,
                                         @NonNull CallNotificationType type,
                                         @NonNull CallNotificationStyle notificationStyle) {
		notificationStyle.setNotificationColor(Color.RED);
		notificationStyle.setNotificationSmallIcon(R.drawable.ic_notification);
	}

	@Override
	public void onNotificationAction(@NonNull NotificationAction action) {
		// Here you can execute your own code before executing the default action of the notification
		action.execute();
	}
};);
Clone this wiki locally