-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IOS unable to receive notification #1203
Comments
I think I have a similar problem except my messages are showing up, but in the wrong context. I have both remote Messaging and Notifications enabled, yet when I send a Notification+Data message from the FCM Console, the message is received on With that in mind, have you tried following the instructions in the Cloud Messaging setup, i.e. listen with |
@TimMun thanks for the suggestion Yes I've tried with there is one more thing I'd like to mention, my delegate methods are not calling. |
It appears as if RNFirebase documentation is missing a few required steps. After adding the below code after
Make sure to add the required import or else your code won't compile |
Can confirm this worked for me, now notifications sent from FCM composer are coming thru on notifications().onNotification(). Thanks! |
As per the documentation, this block of code is handled by the |
@chrisbianca Can you please clarify something, we just spent days debugging this issue and I think I just understood the source of it and a way to avoid future confusion. We were experiencing notifications from our app not arriving, not even when calling APNS directly using the APNS token. (Although, only for some users). We were not calling return firebase
.messaging()
.hasPermission()
.then(enabled => {
if (!enabled) {
firebase
.messaging()
.requestPermission()
.then(() => {
this._initializeListeners()
Tracking.track('User just granted notifications')
})
.catch(() => {
Tracking.track('User denied notifications')
})
}
}) We still had reports of some people not receiving them. When we (almost by accident) added code similar to chriswang's above they started working for those people. So I have a few questions/points I'd like to raise.
The second example above is slightly misleading, because it's not true that we just have to ensure they granted permissions, we have to do it by calling a specific
Instead of having docs that suggest you do: firebase.messaging().requestPermission()
.then(() => {
// User has authorised
})
.catch(error => {
// User has rejected permissions
}); Have the default instructions be: firebase.messaging().requestPermission()
.then(() => {
firebase.messaging().registerForNotifications()
})
.catch(error => {
// User has rejected permissions
}); That way it's clear, even if you're somehow getting a permissions dialog without adding this code, that you still have to register for notifications. |
Hi everyone! |
@chriswang101 |
Worked for me too man. Thanks @sanjcho !!!!! |
still not working for me.. does have any config on AppDelegate.m ?!? |
When i delete and reinstall the app, FCM Console sending notification through fcmToken, however when i stop and run the code again, iOS device stopped receiving notification from Console. I have also added FirebaseAppDelegateProxyEnabled (yes) in info.plist. However issue has not been solved yet. I am planning to add cloud function to send notification, but even console has such reliability issue how i will go on? |
It's working ONLY while testing for a specific Fcm Token... not working while publishing a campaign (for all users). Any updates !???? |
It worked for me when I used firebase.messaging.onMessage() listener, but only on foreground. cannot get notifications in background and when app is closed. |
@yarian thank you so much - For everyone not receiving pushes - request Permission is required even if you have pushes already enabled!! I am migrating a swift app to react native and wasn't receiving pushes even though I had the token. Just calling requestPermission fixed it. |
Tried with latest react-native and firebase version, worked for me with @evanjmg tip. Anyone still have this issue? If not we can close It. |
@fabiodamasceno yes, I am still have the same issue on react-native=0.59.3 and react-native-firebase=5.2.5. Trying send all of json combinations of both notification and data (only data, only notification, and both together):
|
i am not able to fine FirebaseAppDelegateProxyEnabled in my info.plist, |
Can you please upload the full AppDelegate.m file or point me to a full-fledged walkthrough of the steps that you went through? Thant would be a huge help because my AppDelegate.m file looks a lot different that the one's I've seen on this thread. Thanks! |
Oof sorry it's been a year since I wrote that code and I no longer have access to the app's AppDelegate.m file. I do recall that the above code was the only significant change I made to the file. Otherwise, it was just a default AppDelegate file. |
I just tested my app both with and without those changes. Those changes are not necessary. Per the install docs, you need this:
You do not need to add the AppDelegateProxy = true plist entry, if you watch your debug messages in XCode you'll notice that's the default You do not need to add that big chunk of AppDelegate code, if you trace the react-native-firebase iOS code, you'll notice it does all that stuff already Then send a message and it should work. I just did this with the 5.3.x versions and pods 5.20.2 on iOS 9 even and it works My message send script looks like this, and I am receiving them reliably: curl -X POST \
--header "Authorization: key=$SERVER_KEY" \
--Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"to\":\"/topics/AppInfo\",\"collapse_key\": \"AppInfo\",\"content_available\": true, \"priority\": \"high\", \"data\":{\"task\":\"CheckVersion\"}}" |
Thanks man. it works |
@whalemare can you share your AppDelegate.m and code that you add to your solution, maybe the problem could be clarified :D. People, what do you think about send a PR with this improvement to documentation? |
I'm on record with my opinion of the suggestions here, sorry #1203 (comment) None of it is or should be necessary if things are installed correctly, on current versions. I have tested it, it works as currently documented I'm working on a demo here to back that assertion but just haven't got messaging demonstrated yet. If someone wants to beat me to it, you just need a public repo with messaging integrated as documented - if you can demonstrate a sample app installed as documented that doesn't work, then definitely we'll change docs but I'll be surprised... |
any follow up for this? try all above but still not help my problem |
tried everything but in vein, my firebase console says that it has send around 200 notifications in last 90 days but none received on IOS, android is fine, is the docs not clear or is there issue with the library? Its frustrating. |
For those who are still facing this, please make sure that you have push notification service key created in your developer account of apple, and upload this key with key id and team id to your firebase app in firebase console. For complete setup follow this video -> https://www.youtube.com/watch?v=zeW8DO5KZ8Q |
I spent a few days digging into this. I think the reason there are so many varying reports as to what works and what doesn’t is due in part to a few factors: 1.) not calling requestPermission; 2.) FCM token is not updated correctly; 3.) iOS and APNS throttling; and 4.) testing conditions. (All this is relevant to iOS only)
Resources This is all assuming you’ve installed everything correctly and are sending messages from your backend correctly (i.e. content-available=true, etc). After understanding the above, the behaviors are now a little more predictable. I tested my app using RNFirebase 4.3.x and 5.5.x; the behaviors are the same. Foreground notifications/messages trigger onNotification()/onMessage() respectively. Background notifications/messages don’t trigger anything except onNotificationOpened (I assume I’m running into throttling since attaching Xcode debugger makes background messages trigger onMessage()). I still have occasional (but rare) problems with messaging and notifications completely not working on install; force kill usually makes it work. Hope this helps somebody out there. Edit: If you want to see if your silent pushes are being throttled by iOS, you can go into Xcode -> Window -> Devices and Simulators -> Select your device -> Open Console, then search the logs for something like "push" or your app bundle id. If your app is getting throttled by iOS, you'll see log entries like |
@TimMun that's a fantastic explanation of a lot of the intricacies - it matches with my experience as well. And it's also why I almost refuse to help on notifications and messaging questions anymore - the info is all out there and it's possible to slowly, carefully, verify all these things but it is slow and you have to be careful! Slow is fast in this area. Would be very interested to see your future learnings on token refresh - what I've seen from the auto-test-suite attached to react-native-firebase is that the token refresh is potentially very asynchronous. It takes 10-20s on my (slow, far from google) connection, perhaps that has an interaction somewhere and results in dropped refreshes or some sort of race? |
@sam17896 Thanks, my issue was that I had not added the APN key to the cloud message config for my app, found that out form the video, thanks mate! |
For the current latest version (5.x) of RN Firebase, calling `requestPermission` also calls the `registerForRemoteNotifications` method. This is required for the fcm token retrieved to be associated to a valid APNS token, and for push notifications to be delivered correctly to the device. (invertase/react-native-firebase#1203 (comment)) I have been debugging an issue with push notifications and consistently calling the `requestPermission` method even when the user already granted permissions was the only fix. There is also a `firebase.messaging().ios.registerForRemoteNotifications()` method available, but I found that when I called it from the JS thread, a warning popped up in Xcode saying that this method (the underlying `[RCTSharedApplication() registerForRemoteNotifications]` call) should only be made from the main thread. This does not prompt the user on iOS after the first time the user responds to the dialog, so the user experience is not hurt by running this code over and over.
I am wondering where you found this line |
For anyone still struggling with this, I followed everything here and it still didn't work. What finally made it work was adding
as the very last line before "return YES;" in didFinishLaunchingWithOptions. Note that I also had the block of extra code above (if ([UNUserNotificationCenter class] != nil) {....), but it did not work without adding that last line at the end of the method. |
@chriswang101 Your solution worked for me like magic! Thanks alot |
I spent a few hour after i discover that it is necessary call |
Lots of good suggestions here, unfortunately none of them worked for me. At the end, what worked for me was never mentioned here: Waiting. |
I did spend some time on this issue as well ("react-native-firebase": "^5.6.0"), in my case a problem was a missing APNs Authentication Key. Make sure you did create it from Apple Developer Program and upload to Firebase Cloud messaging configuration. Here is a guide which explains required steps: https://medium.com/forddev/react-native-firebase-how-to-send-push-notifications-on-ios-android-part-1-b322d715b79d Regarding
and
was enough to make things work using:
|
@sdqwerty It works! |
Even in V6 this solves the bug. |
Thank @sanjcho |
I got the notifications working remotely in iOS 13.4. but my problem right now it's just the delayed notifications sometimes for about 15 minutes. But after i received it the next notification will be fast about 1 - 2 seconds. Anyone experiencing this issue? My index.js code using firebase cloud function
package.json
|
@dgana If you are getting the notifications, but only experiencing some delay, it sounds to me like the issue is not related to this library. It's possible that if you are sending too many notifications and not opening them on the device firebase might "penalize" you and start delaying notifications (or even not sending at all) but I'm not sure. |
thx @chriswang101 |
#1203 (comment) worked for me |
This works for me too. |
Fixed the issue even with @react-native-firebase/messaging 10.5.1 ! I suggest you to check out this solution if you have multiple connection errors in your Xcode console 📶 |
I have the same issue, how do you solved this problem? |
@xiuwangthoughtworks I think this is somewhat normal. Just because we as developers want things to happen does not mean we own the user's battery. The user does and the operating system does it's best to only actually run things periodically in batches. Sounds like what is happening here. |
|
@TimMun How can I resolve throttled silent notification in my device? I can resolved this issue with Settings-screen sharing - notification on |
Issue:
Not able to receive notification on iOS device
What I've tried:
I've followed this documentation to implement notifications in iOS,
https://rnfirebase.io/docs/v4.2.x/notifications/ios
iOS implementation:
AppDelegate.m
Application's Home File
Can somebody guide me in this, is there any other implementation way to receive notification in iOS
The text was updated successfully, but these errors were encountered: