Android did not receive any notification, but IOS working properly
Question
this is wierd actually, a day ago on Android , the push notification is working even when application is on Foreground or Background. then im going for implement it on IOS, its working too even in Debug or Release.
but, when i try to test on Android again, look like it got some problem. it's working if im test using Firebase Console by targeting Device Token Directly, but when i try to Target to App like bellow, its now not working, same as if im close the application.
Working :

Not Working :

i have test it send to both Ios and Android, the the result is IOS got the push notification, but Android is NOT.
Here's the code i have using on my React Native code :
async componentDidMount(){
this.pushNotificationListener();
}
pushNotificationListener = async () => {
//Handling like this because on IOS, onNotification not Fired, and i ended doing something dirty like so, sad but working
messaging().onMessage((payload) => {
console.log('[payload] : ',payload)
this.showNotification(payload)
});
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister: (token) => {
console.log("TOKEN:", token);
},
// (required) Called when a remote or local notification is opened or received
onNotification: (notification) => {
console.log("NOTIFICATION:", notification);
// process the notification
this.showNotification(notification)
// required on iOS only (see fetchCompletionHandler docs: https://github.com/react-native-community/react-native-push-notification-ios)
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
// ANDROID ONLY: FCM Sender ID (product_number) (optional - not required for local notifications, but is need to receive remote push notifications)
senderID: "Some Sender ID",
// IOS ONLY (optional): default: all - Permissions to register.
permissions: {
alert: true,
badge: true,
sound: true,
}
});
}
showNotification = (payload) => {
//Handling like this because on IOS, onNotification not Fired, and i ended doing something dirty like so, sad but working
let notification = {
title : Platform.OS === 'ios' ? payload.notification.title : payload.title,
message : Platform.OS === 'ios' ? payload.notification.body : payload.message
};
PushNotification.localNotification({
largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
smallIcon: "ic_launcher", // (optional) default: "ic_notification" with fallback for "ic_launcher"
bigText: notification.message, // (optional) default: "message" prop
vibrate: true,
priority: "max",
allowWhileIdle: true,
title: notification.title, // (optional)
message: notification.message, // (required)
});
}
Package.json :
"react-native-push-notification": "^3.1.9",
"@react-native-community/push-notification-ios": "^1.1.1",
"@react-native-firebase/app": "6.4.1.alpha0",
"@react-native-firebase/messaging": "6.4.1.alpha0",
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.testapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.testapp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.testapp.permission.C2D_MESSAGE" />
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:usesCleartextTraffic="true"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="YOUR NOTIFICATION CHANNEL NAME"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>
<!-- Change the resource name to your App's accent color - or any other color you want -->
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.testapp" />
</intent-filter>
</receiver>
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
<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"/>
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<!-- </ Only if you're using GCM or localNotificationSchedule() > -->
<!-- < Else > -->
<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>
Hi @bobbyrinaldy
Thanks for the report, I think it's fixed on master , can you test it ?
And I just saw you manifest is not up to date; check the Readme π
Hi @bobbyrinaldy Thanks for the report, I think it's fixed on
master, can you test it ?
2 question :
- How about this line ? onNotification not fired on IOS 13.4, but messaging().onMessage did that
//Handling like this because on IOS, onNotification not Fired, and i ended doing something dirty like so, sad but working
messaging().onMessage((payload) => {
console.log('[payload] : ',payload)
this.showNotification(payload)
});
- How can i pull the master branch to my project ? sorry for asking, im new on this one, i just know change version not directly to the package branch
(Edit : nevermind, i can do like this
'react-native-push-notification' : zo0r/react-native-push-notification#masteron package.json)
Hi @bobbyrinaldy Thanks for the report, I think it's fixed on
master, can you test it ?
Quick Update :
-
im updating the package to
"react-native-push-notification": "zo0r/react-native-push-notification#master" -
update the manifest like so :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.testapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:usesCleartextTraffic="true"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="YOUR NOTIFICATION CHANNEL NAME"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>
<!-- Change the resource name to your App's accent color - or any other color you want -->
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->
<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>
and result is the same as what im asking above, sorry. @Dallas62
@bobbyrinaldy I will investigate ASAP
@bobbyrinaldy I will investigate ASAP
okay, i will waiting for it then.
btw, thanks for your quick response, love what you did π
Hi @bobbyrinaldy Do you need local notification or scheduled notification ? If not, I think rnfirebase-messaging is enough for your case.
What I don't understand with this Firebase Feature is we just need to generate a token and setup analytics, but it's not enough... I saw you can send the token to a backend en register to a Topic (like android), and with rnfirebase: messaging().subscribeToTopic('weather')
rnfirebase#topics
Hi @bobbyrinaldy Do you need local notification or scheduled notification ? If not, I think rnfirebase-messaging is enough for your case.
What I don't understand with this Firebase Feature is we just need to generate a token and setup analytics, but it's not enough... I saw you can send the token to a backend en register to a Topic (like android), and with rnfirebase:
messaging().subscribeToTopic('weather')rnfirebase#topics
push notification from rnfirebase-messaging cannot push the notification for me, idk why. but this package do
ya i know, but simple one is using this package to manage how FCM received like on IOS did. so no other way to fix this ?
Hi @Dallas62 , i have a question, If im using this package as Push Notification , should i install this one earlier or NOT NEDDED at all ?
- @react-native-firebase/app
- @react-native-firebase/messanging
i think my problem coming from i installed all of that RNFB
I don't know why rnfirebase is not working for you, or if there is any conflict, it's strange. Maybe you should try to remove rnfirebase from AndroidManifest to test, or retry rnfirebase π
I don't know why rnfirebase is not working for you, or if there is any conflict, it's strange. Maybe you should try to remove rnfirebase from AndroidManifest to test, or retry rnfirebase π
yea thanks, try to to test push notification using CURL/Postman and it is seem's working now for Android to receive Notification on Foreground and Backround app, but still Dead/Killed state did not received. can you check it ?
For Dead/Killed, test with then version on master, the default channel is not created on the current version.
For Dead/Killed, test with then version on master, the default channel is not created on the current version.
yes, im using like this on my package json :
"react-native-push-notification": "zo0r/react-native-push-notification#master"
and my Manifest like on Docs
<uses-permission android:name="android.permission.WAKE_LOCK" />
<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="PUSH_NOTIFICATION"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="PUSH_NOTIFICATION"/>
<!-- Change the resource name to your App's accent color - or any other color you want -->
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->
<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>
@Dallas62 i tried to build the apps on my other phone, seem's like onRegister called but when i hit with Postman , it say NotRegistered


I did the same test:

Hi, my iOS not working in foreground, but background is working, am I missing any setup?
"@react-native-firebase/app": "^6.4.0", "@react-native-firebase/messaging": "^6.4.0",
Hi @programmer-RN This issue is not related on iOS, you should look at : https://github.com/react-native-community/push-notification-ios/issues/106 https://github.com/react-native-community/push-notification-ios/issues/107 Thanks
Hi, my iOS not working in foreground, but background is working, am I missing any setup?
"@react-native-firebase/app": "^6.4.0", "@react-native-firebase/messaging": "^6.4.0",
Why is mine behaving differently compared to all of you lmao. My android is working fine, my iOS foreground is working fine but iOS background can't work haha
hi @Gabsys, you can check others issues, this is due to a change in https://github.com/react-native-community/push-notification-ios
hi @Gabsys, you can check others issues, this is due to a change in https://github.com/react-native-community/push-notification-ios
I can't find the relevant issues though. Could you give me some heads up/tips? ><