I have issue on both platforms.
I am using react native 52.1 and latest version of RN firebase.
I can show heads up notification on both OS (push or scheduled notifications) when app is in background, killed and when app is in foreground onNotification is triggered so I make some other action in that case (like show alert and not heads up notification).
My problem is I need to increase app icon badge when get notification.
But I can't do that as onNotification
is not triggered when app is in background.
So I see notification banner but callback itself was not called.
My payload:
{
"to": "tttToken",
"notification" : {
"body" : "test",
"title" : "test",
"subtitle" : "test",
"sound": "default"
},
"data": {
"targetScreen": "order-details",
"orderId": 9087787
}
}
Actually I added onMessage and onNotificationDisplayed and it seems when app is in background none of these callbacks are fired when app is in background.
But as I said I get notifications it鈥檚 just functions are not triggered.
Same is for onMessage when my payload contains only dara.
Have spoken with @vvusts on discord to clarify this issue.
I have similar issue, but in my case I schedule local notifications, with no payload, and have to increase app icon badge while app is in background. And as in @vvusts case none of the callbacks is being called in background.
@chrisbianca could you share details on how to make it work?
i also got this, notification even with onNotification//.onMessage((message: RemoteMessage) => {console.log()}); empty values notifications gots triggered without onNotification function.
I am seeing this issue too, onMessage
does not trigger if the app is running in background (verified by debugger being connected). The notification is shown, however when tapping it, the app moves to foreground but does not trigger the onMessage
callback.
This seems to be happening on iOS and Android.
For me onMessage is triggered in background on android but not on ios.
This is why I use notifications on ios and message on android (and create notification manually).
@chrisbianca explained to me that there is some issue with this background things and should probably be solved soon.
@vvusts neither onMessage nor onNotification is getting triggered for me. Can you please suggest how you made it working?
@NarendraSingh88 if you didn't check once more installation documentation.
Don't forget anything in android manifest.
Make sure that your notification/message payload JSON is good.
And make sure that you didn't forget this part: https://rnfirebase.io/docs/v4.2.x/messaging/receiving-messages#4)-(Optional)(Android-only)-Listen-for-FCM-messages-in-the-background
i got it working on android (as @vvusts noted) onMessage() and manual notification display background/foreground. i have left onNotification() asside.
@vvusts onNotification is getting triggered, but only when app is in foreground, but I am stuck for managing it in case of background. Though, the default status bar notification gets displayed in the background, _but I need to navigate it to the specific screen on tapping / clicking the notification_, and for that I need some callback like onNotification / onMessage in background as well, similar to foreground. Everything is working well, in foreground mode. The issue, I am facing is specifically in the background mode.
Did anyone find the solution? I am facing exactly the same issue as @NarendraSingh88
Hello All , Foreground and Background notification working perfectly in Android. but notification received when app in foreground in IOS but notification did not receive when app in background. is this issue still exist in IOS? any solution ?
onMessage
doesn't work when the app is in background in IOS. As soon as the app is in foreground, all of the notifications sent before are displayed. Neither onMessage
nor onNotification
gets called when the app is in the background.
@laukaichung background is working in iOS when you listen for onOpen callback
Hello All ,
I am facing exactly the same issue, Foreground and Background notification working perfectly in Android. but in IOS notification did not receive when app in Foreground. any solution ?
Same issue here
@chrisbianca any update on this? Still happening...
I have same problem. onNotification is triggered on android but not work on ios.
on IOS, onMessage is triggered on foreground but isn't triggered on background and closed app.
Any help?
thanks!
I have also the same problem on iOS. When the app is foreground, both onNotification and onNotificaitonDisplayed events are triggered, however when the app is background & killed neither of the events are triggered.
I'm using the versions below. Any help would be really appreciated.
react-native : 0.60.5
react-native-firebase : 5.5.6
@petrucci53 that's just the way iOS works. You kill the app it's dead. I think the google docs have a table that shows all of this?
I am facing same issue.
When i send notification on iOS it triggers onMessage
theres is no activity in onNotification
event and no banner pops up.
Same thing works fine on android though.
react-native: 0.59.4
react-native-firebase: 5.5.6
podfile
pod 'Firebase/Core'
pod 'Firebase/Messaging'
APNs certificates added on firebase settings as well. Nothing seems to work.
@mikehardy .onNotificationOpened()
& getInitialNotification()
callbacks are not being called on Android
only. I've used react-native-splash-screen
in my project, is that problem ? android:launchMode="singleTop"
I've this on my .MainActivity
, but my app starts with .SplashActivity
.
onMessage()
is working in all conditions on both iOS and Android. iOS is working all fine. Can you please tell if there is any setup I have to do ? @dikshaonline Since your Android setup is working, can you specify your setups ? or put basic codes here ?
@deepankarsandy there is all sorts of setup you need to do. it's all documented on rnfirebase.io though. You also have to be careful of interactions with other modules default setup guides e.g. (code included): https://github.com/crazycodeboy/react-native-splash-screen/issues/289
Thank you @mikehardy. It's react-native-splash-screen
. This is the solution. https://github.com/invertase/react-native-firebase/issues/1272#issuecomment-421424104
Most helpful comment
Hello All , Foreground and Background notification working perfectly in Android. but notification received when app in foreground in IOS but notification did not receive when app in background. is this issue still exist in IOS? any solution ?