Open rochapablo opened 6 years ago
i'm facing the same issue, any light @evollu ?
@rochapablo @fecabianchi faced this exact same issue few days ago. Took a chance to write it as a blog post, take a look
http://faysal515.xyz/2018/06/react-native-push-notifications-counter-implementation/
@faysal515 i see that you are sending the badge value from the backend right? how do you control the badge value?
@fecabianchi we're maintaining this information in the server. once the app is being opened, we're clearing the badge counter to 0
I'm doing the same as @faysal515
back to @rochapablo 's question.
when you say while the app is dead (closed)
, do you mean you swiped and killed the app? In that case, no logic will be triggered (JS or native code). however, badge should still be updated if you put it in notification
payload
@faysal515 where do you put the code for clearing the badge? when the app is dead and i open the app my event that set the badge to 0 is not triggered... when you clear the badge you update the database?
@fecabianchiI don't exactly know where is our setting badge to 0 is written since someone else on our team is working on the react native part. But most probably in the componentDidMount
of the root component. And yes, we're also clearing db at that time. I'm writing the process if that somehow helps you.
badge
in the server. sending the badge
in the notification payloadbadge
value to be 0 for that user.i tested with android when app totally closed. I got this function triggered:
messaging().onNotificationOpenedApp(remoteMessage => {
console.log('Notification caused app to open from background state:', remoteMessage)
})
But when user click into notification, app opened without any callback, then i can not get message data
Hey, this is more a question; The notification it's working pretty well while the app is opened (foreground) and minimized (background); events and badge working. Good.
Now problem is, while the app is dead (closed) I can only receive those banners, but not badge or listeners; Question:
Is there a way to fix this? Should I use
react-native-fcm
ornative code
?What version of RN and react-native-fcm are you running?
What device are you using? (e.g iOS9 emulator, Android 6 device)?
Is your app running in foreground, background or not running?