firebase-ios-sdk
firebase-ios-sdk copied to clipboard
Cloud Messaging no FCM token being created
Description
When I deploy my app to the App Store or TestFlight I no longer get any FCM tokens, works perfectly when running on connected device from within Xcode. Also no issue with Android version of my app, works ok in development and from the released app in Play Store.
Reproducing the issue
The App delegate:
final class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
FirebaseApp.configure()
Messaging.messaging().delegate = self
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { granted, error in
if let error = error {
print("Error requesting notification authorization: \(error)")
} else if granted {
print("Notification authorization granted")
} else {
print("Notification authorization denied")
}
}
application.registerForRemoteNotifications()
return true
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Failed to register for remote notifications with error: \(error)")
}
}
This following code is never fired when the app is from the App Store or TestFlight, in the full code I save the token so can be used in other parts of the app:
extension AppDelegate: MessagingDelegate { @objc func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { guard let token = fcmToken else { return }
}
}
Firebase SDK Version
10.23.0
Xcode Version
15.3 (15E204a)
Installation Method
Swift Package Manager
Firebase Product(s)
Messaging
Targeted Platforms
iOS, macOS
Relevant Log Output
No response
If using Swift Package Manager, the project's Package.resolved
Expand Package.resolved
snippet
Replace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand Podfile.lock
snippet
Replace this line with the contents of your Podfile.lock!
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Thanks for reporting, @ian-sayles. Could you confirm if you've set the APS Environment key to production instead of sandbox/development in the Entitlements file?
Thanks @rizafran I checked by entitlement file and it was set for development, edited the file and changed it production, submitted new app and tried it in TestFlight with same issue, I also checked the entitlement file to make sure Xcode had not changed it back, and it was still set for production.
Thanks for the update, @ian-sayles. May I know if you have uploaded your production APNs certificate to the Firebase console?
Thanks @rizafran I have used the APNs Authentication Key not the APN certificate, do you have to use the certificate or should it work with just the authentication key?
@ian-sayles, you can use either the APNs authentication key or APNs certificate.
Hey @ian-sayles. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@ian-sayles if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.