-
public final class PushMessageSyncHandlerA class which can be used in com.google.firebase.messaging.FirebaseMessagingService in case the app uses multiple push notifications backend services. It's responsible for registering the device's Firebase token on Stream backend, executing data sync, and showing notification about the new messages obtained during the sync.
If the app uses Stream service as its only push notifications provider, the OfflineSyncFirebaseMessagingService class can be used as the out-of-the box implementation instead of PushMessageSyncHandler methods.
-
-
Constructor Summary
Constructors Constructor Description PushMessageSyncHandler(Service service)
-
Method Summary
Modifier and Type Method Description final UnitonNewToken(String token)Should be called from FirebaseMessagingService.onNewToken function. final UnitonMessageReceived(RemoteMessage message)This method should be called from FirebaseMessagingService.onMessageReceived function. final BooleanisStreamMessage(RemoteMessage message)Checks if the cloud message is sent from the Stream backend service. -
-
Constructor Detail
-
PushMessageSyncHandler
PushMessageSyncHandler(Service service)
-
-
Method Detail
-
onNewToken
final Unit onNewToken(String token)
Should be called from FirebaseMessagingService.onNewToken function. It registers the Firebase token at Stream backend service. It's required by the backend to send push notifications via Firebase.
- Parameters:
token- the token delivered by Firebase service to com.google.firebase.messaging.FirebaseMessagingService registered at your app.
-
onMessageReceived
@WorkerThread() final Unit onMessageReceived(RemoteMessage message)
This method should be called from FirebaseMessagingService.onMessageReceived function. It parses the message, and starts the sync operation (synchronously), proceeded with notification displaying.
In order to perform the sync, the service is switched into foreground, and the foreground notification is displayed to inform about the foreground execution. Afterwards, the service switches back to background execution and a new notification is displayed informing about the new messages / events obtained during the sync.
In case the message was not delivered from the Stream push notification provider no operation is executed.
- Parameters:
message- the RemoteMessage delivered to com.google.firebase.messaging.FirebaseMessagingService registered at your app.
-
isStreamMessage
final Boolean isStreamMessage(RemoteMessage message)
Checks if the cloud message is sent from the Stream backend service.
- Parameters:
message- instance of RemoteMessage delivered at FirebaseMessagingService
-
-
-
-