Skip to content

Customize Chat Module Notifications

Kristiyan Petrov edited this page Aug 2, 2019 · 9 revisions
  • Incoming chat messages can be displayed as notification or activities.
  • All chat notifications may be customized inside the following method: onCreateNotification(chatInfo, chatNotificationStyle)

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

  • Default action is to open the chat if possible, otherwise the application will be launched.

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

builder.withChatEnabled(new ChatNotificationListener() {

	@Override
	public void onIncomingChat(@NonNull IncomingChat chat, boolean isDnd, boolean isScreenLocked) {
		chat.asNotification(App.this).show();
	}

	@Override
	public void onCreateNotification(@NonNull ChatInfo chatInfo,
					 @NonNull ChatNotificationStyle notificationStyle) {
		notificationStyle.setNotificationColor(Color.RED);
		notificationStyle.setNotificationSmallIcon(R.drawable.ic_notification);
	}

	@Override
	public void onChatActivityStartedFromNotificationAction(@NonNull ChatInfo chatInfo,
								@NonNull ChatIntentOptions chatIntentOptions) {
		CallCapabilities capabilities = new CallCapabilities()
			.withWhiteboard()
			.withFileSharing()
			.withChat()
			.withScreenSharing();

		CallOptions options = new CallOptions()
			.withRecordingEnabled() // if the call started should be recorded
			.withBackCameraAsDefault() // if the call should start with back camera
			.withProximitySensorDisabled(); // if the proximity sensor should be disabled during calls
                
                chatIntentOptions
                        .withAudioCallCapability(capabilities, options)
                        .withAudioUpgradableCallCapability(capabilities, options)
                        .withAudioVideoCallCapability(capabilities, options);
	}

	@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