-
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
[🐛] 🔥RNFBMessaging getToken - no APNS token is available. #8435
Comments
Hey there, thanks for the details and providing a snippet, looking at the stack trace its asking you to check out this here: https://rnfirebase.io/reference/messaging#setAPNSToken meaning you will need to use the setAPNSToken method which likely means Firebase does not automatically pick up the APNS token on iOS as this is a method you specifically use for iOS. Please let me know how this goes. 😄 |
I also tried sending a test push using the Apple Push Notifications console with the obtained device token, and it was successfully delivered - I can see it on the device. |
Nice one @stalteri , does this mean your issue is resolved or are you still experiencing other issues? |
No, I still can’t get an FCM token with messaging.getToken(). Despite the APNS token being present and fully functional, I still see the following message in the Xcode logs:
Also, as I mentioned above, I cannot set the APNS token using the messaging.setAPNSToken(token) method. |
Ok, thank you for the information I will keep investigating this. 👍 |
Seeing that message "no default app initialized" makes me think something is wrong in your basic react-native-firebase integration, and you need to solve that first. Are you certain you have followed the setup guidelines and you have altered AppDelegate.swift to import Firebase and call Firebase.configure()? Are you certain you have the GoogleServices-Info.plist file in your project tree and also - via Xcode - actually added to your project files? |
Using an example app I was able to grab the token, so I do also think it is a configuration issue on your end. I had mine configured as such:
For testing purposes I used a useEffect to grab it which I would not recommend anyways. But it was a quick way to do it on startup. |
Forgot to mention I also did not use setToken within aswell. |
The setAPNSToken method really only exists for test and debugging purposes, I can't think of many valid use cases in a correctly configured app where it should be used, for what it's worth. I only added it at the time in order to test FCM methods on the Simulator, when Apple just introduced APNS capabilities to the Simulator. It allowed me to test the new capabilities even on x86-64 Simulators, despite the APNS features only working on Apple Silicon Simulators. It is still useful for that, and maaaayyybe someone else has a valid use case for it, but I don't expect setAPNSToken to ever be used in a normal, well-configured project. |
I'm not trying to use setAPNSToken in my project; if you look carefully at the previous messages, you'll see that I was simply checking your colleague's suggestion to use that method. |
I understand there's a 99% chance the issue lies with my project's configuration, but I've checked all the settings many times and they match the documentation. That's why I posted here and provided all my configuration files in the hope that someone will spot the error or has encountered this issue before. |
Unfortunately - as long as you see that "no default project configured" error message, I don't think it's going to work. And it is a project configuration error. But with the information you've provided I just can't spot the error. You might try checking out the iOS app-related script steps (detailed with comments) in my build demonstrator which generates a correctly configured project: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh - that script does all the things you need to do, and I read of it may help identify what's missing in your project |
Could the use of |
@stalteri our documentation is crystal clear on this subject: But you must link static. |
hi @mikehardy Here’s a summary of what I’ve done:
|
Not sure what's going on as I don't reproduce this personally, but do you have an entitlements file as part of your iOS project? Should be |
Yes i have it
|
@mikehardy, your comment in another issue confused me, and I thought that both static and dynamic linking could be used :) ![]() |
Issue resolved by switching to |
hi @stalteri how so are you getting device token without setAPNSToken? and able to receive the notification? your would be appreciated |
@stalteri thanks for pointing out that comment! Indeed I was incorrect there - perhaps typing too fast or something - but dynamic is exactly wrong 🤦 - I edited that comment so no one else would be led into the trap. Happy to hear you resolved your issue |
@stalteri could please review above |
can you share your Podfile? |
Here my podfile |
Setting FirebaseAppDelegateProxyEnabled => true in Info.plist solved my issue, but I didn't find this mentioned in the official documentation: RN Firebase Messaging Usage. @mikehardy, I really appreciate your contributions across so many libraries! If you think it's relevant, please consider updating the documentation to include this ProxyEnabled setting. |
Issue
When calling messaging.getAPNSToken(), it returns null even though the APNS token is correctly received in didRegisterForRemoteNotificationsWithDeviceToken (verified by logging a device token with a byte length of 32). Consequently, calling messaging.getToken() halts execution and never returns an FCM token. Notifications permission is granted.
Have this message in xcode logs:

-[RNFBMessagingModule getToken::::] [Line 134] RNFBMessaging getToken - no APNS token is available. Firebase requires an APNS token to vend an FCM token in firebase-ios-sdk 10.4.0 and higher. See documentation on setAPNSToken and getAPNSToken.
Background Modes and Push Notifications are enabled in xcode:

All settings enabled in AppStoreConnect, APNS key created and uploaded to Firebase Console.
Also have this warning multiple times:

Project Files
Javascript
Click To Expand
executionFile.ts
:package.json
:firebase.json
for react-native-firebase v6:iOS
Click To Expand
ios/Podfile
:AppDelegate.m
: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
react-native info
output:react-native-firebase
version you're using that has this issue:21.12.3
Firebase
module(s) you're using that has the issue:messaging
TypeScript
?Y
&5.0.4
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: