Notifications

Notifications layer

The notifications layer is where the tokens and messages are handled and exposed via observables to all the notifications providers.

Overview

Notifications layer overview
Notifications layer overview

  • PoqFirebaseMessagingService is an extension of FirebaseMessagingService that forwards onNewToken() and onMessageReceived() via MessagingServiceEventsPublisher.
  • MessagingServiceEventsPublisher is the interface to send onNewToken and onMessageReceived events.
  • MessagingServiceEvents is the interface to expose onNewToken and onMessageReceived as RxJava observables.
  • PoqMessagingServiceEvents is the implementation of MessagingServiceEventsPublisher and MessagingServiceEvents

How to add a new notifications provider

To add a new notification provider:

  1. Inject MessagingServiceEvents into your Application.
  2. Subscribe to MessagingServiceEvents.onNewToken and MessagingServiceEvents.onMessageReceive from the Application onCreate 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.

Notification permission request on the home screen
Notification permission request on the home screen