-
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 - Cannot receive any notifications before the app opens second time #4299
Comments
Try doing it without remote debugger, that causes the JS bundle to run in browser vs on device and the execution environment is pretty different. Also, you may need to wait a little bit - these processes are all asynchronous in the cloud though your success response from node does seem to indicate it should work. |
I was having the same issue here on iOS with latest React Native and it seemed to persist even after uploading a production build to TestFlight. Downgrading the libraries solved the issue for me:
On iOS notifications were only received on second app launch and after, Android had no issues at all. I'm using the libraries exactly as @jagwingchoy, though having quite a bit more dependencies. Happy to add my environment details here once I'm back at work if it helps. |
Hey, Just to add that I appear to be having the same issue. "@react-native-firebase/app": "^8.4.3" I've tried using the default Firebase iOS SDK version and also overriding to 6.32.2 On first install and open from TestFlight:
Hard closing the app and re-opening it appears to resolve the issue - sending the same message with the same FCM token via the Firebase console is successful. Happy to add extra info if helpful 👍 |
This sounds like the sort of thing that may need a reproduction using pure Obj-C (or Swift) and nothing but the native APIs to see if it's firebase-ios-sdk or us https://github.com/firebase/quickstart-ios/tree/master/messaging - that is a skeleton which should be trivial to build a repro on |
Just to add more info, I am having the same issue with some devices.
|
Disclaimer: I'm no native developer 🙈 I had a go with the iOS quick start above and it seems to have the same issue which I guess points towards it being a firebase-ios-sdk problem? This was my process:
I can repeat the above process and it always seems to be the same. When testing the app without TestFlight and just running from Xcode to my device I experienced inconsistent results. Sometimes the notification is received on first install/open and other times I have to quit the app and re-open it. However, via TestFlight it seems to be consistently not working following the steps above. |
To set expectations: for something inconsistently reproduced or device specific this really doesn't sound like a problem with the module and also sounds quite time-intensive to troubleshoot, I will spend no personal effort on finding the root cause but will happily merge a well-reasoned PR. I strongly suggest using the firebase-ios-sdk quickstart messaging sample to attempt reproduction without this module |
for ppl that use performance and analytics, this is the combo that actually works for me(so far): "@react-native-firebase/analytics": "7.4.2",
"@react-native-firebase/app": "~8.2.0",
"@react-native-firebase/messaging": "~7.5.0",
"@react-native-firebase/perf": "7.3.2", |
I have the exact same behaviour. on TestFlight version it never works after first install, you need to force quit the app and open it again to start receiving notificaitons. But on XCode run version it sometimes works after first install other times it never works. I tried every possible hack to fix it over the last week and I am not able to find any solution. |
@ahmadworks did you look at the changelog for the versions released between the version you downgraded to and the version not working for you? Did you try versions one by one (if there are more than one) to see exactly when it broke? Then you can go into the actual version (I keep releases very small so it is usually just one PR with a small change) to see what the difference was? Then you can try the current version but overriding the difference (either via patch-package or - more likely it was a firebase-ios-sdk change) to see if it works again Finally, if it was code here you can point out the actual error, or if it was firebase-ios-sdk upgrading you can check their github for relevant issues and get an actual fix for the problem. I don't think we changed much here in the versions you mention so this sounds like a firebase-ios-sdk problem. If you need to make a reproduction from them you need to do it based off one of their quickstarts: https://github.com/firebase/quickstart-ios/ - they won't accept react-native issues |
@tomkelsey i was having the exact same problem as you -- after a clean install, nothing was being called. force close the app, re-open, and my notifications would start working again i just downgraded my app to the following versions:
Which in turn, changed some Podfile.lock versioning. This is what it looks like for firebase:
I'm not really sure yet if it was related to RNFB or Firebase core. I'm working on their quickstart app to see if i can find anything there. (btw, after i changed |
Thanks @adbario, I have downgraded to the versions you mentioned fixed the issue. |
@mikehardy please check this (leyserkids/cordova-plugin-firebase@124dd72) it fixed the bug for Cordova users. |
I am the author of this commit. this issue has gone after this change, But I am not sure if it’s really works well. |
Thanks for the suggestion @ahmadworks and for checking in @ewfian interesting your uncertainty, I remember reading the changelog for the last ios sdk update and thinking "hmm looks like we have a fair bit of work to switch away from any of the instance ID APIs as they're moving that all under messaging", so to me this really looks like it aligns with the future direction of firebase-ios-sdk and if I were the firebase-ios-sdk team I wouldn't even accept the instance ID bug as a repro, I'd just direct you/us to the API in that commit So to the point: is there anything specific you are uncomfortable with, or would a PR in this repo to make the analogous switch seem like the right thing? Seems like it would be right thing to me... |
Had the same issue and this worked for me, thanks @adbario |
Glad to hear there is a workaround but the most valuable thing anyone could do 🙏 🙏 is take the change listed above and make a PR here that implemented the same switch to the different/new API |
We're also facing the same issue here and it seems somewhat dependent on the iDevice, since some of our test devices don't face the issue while others do. Trying to switch to |
Interesting. I was operating under the assumption the referenced change from cordova ecosystem would resolve the issue. @TPXP - are you quite certain you attempted that patch cleanly (for example using If that PR doesn't fix the problem then, no, I don't just want a PR that rolls back changes, we learn nothing then. What I want is a bisect on the versions (perhaps already done? I think we know the version to roll back to, indicating that the next version broke?) to know exactly which PRs are the problem (they're not listed yet unless I missed them?) Then maybe a roll back PR, but I have a further hunch that it is a firebase-ios-sdk issue, so if the change in the PR that caused the problem is just bumping the firebase-ios-sdk we don't need a PR here at all. You just override the firebase-ios-sdk in your Podfile, but then we need a clean reproduction based on the quickstart directly against firebase-ios-sdk so we may get resolution The general idea being: we can't just move backwards here. The underlying firebase SDKs move too quickly, and when we support the new APIs (which we must do) we become dependent on the new versions, moving back blindly is not a viable plan. So I'm looking for any way to either stay current or log upstream issues vs current while moving allowing affected people to temporarily stay back. |
@mikehardy Here is the patch I applied. It breaks the scope feature but I don't need it in my app. I'm also betting this is a firebase ios SDK issue, especially since downgrading fixed the issue for some. |
Related discussion of scope, which I/we think may be broken already and will likely be removed: #3714 (comment) - I did a quick scan of the firebase-ios-sdk repo code and couldn't quickly + authoritatively say we're using the APIs right but that's mostly because the codebase is gigantic and I ran out of time. My goal with that was to see exactly how they are fetching tokens on app startup to make sure we're doing the same - I think their APIs all just moved here so perhaps we're still using the older (now-deprecated) APIs and their current release has only tested the new APIs thoroughly (that would imply there's a bug in the older APIs, could happen?). Nothing concrete to say though, sorry, and I'm out of time on this one for a while |
I have tested it many times on different devices in the past few days and it has worked well through this modification One point that needs to be explained is that I called
This is because I want to provide users with a reset button when they complain about not receiving the push. It will call I'm not sure if this method call triggered the FCM associated APNs token. You guys can try to add this and try to find if it’s effective. As @mikehardy says:
How APNs token and FCM are associated is unclear. If anyone knows the principle, can you explain it? |
this solution does not work for me. i can only see notification on background and cannot access notification data. |
A simpler way is to look at the firebase-ios-sdk release notes to find the first version they introduced the bug, then override firebase-ios-sdk versions in your Podfile to use that one. I'm not sure what version that it is though, I'm more focused on moving forward / forward-porting sorry |
#4471 has landed and is released, this should be solved now. Pay VERY CAREFUL attention to the breaking changes notes on https://rnfirebase.io/releases/ in case you need to forward-port any of the APIs you are using (or drop them, if they were deprecated) Any testing feedback would be welcome Note that if you use on-device inference from ml-vision or ml-natural-language you will need to wait until react-native-mlkit gets that functionality re-homed (it is my next task), but if you use cloud inference you can migrate directly to the new consolidated Cheers |
exactly, after remove Intercom SDK, i can access data notification on first time open app. |
I'm sorry, I won't have time to debug interaction issues between a 3rd party product and react-native-firebase - it just isn't a priority It may help to test with the most up to date firebase-ios-sdk though, check this release note: https://firebase.google.com/support/release-notes/ios#fcm (on the 7.1.0 release) Also / in addition - if anyone could document the workaround it would help others, perhaps here? https://rnfirebase.io/faqs-and-tips - or maybe we need a new page for interaction between other messaging packages If there is actually a problem with the way this module swizzles AppDelegate handlers then we can merge PRs to fix it but they will have to be contributed + tested by the community (that's you all, here) |
Thank for working on resolving this @mikehardy I tried the latest release and the issue was solved on the device I was testing. However, it turns out I'm still seeing something similar in some devices. @jagwingchoy it's very consistent that for those messages which aren't delivered (sometimes they are delivered but delayed by a LOT) I get a message id that starts with |
Very important to note that FCM never establishes a connection to iOS devices any more - direct channel FCM was removed from iOS. It is always FCM -> APNs -> device. I'm not sure that has bearing or not, but maintaining clarity in mental models is critical in keeping universe of possible causes/effects manageable... |
My project was don't received notification before opens second time on production build. |
My app use react-native-notification-badge to update badge of ios and it use APNs so conflict with firebase-messaging. |
You might like notifee.app - fully open source now, and supports badging on iOS, https://notifee.app/react-native/docs/ios/badges - not as simple as that notification package, but should not conflict with firebase messaging |
same here.. do you find any workaround |
pls check my comment #4299 (comment) |
So what was the resolution here? seems like its still been kind of ongoing still? And I know it affects Testflight, does that mean it affects an app store release the same as well? |
@justinkchen all the development is in the open. You may read the comments and determine status. I just did, it seemed like a subtle interaction of 3rd party providers that you are other affected users would need to inspect and drive to a root cause if desired. It's not reproducible in a stock app and does not appear to be caused by the module, or at least not demonstrably so yet. I'm open to collaborate with anyone on PRs if they are proposed. |
Hmm okay I don't really have any other 3rd party provider that I can think of that would interfere. I saw some other thread somewhere else in the searching of this talking about how the permission of allowing notifications was coming after firebase was initialized and how that might be causing it so that firebase messaging not working until force restart of the app. Is there any validity to that idea? If so, any ideas how we could reinitialize firebase or somehow have that permission checked before firebase initializes? |
There's a lot of speculation there for something I haven't seen 🤷 - that always leads me to: |
Thanks Mike! I'll try to see what I can do to get it into a minimal state. I'm currently getting very consistent behavior of working 100% of the time on builds directly to phone, 100% of new app install from TestFlight doesn't work on first acceptance of permission but works after a force quit and reopen, and I'm waiting on a deploy to app store to confirm if it's same behavior as the TestFlight scenario. |
@justinkchen seems like an onerous test cycle. Is the AppStore build not equivalent to a local release build, installed on phone? If not, why not? A reproduction that involves releasing via TestFlight isn't going to be too useful for us here as we don't have our test apps here configured for TestFlight release... |
Haha I guess that's what I'm trying to figure out. At first I thought it wasn't working at all until I found the trick of closing and reopening. And yea I'm also unsure why the one on phone is different but I think it's being built in debug mode rather than release? So something maybe in my debug/release specific handling of stuff? |
|
i've been running it by just clicking the Play button with my connected phone selected on Xcode GUI (on the top middle), so not sure which command that one runs under the hood |
Literally the one I wrote `npx react-native run-ios --configuration Release --device 'JustinKChens iPhone15Max' |
Hi, |
Hi, Thanks in advance. |
I am encountering the same issue with the following dependencies: @react-native-firebase/analytics: ^21.2.0 Are there any alternative methods to resolve this problem? |
Background
Here I am changing the notification service from appcenter to firebase.
I am building the app to my real device (iPhone XR) using Xcode in order to test notifications.
I have tried to search the issue from this issues board, stack overflow, and google, but still cannot find any related reports.
Project Files
index.js
App.js
I have also built up a
firebase-admin
nodejs server for pushing notification:Then I will call the function like below:
I surely follow the instructions to install the
react-native-firebase
and allfirebase-cloud-messaging
steps in https://rnfirebase.io/. (Also the image notification in iOS)Issue Encountered
After I have built the app into my real device(iPhone XR) through Xcode,
I will open the debugger to get the fcm token from
console.log()
. No matter:firebase console
or my own builtnodejs function
it cannot receive any notifications. The logs in nodejs function show it is success:
But after I completely quit the app from background and restart the app again, it can receive notifications normally. The logs also show it is success:
One thing I have noticed is: the
message ID
are always start with0:
when I cannot receive the notification.Does anyone encountered this problem? And how to solve it?
Environment
Click To Expand
react-native info
output:package.json
The text was updated successfully, but these errors were encountered: