PushwooshFcmHelper
Helper class for integrating Pushwoosh with Firebase Cloud Messaging (FCM) in custom FirebaseMessagingService implementations.
By default, Pushwoosh SDK automatically handles Firebase Cloud Messaging without any additional code. However, if your app needs a custom FirebaseMessagingService (for example, to handle messages from multiple push providers), use this helper class to forward Firebase callbacks to Pushwoosh.
Important: Use this helper ONLY if you need a custom FirebaseMessagingService. For customizing notifications, use com.pushwoosh.notification.NotificationServiceExtension instead.
Prefer PushwooshFcmRouterService over calling this helper by hand: forwarding is built in and the dispatch chain is sealed, so the calls below cannot be dropped in a later refactor. Use this helper directly only when your service must extend a different base class.
Once messages are forwarded, Pushwoosh renders the notification and your own renderer no longer runs for Pushwoosh pushes — that is the intended split. Match the appearance through the manifest: com.pushwoosh.notification_icon, com.pushwoosh.notification_icon_color and com.pushwoosh.multi_notification_mode; reach for com.pushwoosh.notification.NotificationServiceExtension only where those are not enough.
Critical Integration Steps:
- Create your custom FirebaseMessagingService class
- Override onNewToken and call onTokenRefresh
- Override onMessageReceived and call onMessageReceived
- Register your service in AndroidManifest.xml
Example - Multiple Push Providers:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
public void onNewToken(@NonNull String token) {
super.onNewToken(token);
// CRITICAL: Forward to Pushwoosh to keep receiving notifications
PushwooshFcmHelper.onTokenRefresh(token);
// Forward to other providers if needed
OtherProvider.setToken(token);
}
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
// CRITICAL: Route Pushwoosh messages to Pushwoosh
if (PushwooshFcmHelper.isPushwooshMessage(remoteMessage)) {
PushwooshFcmHelper.onMessageReceived(this, remoteMessage);
return;
} else {
// Handle other providers
OtherProvider.handleMessage(remoteMessage);
}
}
}
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>