I have a React Native app that uses https://github.com/zo0r/react-native-push-notification to manage push notifications. Attempting to migrate from GCM to FCM messages on Android is not working, and I cannot find a way to debug the issue.
I have:
- Removed all GCM-specific components
- Followed https://firebase.google.com/docs/cloud-messaging/android/client
- Followed instructions from react-native-push-notification
- Successfully built and run the app
- When sending a notification via the Firebase console - it detects that there is 1 user to send to, but it never gets received on the device
- When sending via the API https://fcm.googleapis.com/fcm/send, the response indicates success, despite the notification not being received on the device
- Confirmed device has permission to receive notifications
- Tested with app in background
AndroidManifest.xml relevant parts:
<manifest...>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application...>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="CHANNEL NAME"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="CHANNEL DESCRIPTION"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@android:color/white"/>
<activity...>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
app/build.gradle includes:
dependencies {
...
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.5.0"
}
apply plugin: 'com.google.gms.google-services'
build.gradle includes:
buildscript {
...
dependencies {
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.android.tools.build:gradle:3.0.0'
}
...
}
google-services.json has been placed correctly with matching package name.
https://fcm.googleapis.com/fcm/send
POST Request (IDs removed)
Header "Authorization: key=AUTH_KEY"
{
"to": "DEVICE_TOKEN",
"notification":
{
"title": "Test",
"body": "Test"
},
"priority": 10
}
Response (IDs removed)
{
"multicast_id": MULTICAST_ID,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results":
[
{
"message_id": "0:MESSAGE_ID"
}
]
}
Firebase console when sending test message to app shows:
This campaign targets 1 app user(s) (100% of potential users)
Indicates device has been registered, and can send the campaign, however it is never displayed on the device.
How can I determine why the message is not displayed on the device?