Notifications
Notifications layer
The notifications layer is where the tokens and messages are handled and exposed via observables to all the notifications providers.
Overview
PoqFirebaseMessagingService
is an extension ofFirebaseMessagingService
that forwardsonNewToken()
andonMessageReceived()
viaMessagingServiceEventsPublisher
.MessagingServiceEventsPublisher
is the interface to sendonNewToken
andonMessageReceived
events.MessagingServiceEvents
is the interface to exposeonNewToken
andonMessageReceived
as RxJava observables.PoqMessagingServiceEvents
is the implementation ofMessagingServiceEventsPublisher
andMessagingServiceEvents
How to add a new notifications provider
To add a new notification provider:
- Inject
MessagingServiceEvents
into your Application. - Subscribe to
MessagingServiceEvents.onNewToken
andMessagingServiceEvents.onMessageReceive
from the ApplicationonCreate
and 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.