In-house I am implementing Firebase's fcmToken and sending a push notification.
But firebase 's fcmToken can not be acquired at all, and delegate has never been called.
I investigated it with the same verison as this is a firebase bug or my own project is wrong.
The project created by me can get fcmToken and delegate called.
I'm Very Warried...
If you like, please let me know where the cause for this is involved.
Can you share the project that's unable to fetch the fcmToken?
I don't know why but some days before, firebase was working normal in my project but today it's not working =((((
@morganchen12 We can not be shared because of the company's products.
@TuanFram I see. Can you share that project?
Can you share your implementation of FIRMessagingDelegate?
i am having the same issue where the didReceiveRegistrationToken delegate function all of a sudden isn't firing anymore...it was just working the other day where i'd see the fcmToken
@ccynn Can it be reproduced by creating a new project?
i just reproduced it and weird...with the new project the didReceiveRegistrationToken does get triggered.
what's the best mode of action here? @omatty198
Closing this issue since there's not enough information for me to debug. Please feel free to continue commenting here, and if someone shares a reproducible example, I'll re-open the issue.
I was struggling with this issue too. Steps to reproduce from my app:
FirebaseApp.configure()Messaging.messaging().delegate = selfUIApplication.shared.registerForRemoteNotifications() - system alert view should appear; tap acceptMessaging.messaging().apnsToken = dataResult: InstanceID.instanceID().token() is nil and nothing from MessagingDelegate is called
However, there is simple workaround for this - looks like you have to set the messaging delegate (Messaging.messaging().delegate = ...) before FirebaseApp.configure()
@morganchen12
As I understand didReceiveRegistrationToken method simply doesn't exist at all.
So it seems everything is correct except of the documentation:
https://firebase.google.com/docs/cloud-messaging/ios/client
Fix the documentation please
I fixed it. I think I was wrong when I put in the end
FirebaseApp.configure()
Messaging.messaging().delegate = self
And I fixed it as screenshoot below:

I fixed it. I think I was wrong when I put in the end
FirebaseApp.configure()
Messaging.messaging().delegate = self
And I fixed it as screenshoot below:
This solved the issue for me. But I can't figure out why this started happening. It was working fine previously.
shoaibnomani, thank you man - you saved my day
shoaibnomani, thank you man - you saved my day
It was in fact the solution by @kilirushi if you look above in the thread. It saved me a lot of time as well.
I fixed it. I think I was wrong when I put in the end
FirebaseApp.configure()
Messaging.messaging().delegate = self
And I fixed it as screenshoot below:
This solved the issue for me. But I can't figure out why this started happening. It was working fine previously.
I think this makes sense you are trying to set up the delegate while firebase engine is not yet ready.
Firebase need to take some second to connect with server. so i gave 5 second delay.
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(5000)) {
InstanceID.instanceID().instanceID { (result, error) in
// Get called
if let error = error {
print("Error fetching remote instance ID: \(error)")
} else if let result = result {
print("Remote instance ID token: \(result.token)")
//self.instanceIDTokenMessage.text = "Remote InstanceID token: \(result.token)"
}}
}
Most helpful comment
I was struggling with this issue too. Steps to reproduce from my app:
FirebaseApp.configure()Messaging.messaging().delegate = selfUIApplication.shared.registerForRemoteNotifications()- system alert view should appear; tap acceptMessaging.messaging().apnsToken = dataResult:
InstanceID.instanceID().token()is nil and nothing fromMessagingDelegateis calledHowever, there is simple workaround for this - looks like you have to set the messaging delegate (
Messaging.messaging().delegate = ...) beforeFirebaseApp.configure()