notification is received when app in foreground by onMessage() this function
.messaging()
.onMessage(message => {
console.log('message received', message);
});
but it not received when app in on background.
firebase libraries versions:
Using Firebase (4.0.4)
Using FirebaseAnalytics (4.0.2)
Using FirebaseAuth (4.0.0)
Using FirebaseCore (4.0.4)
Using FirebaseInstanceID (2.0.8)
Using FirebaseMessaging (2.0.0)
iOS device version: 11.2.2
@Mamdouh-Symbyo FCM support is a little shaky at the moment and we're planning on overhauling it in our next major release. We've had lots of similar issues reported that we're closing off until we properly fix the functionality.
Keep track of this for updates: https://github.com/invertase/react-native-firebase/issues/595
@Mamdouh-Symbyo
You need to upload your certificate to the firebase messaging settings.
Then enable push messages in xcode and it will work even when running the app in background and its closed.
@Mamdouh-Symbyo where do I upload the certificates?
its working with me now,
what i did:
-generate APNs key.
https://firebase.google.com/docs/cloud-messaging/ios/certs
-upload APNs key to firebase project.
in firebase project => settings => cloud messaging => iOS app configuration => APNs Authentication Key
-also Make sure your application requested notification permissions upon first launch.
// requests permissions from the user
FCM.requestPermissions();
FCM.getToken()
thank you @chrisbianca
@hegelstad
i upload APNs key to
firebase project => settings => cloud messaging => iOS app configuration => APNs Authentication Key
@Mamdouh-Symbyo i have already uploaded the .p8 file in the firebase project setting its not working when app in background,
should i upload the .p12 file ???
@yusuf987 When you upload a p8 key and it doesn't work meaning there's an issue with your p8 file.
Try using below code in Postman or Terminal and see what it responds
curl -X POST \
https://fcm.googleapis.com/fcm/send \
-H 'Authorization: key=REPLACE_FCM_SERVER_KEY_HERE' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"to" : "IOS_DEVICE_TOKEN_HERE",
"notification" : {
"body" : "Push test",
"title" : "Push test",
"content_available" : true,
"priority" : "high"
}
}'
I was having the same issue, I finally resolved it by Re-generating new APN Key auth file and Re-uploading to FCM.
What was the issue in my case:
Other possible issues:
Most helpful comment
its working with me now,
what i did:
-generate APNs key.
https://firebase.google.com/docs/cloud-messaging/ios/certs
-upload APNs key to firebase project.
in firebase project => settings => cloud messaging => iOS app configuration => APNs Authentication Key
-also Make sure your application requested notification permissions upon first launch.
// requests permissions from the user FCM.requestPermissions(); FCM.getToken()thank you @chrisbianca