firebase-ios-sdk: FCM Token not updating latest iOS13.5 and Xcode 11.5
Hi Team,
Firebase suddenly stop updating the fcm token. It’s always giving a same token, Even i uninstall the app and check it on several times, but it’s always giving the same token. My two iOS apps was working properly but last 1 weeks it’s giving the issue. When i am trying to send notification on that token its saying that “NotRegistered” Response
{“multicast_id”:1896555360655138060,“success”:0,“failure”:1,“canonical_ids”:0,“results”:[{“error”:“NotRegistered”}]}.
Step 0: Are you in the right place?
- For issues or feature requests related to the code in this repository
file a Github issue.
- If this is a feature request please use the Feature Request template.
- For general technical questions, post a question on StackOverflow
with the
firebasetag. - For general (non-iOS) Firebase discussion, use the firebase-talk google group.
- For backend issues, console issues, and other non-SDK help that does not fall under one of the above categories, reach out to Firebase Support.
- Once you’ve read this section and determined that your issue is appropriate for this repository, please delete this section.
[REQUIRED] Step 1: Describe your environment
- Xcode version: 11.5
- Swift Version 5.2 with iOS 13.5
- Firebase SDK version: latest version
- Firebase Component: Messaging (Auth, Core, Database, Firestore, Messaging, Storage, etc)
- Component version: latest version
- Installation method: CocoaPods
CocoaPods | Carthage | Zip file(select one)
[REQUIRED] Step 2: Describe the problem
Install the app and allow the notification you will get the token. Now save that token in
some where else and uninstall the app in device and again install the same app. You will get
the exact same token as you install app on first time. And you try to send notification on that
token api give below response. I have done the install and uninstall several times but same
token coming always.
{"multicast_id":1896555360655138060,"success":0,"failure":1,"canonical_ids":0,"results":
[{"error":"NotRegistered"}]}.
Steps to reproduce:
What happened? How can we make the problem occur? This could be a description, log/console output, etc.
If you have a downloadable sample project that reproduces the bug you’re reporting, you will likely receive a faster response on your issue.
########## Create the new project Xcode11.5 download the fcm sample code and integrate the same in newly created app. Install the app in device. You will get the token, now uninstall the app and install again you will get the same token again. now use that token to send notification it will gives a error.
Relevant Code:
// TODO(you): code here to reproduce the problem
// Added this on didFinishLaunchingWithOptions function
Messaging.messaging().delegate = self
Messaging.messaging().shouldEstablishDirectChannel = false
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {
(granted, error) in
//Parse errors and track state
debugPrint("notification=\(granted)")
DispatchQueue.main.async {
if granted {
debugPrint("granted")
}
}
}
application.registerForRemoteNotifications()
//FCM Delegate method
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
print("Firebase registration token: \(fcmToken)")
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (10 by maintainers)
@maksymmalyhin Thanks for your suggestion. Now its working as expected. I removed
instance.deleteID {...}this in app now the same token is coming on every app restart.Let test it few days more if this work we will close this. If any bug we will continue the discussion here.
@vinod1988 It’s great you found it.
instance.deleteID {...}is the method that triggers FCM token deletion. If you remove it, FCM token should stay the same between app launches. Could you please remove the callinstance.deleteID {...}and test again? Please let us know the results.@maksymmalyhin thanks for reply
But this is bug. Let me know when this resolved.
I will try to add your suggested points and let me know. and will share you the debugLog same as well.
@chliangGoogle I am not aware of a valid case when the client can get the same FID/token even after app uninstall, if it does, it’s a bug.
FID, FIS token and FCM token are stored in the keychain which preserves the data between app installations, but FID and FIS stored in the keychain are ignored if there is no are a corresponding flag in User Defaults (see the logic here). The User Defaults are supposed to be deleted with the app which means that after the app uninstall and reinstall a new FID and FIS token should be generated that will replace old ones.
FCM token stored in keychain should be updated after uninstall based on the updated FID (implemented in #4096)
@vinod1988 To help us narrow down the scope of the issue could you please check the following things:
IIDvariable from at this line. If it matches the prefix of the Firebase Messaging token?