I'm trying to test FCM push notifications on an iOS (iPhone 6S). I've got this working a month ago, but now I do not get it to work.
I'm using React Native Firebase v.5.x.x. I've followed the initial setup guide, the setup guid for cloud messaging and the setup guide for notifications. I also followed this manual on the firebase docs to set up APN certificates.
Now, when I use the editor on the firebase console to send a notification, I do not get any response from my app. This is my react native code in my app.
const run = async () => {
const enabled = await firebase.messaging().hasPermission()
console.log('firebase', enabled)
if (enabled) {
// user has permissions
console.log(await firebase.messaging().getToken())
} else {
// user doesn't have permission
try {
await firebase.messaging().requestPermission();
} catch (error) {
// User has rejected permissions
}
}
}
useEffect(() => {
run()
}, [])
firebase.notifications().onNotification((notification) => {
console.log(notification)
});
With this code, I ask for permission to receive push notifications. I see the permissions dialog when I open the app for the first time. I accept the notifications. I also get a console.log output with the FCM token (console.log(await firebase.messaging().getToken())
). I use this token in the notification creator in the firebase console to send a test notification. But I do not receive anything, if the app is in background, foreground, closed, ... it doesn't matter.
I have created a provisioning profile and I've added this in xcode. In xcode, going to my project > signing & capabilities, I've added the capabilities 'background modes (remote notifications)' and 'push notifications'. At the signing component, I have added the provisioning profile. I have unchecked automatically manage signing.
It seems to me I've done all steps necessary to receive push notifications. I'm testing on a real devices (iphone 6s), not on a simulator, and I've got it working on another iphone (6s) before, so it should work.
Am I missing anything?