Issue
- In the Message History, I see that the sends to the devices were successful, and there were no errors from the gateway in the Delivery Report details. But I still don't see push notification alerts on the device.
- When we integrated the Firebase plugin, we stop receiving pushes altogether with Pushwoosh.
- When I send notifications to my Android device, they're not displaying. But if I send notification from Firebase, they will be shown.
Resolution
Case 1: you use or are planning to use only Pushwoosh to send push notifications.
Most likely, the other Firebase Messaging Service implementations exist alongside Pushwoosh, but with higher priority. That can be reason to stop receiving the notification.
Please check your AndroidManifest.xml. The FirebaseMessagingService
is responsible for handling push notifications when they are received. However, only the one with the highest priority will work.
To resolve this issue, you will need to add the com.pushwoosh.firebase.PushFcmIntentService
to the AndroidManifest.xml with the highest priority that will handle all pushes.
Then, please make sure that the Pushwoosh service has the highest priority using android:priority
inside <intent-filter>
or just place it above others (in case the "priority" is not specified):
<service android:name="com.pushwoosh.firebase.PushFcmIntentService"
android:exported="false">
<intent-filter android:priority="500">
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
AndroidManifest.xml
Case 2: you use or are planning to use several services for sending push notifications in addition to Pushwoosh.
In short: you can add a router service to distribute events between the services. Check this guide for Android native: Using Pushwoosh SDK with other FCM services. For some 3rd party frameworks, check their corresponded guides: Cordova, React Native.
In details: when a push is received, it is handled by FirebaseMessagingService
, particularly, by onMessageReceived
method. Both Pushwoosh SDK and Firebase SDK handle notifications by overriding FirebaseMessagingService
class — this means that your app will have two possible handlers for push messages.
Both Pushwoosh and Firebase messaging services are declared in AndroidManifest.xml of the app, and, without intentionally specifying priorities of these services, we cannot guarantee pushes will be handled by Pushwoosh SDK.
When we talked about the router service, we meant routing the pushes within the application. For the native Android or supported plugins (i.e., Cordova, React, etc.) to resolve this issue, you will need
to create the main service with the highest priority that will route all pushes to Pushwoosh. To do that, it's
needed to add a class to the project as described here: Using Pushwoosh plugin with other FCM services.
Just create a new class that extends FirebaseMessagingService
, override its onMessageReceived()
and onPushToken()
methods and call corresponding PushwooshFcmHelper
methods inside them.
Then, just register the service in AndroidManifest and you should be all set up. Pushwoosh will automatically add all dependencies used in this file, so there should be no need to add them manually.
An example: the service should be added to route all pushes to Pushwoosh (on the top of
the list or with a higher priority):
<service
android:name=".MyFirebaseMessagingService" android:priority="500">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service
android:name=".OtherMessagingService" android:priority="-500">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
Then, use super
to call the superclass MyFirebaseMessagingService
of FirebaseMessagingService
subclass:
package com.your.application;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.pushwoosh.firebase.PushwooshFcmHelper;
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
PushwooshFcmHelper.onMessageReceived(this, remoteMessage);
}
@Override
public void onNewToken(String s) {
super.onNewToken(s);
PushwooshFcmHelper.onTokenRefresh(s);
}
}
Comments
0 comments
Please sign in to leave a comment.