Firebase-ios-sdk: didReceiveRegistrationToken not called on first app run

Created on 25 Sep 2019  路  16Comments  路  Source: firebase/firebase-ios-sdk

Describe your environment

  • Xcode version: 11.0 (11A420a)
  • Firebase SDK version: 6.8.1
  • Firebase Component: Messaging
  • Component version: 4.1.4

[REQUIRED] Step 3: Describe the problem

The MessaginDelegate function messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) is not called on the first run a fresh installed build. I've also confirmed this is happening in Firebase SDK version 6.9.0.

This was working fine on Firebase SDK version 6.2.0/FirebaseMessaging version 4.0.2 but recently updated to 6.8.1/4.1.4.

instanceid messaging

Most helpful comment

i am also facing same issue, on first launch of app not getting fcm token

All 16 comments

Is this reproducible in a sample project like the Messaging quickstart?

Another piece of valuable information: does this happen on iOS 13 only, or older devices as well?

@morganchen12 After modifying the linked sample project to replicate the conditions in our app (we disable swizzling) I was not able to reproduce the issue there. But I was still able to reproduce it in our app after completely stripping it down to just setting up push notifications. I also noticed some relevant console messages from that:

2019-09-26 10:53:11.855378-0500 Tasty[7040:1958829] 6.8.1 - [Firebase/InstanceID][I-IID003009] Failed to fetch default token Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://device-provisioning.googleapis.com/checkin, NSLocalizedDescription=cancelled, NSErrorFailingURLKey=https://device-provisioning.googleapis.com/checkin}

2019-09-26 10:53:11.855877-0500 Tasty[7040:1958829] 6.8.1 - [Firebase/InstanceID][I-IID003007] Failed to retrieve the default FCM token after 0 retries

@ryanwilson I've also been able to reproduce this on iOS 12.4.1/Xcode 10.3 and our QA team reproduced it on iOS 12.1

Can you share your stripped-down project? I'll try to repro and identify the root cause.

@morganchen12 I have a stripped down project where the issue is reproducible. Would it be possible to get an email to send it to? Also would it be acceptable not to include the GoogleService-Info.plist file as that contains sensitive information?

i am also facing same issue, on first launch of app not getting fcm token

I am also facing the same issue. Any work arounds @venkimurthy07 @willk37 @morganchen12 ???

Yes, that would be fine. You can send it to morganchen at google, or if it contains no sensitive information, you can just upload it in a git repo.

@willk37 I've been able to reproduce the issue with the sample you provided, but am getting these errors in console:

2019-10-01 10:49:40.636945-0700 SampleApp[1622:398226] 6.8.1 - [Firebase/InstanceID][I-IID003009] Failed to fetch default token Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://device-provisioning.googleapis.com/checkin, NSLocalizedDescription=cancelled, NSErrorFailingURLKey=https://device-provisioning.googleapis.com/checkin}
2019-10-01 10:49:40.637352-0700 SampleApp[1622:398226] 6.8.1 - [Firebase/InstanceID][I-IID003007] Failed to retrieve the default FCM token after 0 retries
2019-10-01 10:49:40.637829-0700 SampleApp[1622:398246] 6.8.1 - [Firebase/Analytics][I-ACS025026] Deferring to Firebase for event data collection
2019-10-01 10:49:40.713938-0700 SampleApp[1622:398238] [] tcp_input [C5.1:3] flags=[R] seq=2172968099, ack=0, win=0 state=CLOSED rcv_nxt=2172968099, snd_una=315792937
2019-10-01 10:49:42.658353-0700 SampleApp[1622:398237] 6.8.1 - [Firebase/InstanceID][I-IID007007] Inconsistent state: NSURLSession has been invalidated
2019-10-01 10:49:46.660046-0700 SampleApp[1622:398246] 6.8.1 - [Firebase/InstanceID][I-IID007007] Inconsistent state: NSURLSession has been invalidated
2019-10-01 10:49:54.661338-0700 SampleApp[1622:398374] 6.8.1 - [Firebase/InstanceID][I-IID007007] Inconsistent state: NSURLSession has been invalidated
2019-10-01 10:50:11.158362-0700 SampleApp[1622:398377] 6.8.1 - [Firebase/InstanceID][I-IID007007] Inconsistent state: NSURLSession has been invalidated

Are you getting the same errors?

@morganchen12 Yes, these look like the same errors I am receiving in the SampleApp example and in our prod app.

Looks like there's some weird lifecycle stuff going on in InstanceID/Messaging. Continuing to investigate.

3984 likely addresses this issue.

@morganchen12 or @willk37 : Would you try patching in #3984 to confirm that it fixes this?

I've been unable to reproduce this bug with the new patch.

@willk37 feel free to comment here if this is still an issue, and thanks for reporting!

Sorry for the delay but I just updated to 6.10.0 and it looks like the issue is fixed for me as well. Thanks for the help!

Was this page helpful?
0 / 5 - 0 ratings