I use firebase/messaging in my react-native application to receive data-only notifications from firebase.
When a message is received, i'll process the data, update my state and show a local notification with react-native-push-notification if the app is in background or terminated.
messaging().setBackgroundMessageHandler(async remoteMessage => {
PushNotification.localNotification({...})
})
At the android device everything works perfect in foreground, background and terminated state.
In iOS foreground and background is working.
When the app is terminated i can log the notification in the console (see below) AND there is a notification sound. But no local notification is showing up.
When i try to logg the iOS device the console prints following output
default 03:51:53.697535+0100 dasd Daemon Canceling Activities: {(
com.apple.pushLaunch.de.myapp.app:D1FAA2
)}
default 03:51:53.697770+0100 dasd CANCELED: com.apple.pushLaunch.de.myapp.app:D1FAA2 at priority 10 <private>!
My message from the server is:
const message = {
data: {
body: JSON.stringify(msgBody),
title: title,
},
contentAvailable: true,
priority: "high",
android: {
priority: "high",
},
apns: {
headers: {
"apns-priority": "10",
"apns-push-type": "alert", //already tried background too
"apns-topic": "de.myapp.app",
},
payload: { aps: { sound: "default", contentAvailable: true } },
},
tokens: userTokens,
};
It drives me crazy for days now and i cant get it to work. Every help is appreciated
Version 7.18.0 - August 13, 2020 Cloud Messaging
Deprecated setBackgroundMessageHandler. Use the new API onBackgroundMessage instead.
https://firebase.google.com/support/release-notes/js#cloud-messaging_2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With