firebase-ios-sdk: Every time after app update cannot receive FCM token after first run only

  • Xcode version: 10.2.1
  • Firebase SDK version: 5.20
  • Firebase Component: Messaging
  • Component version: umm, it’s a binary from iOS SDK 5.20

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

I call [FIRApp configure]; in application didFinishLaunchingWithOptions. Then, when when user goes to in-app settings, (s)he wants to enable or disable remote notifications for my app. I need FCM token to send it to server and check. I use

[[FIRInstanceID instanceID] instanceIDWithHandler:^(FIRInstanceIDResult* _Nullable result, NSError * _Nullable error) {
			if (error != nil) {
				//NSLog(@"Error fetching remote instance ID: %@", error);
				token = "error";
			} else {
				//NSLog(@"Remote instance ID token: %@", result.token);
				token = [result.token cStringUsingEncoding:NSUTF8StringEncoding];
			}
			gettokenstarted = false;
		}];

and return token.c_str();. It works fine… Well it actually fails… only every time… after user gets an update for my app. User installs an update and runs app, then instanceIDWithHandler called but somehow it’s callback doesn’t called, neither error nor token are returned. Workaround is close app and run it again. From second run it works, but on next update it happens again… It’s PITA. Please tell me if You have some workaround, or how long do I need to wait until it fixed? I have it for 3 months already since I migrated to FCM. Android version works fine, but on iOS some strange things happening here.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22 (6 by maintainers)

Most upvoted comments

You should be handling token refreshes via the FIRMessagingDelegate protocol instead of manually fetching a new instance ID on every app launch. This method will be called whenever the token is refreshed.

I updated to Firebase SDK 6.2.0 and tried again. 6.1.0 works better(thought it fixed but still can reproduce in 20-30% cases on first run) than 5.2.0(my issue occurs in almost 100% cases on first run), and 6.2.0 seems to be even better (reproduced 0 times, but need a few days to confirm). I hope it fixed by SDK update 6.2.0, but still need a time to check it good enough to close ticket.