Push Notification
Enable / Disable Push Notification
You can set whether users receive push notifications.
// Enable Push Notification
TalkPlus.enablePushNotification(new TalkPlus.CallbackListener<TPUser>() {
@Override
public void onSuccess(TPUser tpUser) {
}
@Override
public void onFailure(int i, Exception e) {
}
});
// Disable Push Notification
TalkPlus.disablePushNotification(new TalkPlus.CallbackListener<TPUser>() {
@Override
public void onSuccess(TPUser tpUser) {
}
@Override
public void onFailure(int i, Exception e) {
}
});// Enable Push Notification
TalkPlus.enablePushNotification(object : TalkPlus.CallbackListener<TPUser>() {
override fun onSuccess(tpUser: TPUser) { }
override fun onFailure(i: Int, e: Exception) { }
}
// Disable Push Notification
TalkPlus.disablePushNotification(object : TalkPlus.CallbackListener<TPUser>() {
override fun onSuccess(tpUser: TPUser) { }
override fun onFailure(i: Int, e: Exception) { }
})You can set whether you want to receive push notifications from specific channels.
Push Notification
Push Notification is handled by FCM.
First, integrate FCM on TalkPlus dashboard. Then, when a user logs in, call registerFCMToken function to register FCM token from that device.
The following code demonstrates how you can obtain and register an FCM token from FirebaseMessaging.
You can then call processFirebaseCloudMessagingData function to handle push notifications, as shown below.
When app is running in the foreground, callback is automatically handled by an already registered ChannelListener.
When app is in the background, app is currently not running and may not have a callback already registered. In that case, you can register an anonymous callback to handle events as shown below:
(processFirebaseCloudMessagingData function accepts boolean value for its last parameter forceCallback. You must set forceCallback to true to receive callbacks from FCM, regardless of whether you are already receiving callbacks from the realtime connection.)
In order to have complete control of FCM push notification both in foreground and background, you need to receive data type FCM push notification and handle it via onMessageReceived. To enable this feature, you need to make sure the following settings are in place in dashboard:
Push Notification is enabled

Disable push notification for Android (this allows only data type FCM notifications for Android)

Last updated