Notifications
Notifications layer
The notifications layer is where the tokens and messages are handled and exposed via observables to all the notifications providers.
Overview
PoqFirebaseMessagingServiceis an extension ofFirebaseMessagingServicethat forwardsonNewToken()andonMessageReceived()viaMessagingServiceEventsPublisher.MessagingServiceEventsPublisheris the interface to sendonNewTokenandonMessageReceivedevents.MessagingServiceEventsis the interface to exposeonNewTokenandonMessageReceivedas RxJava observables.PoqMessagingServiceEventsis the implementation ofMessagingServiceEventsPublisherandMessagingServiceEvents
How to add a new notifications provider
To add a new notification provider:
- Inject
MessagingServiceEventsinto your Application. - Subscribe to
MessagingServiceEvents.onNewTokenandMessagingServiceEvents.onMessageReceivefrom the ApplicationonCreateand forward each event to the appropriate method from your notification provider.
Notification permission
Android 13 introduces a runtime permission for posting notifications. This permission is granted on previous Android versions and for your existing users migrating to an Android 13 device.
The PoqSDK offers an onboarding page to request the permission. This page will be filtered out for non-applicable Android versions or users with notifications already enabled. Also, the PoqSDK tries to request the permission every 30 days on the home screen. Based on a system flag, when the user has not allowed the notifications once on the OS dialog, the PoqSDK will show a screen explaining the reason to request the permission before showing the system dialog again. Finally, depending on the specific OS behaviour, if the permission has been denied twice on the OS dialog, the PoqSDK will not be able to request the permission again.