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
[🐛] The operation couldn’t be completed. No APNS token specified before fetching FCM Token #6893
Comments
After adding initializeApp() with credentials from new firebase app it stopped hanging. However, now encountering:
So trying to debug this now |
with the latest firebase-ios-sdk (v10.4.0+) an APNS token is strictly required as a prerequisite to get an FCM token
|
Hi @mikehardy thanks for the response. I'm very confused. Apologies as I'm still relatively new to react-native. Note that I'm also using Expo. In my example above, I am calling registerForRemoteNotifications before calling getToken. |
I'm not sure why, but the FCM system does not have an APNS token set for your app before you request an FCM token. One thing that might be uncomfortable to hear but is nevertheless important: others have this working. The code works in the module. Why is that important but maybe uncomfortable? Because it implies (though no, it does not quite prove...) that the problem is specific to your app and your configuration. You should triple check everything with the assumption the problem is in your app and no one will be able to help you find it - you will likely find the problem yourself in your app upon further careful inspection. There is still of course the possibility the problem is in this module, but no one else is experiencing it so I am operating on the assumption the problem is project-specific |
Thank you for your respectful response! Definitely appreciate this input. I think part of the reason I raised this issue is that I did see some other threads for a few weeks ago related to this issue. So I thought just getting the minimal example to reproduce the issue could cause an issue - so in case anyone else encounters and has found a solution they may stumble upon this ticket. The fact that this sounds like only affecting me indicates it is indeed a problem with my configuration - I guess the tough part I'll need to figure out is what is the issue with my configuration:). Anyway best regards, and thanks again for the pointers |
The new strict requirement for an APNS token prior to an FCM one is bound to turn up issues like this so I will be very curious to hear what you turn up. Right now the entitlements idea is my best one for you but maybe it's something else? There was a lot of traffic about this recently because they added this requirement first on the backend without warning which exposed lots of people getting FCM tokens with no corresponding APNS token and broke their apps. Of course those non-APNS FCM tokens are useless, but breaking the misconfigured apps unexpectedly was bad and generated all the traffic. They relaxed the backend change but left the SDK change in for firebase-ios-sdk 10.4.0 release so it is now only seen by folks as they upgrade, which is you now. It's a valid change (the APNS token should be required...) but forces everyone to find their corner cases where it fails now. And here we are... Anyway, definitely report back if you find anything, and I hope you do + quickly. Cheers |
also running into this issue today. not sure right now why that is. it's not a minimal example, but issue can be seen by cloning this repo: https://github.com/GaloyMoney/galoy-mobile |
@k2xl I had the same issue minutes before. I solved it by checking in signing & capabilities. Inside "Background modes", I selected "Background check" and "Remote notifications". I hope this helps you. |
just tried that and had no effect on my end. I realized I had not set |
I have been digging into this problem the whole evening. In my case the problem was that in I don't remember why did I set |
on my end, solving by doing a full re-install off the app. don't know how it got corrupted in the first place but anyway, no longer seen the error message. |
I fixed this by changing From {
"react-native": {
"analytics_auto_collection_enabled": false,
"messaging_auto_init_enabled": false,
"messaging_ios_auto_register_for_remote_messages": false
}
} To {
"react-native": {
"analytics_auto_collection_enabled": false,
"messaging_auto_init_enabled": false,
"messaging_ios_auto_register_for_remote_messages": true
}
} And deleted call await messaging().registerDeviceForRemoteMessages() |
Thanks for the responses. I am on an expo managed app so didn't have a firebase.json file... I tried adding a firebase.json to the root of the folder and removed the However |
Hey, i just stumbled upon this issue, got a solution? |
I don't believe this statement is true? The docs should say (and I think they say?) that you must call setAPNS *if you have disabled method swizzling or for some other reason have disabled the automatic firebase APNS token handling on remote message registration In almost all cases, certainly the "default integration" cases, if you call the API to register for remote notifications, and have You only want or need to use setAPNS token if you really want to manage APNS tokens yourself (for automated testing on non-Apple-Silicon emulators, perhaps, or if you have some brownfield app where you manage APNS tokens yourself, etc) |
We appear to have an issue in the reference API docs where line breaks in our method docs stop the rest of the doc from rendering but the whole doc is as such: react-native-firebase/packages/messaging/lib/index.d.ts Lines 888 to 906 in 2e51817
I'll see what I can about getting the rest of the info to actually show up on the reference site as it should. |
Hi Mike, According to the changelog there were some breaking changes:
EDIT: Saw your reply, i'll have a read through. The thing is, nothing changed in our code, we just updated the package, then it started throwing the APNS error. Been working flawlessly prior to this :) How i noticed it; the entire app hung on the splash screen (both simulator and device - iOS). Moving the getToken() function to after the app checks for permissions, fixed the freeze. However it's throwing the error: |
Yes, as you quote, I quote the important bit:
That is
Almost no one does either. In the testing case, you can inject a "correctly formatted but useless" APNS token just to exercise FCM APIs, but who would do that except someone that implements FCM APIs (that is: us here, as maintainers...). So it's possible but I expect no one else to do it. And disabling swizzling is something I'd consider "advanced" on the iOS side. If you're disabling swizzling you are effectively on your own as you have moved past the default + works implementation and are stating clearly (by disabling swizzling): "we know what we're doing on iOS, don't worry about us" |
--> #6893 (comment) |
Yeah, but the thing is; this code have been running fine in a simulator upon until today when doing a package update, then the freeze, now the error. This also occurred on a real device |
...across a breaking change boundary, which contains this note: https://github.com/invertase/react-native-firebase/blob/main/CHANGELOG.md#1700-2023-02-02
It's a big deal, it must be handled. Getting an APNS token is an asynchronous network-bound process that could fail, or may even be disabled by some configuration issue. Previously these misconfigurations or order-of-operations issues were ignored and Firebase would gladly vend an FCM token that was useless as it had no corresponding APNS counterpart. Now it is (correctly, but maybe painfully) saying "Nope, an FCM token in this context is actually without value, so we won't give you an FCM token without the APNS token behind it" And we all have to adjust by making sure the APNS token is really there before asking for an FCM token. Might require checking network, re-trying, verifying you really register for remote notifications, you really have your iOS app entitlements correct, you have permission etc, but that's all justified and correct. Just a bit painful, maybe unexpected. |
Yeah, but how do we actually check for the token? That's what we are asking about. How can we adjust the code? Isn't that function supposed to check to see if the APNS are there? Just want to reiterate: that all the certificates/keys etc are in order |
well...it does, but not in a pleasant way. It checks and throws an error if it's not there. Shouldn't be hanging you should be getting the error I think you report:
So, perhaps you want to make sure you have permissions from the user, that you register for remote notifications, and that getAPNSToken returns a token (any token, value doesn't matter - except undefined is bad of course). Once those work (perhaps in a backoff retry loop with a final error to user saying some functionality won't work?) then you go for the FCM token |
Awesome, yes, that's exactly what I ended up doing. Good to know that it handles the error kinda weird. The hanging/freezing issue was fixed by moving the |
Got the same error after upgrade Signing & Capabilities -> Background Modes (Remote notifications, Background processing) enabled. Before this upgrade everything was fine. Is there any solution for this issue? I see this is a new issue but I think a lot of people will see this issue after upgrades. So any workaround, patch or instruction is really needed. Right now, I decided to stick with old version of module. |
I get this error when update the app from Testflight, i am using Ver 17.3.2. I found that when i install the previous app and get the fcmToken successfully . After that , i update the app from Testlight, then the getToken() function return this error. |
I also tried getting the token in a setTimeout after 3000ms, seems to be reliable now. No clue why this would happen outside of Chrome V8 Engine as the server.... |
Same, getting it the first time (full app deletion and installation) works. Killing and restarting gets the error :| 📱(real device) |
I solved the problem by updating mac os and installing additional components of Xcode that were requested after the update. |
I removed my app from my device and built it again and it worked. |
Sometimes I got this, anyone here can share a solution? |
@sandeep14 any luck for you? |
after calling in timeout of 2000 sec then we getting token for every time |
Thx for your reply. Did not work for me tho :/ |
Is there really no solution for this yet??? |
I'm having similar issue in a Unity project, downgrading Firebase to 10.2.0 helped in my case. Maybe it's working in a later versions, but I didn't have enough time yet to check which ones are working too. Hope it helps someone! |
Any solution for this problem? Setup a project from scratch released on store, when it comes to push notification, i set the apns but nothing make it work. It's very trick. |
I got that error after configuring the react-native-splash-screen, and before getting the token, I waited for 1000 ms, then it worked fine. |
I got sorted it out by adding the |
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
Thank you for your contributions. |
if you are on iOS simulator, i just quit the simulator device and rerun again. I experienced the error when i tried to simulate notification via |
Could somebody please point me into a direction that explains what to enter as a parameter in From what I understood, this is a required step in the latest version, but I can't find any info about how to obtain that value, calling
|
this worked for me. |
It seems to me that getToken() doesn't get it right away after starting the app.
If you do not do this, getAPNsToken() will not return on iOS. |
same +1
I nedd to getToken send to server. when the key
I need this configuration key to turn notification on or off. but when the key is true, the switch is false, and ture it on, I got warning |
question, base on some search I found that getting APNS token should be working on Simulator but I tried all settings and configuration on the documentation, it didn't work and still get the error/issue on the APNS Token. Also, on the documentation in this link it says
As there not clear answer, I switch to real devices and it all works |
Good point @eggybot, unfortunately the docs don't 100% clearly state whether it's even possible to get a messaging token on the iOS simulator:
It says "iOS devices", so I guess it's normal to get the "You must be registered for remote messages..." error on the iOS simulator. Would be cool to clarify this though, maybe the man @mikehardy himself could give us a hint about this? ;) |
The iOS Simulator can get an APNs token and do messaging, if it is iOS 16+ and it is running on an Apple Silicon machine and macOS is 13+: https://github.com/invertase/react-native-firebase/blob/main/CHANGELOG.md#features-11 Which leads to this chunk of diff: 8d75b36#diff-348d828b3a27617f7b287d2f055dfe4641effd95bdf21cbfb87397c4675dea7fR22-R27 Where you can see the conditions that must be met and how I exercise this new (and pretty cool) feature as I implemented it for react-native-firebase v17 since I was eager to actually see this work and prove that it (and our implementation here) worked. It does! In all other cases you need to make up a token and send it through setAPNSToken in order to try do anything with the FCM system, and you will not actually receive messages. Sadly, I missed that chunk of documentation someone just linked, and I've posted PR #7381 to clarify it - I'll merge it shortly if no one has any comments but I'll leave it open for review in case anyone has a better of way of clarifying it, just post up a comment on the PR Hope this helps |
100% Fixed my issue by:
(FYI, make sure to use real device for testing.) Hope it works for you guys. FYI: |
Hi please where do I add or find this "didRegisterForRemoteNotificationsWithDeviceToken" |
I setup "didRegisterForRemoteNotificationsWithDeviceToken" when I install @react-native-community/push-notification-ios
|
Rodney-Web + rhfksl method worked for me, |
Issue
Trying to get token from user.
When running this on iOS simulator, I getA
on the console but it never reaches B. On further debugging just callingawait messaging()
seems to do enough to hang.I see now after adding initializeApp() with credentials from firebase the following error
Project Files
Javascript
Click To Expand
package.json
:firebase.json
for react-native-firebase v6:# N/A
iOS
Click To Expand
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:// N/A
android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:// N/A
AndroidManifest.xml
:<!-- N/A -->
Environment
Click To Expand
System:
OS: macOS 12.5
CPU: (10) arm64 Apple M1 Pro
Memory: 227.88 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 19.5.0 - /opt/homebrew/bin/node
Yarn: Not Found
npm: 9.3.1 - /opt/homebrew/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9477386
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 17.0.6 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.5 => 0.70.5
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
react-native-firebase
version you're using that has this issue:Firebase
module(s) you're using that has the issue:e.g. Instance ID
TypeScript
?Y
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: