PushwooshFcmRouterService

FCM service base class for apps that need their own push routing next to Pushwoosh.

Extend this class instead of FirebaseMessagingService and register your subclass in the manifest as the FCM service. Forwarding to Pushwoosh is built in and cannot be bypassed: both callbacks and the FCM dispatcher handleIntent are final.

Message dispatch is exclusive. A Pushwoosh message goes to the Pushwoosh SDK and never reaches onAppMessageReceived; any other message goes to onAppMessageReceived only. To observe Pushwoosh pushes as they arrive, override NotificationServiceExtension#onMessageReceived(PushMessage): it fires for every Pushwoosh push whichever FCM service received it, and its return value decides whether the notification is shown. To route Pushwoosh pushes to screens, handle the open, not the receive: use NotificationServiceExtension and the notification open handler chain.

Contract:

  • on a new token the Pushwoosh SDK is notified first, then onAppTokenRefresh;
  • both callbacks run on the FCM background executor, like the native onMessageReceived and onNewToken;
  • an exception thrown by the Pushwoosh SDK on a Pushwoosh message is logged and swallowed; an exception inside onAppMessageReceived is the app's own.
Recommended manifest registration — the priority keeps the service winning the resolve even if another library ships its own FCM service:

<service android:name=".YourRouterService" android:exported="false">
    <intent-filter android:priority="1">
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>
Other FirebaseMessagingService callbacks (onDeletedMessages, onMessageSent, onSendError) are not sealed — override them as usual.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun handleIntent(intent: Intent)
Link copied to clipboard
protected abstract fun onAppMessageReceived(message: RemoteMessage)
Called for every FCM message that is not a Pushwoosh message.
Link copied to clipboard
protected open fun onAppTokenRefresh(token: String)
Called after the new FCM token has been passed to the Pushwoosh SDK.
Link copied to clipboard
fun onMessageReceived(remoteMessage: RemoteMessage)
Link copied to clipboard
fun onNewToken(token: String)