func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) is not called until the app is restarted. Only happens when importing FirebasePerformance into the project.
In the AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
FirebaseApp.configure()
Messaging.messaging().delegate = self
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
application.registerForRemoteNotifications()
return true
}
In Podfile
pod 'Firebase/Messaging'
pod 'Firebase/Performance'
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) Is not called in the first app start.
By removing pod 'Firebase/Performance' form the Podifile, the problem is gone.
When the problem occurs some error are logged like:
Task <14CEA9FB-0EEA-43EF-8AAE-C21EE06EA1FF>.<1> HTTP load failed, 0/0 bytes (error code: -999 [1:89])
6.8.1 - [Firebase/InstanceID][I-IID003009] Failed to fetch default token Error Domain=NSURLErrorDomain Code=-999
6.8.1 - [Firebase/InstanceID][I-IID007007] Inconsistent state: NSURLSession has been invalidated
@da-mian Are you running this on simulator or real devices?
I can reproduce on simulator only and with messaging and perf in the pod at the same time.
I’m running on real device.
On Fri 20. Sep 2019 at 23:40, Chen Liang notifications@github.com wrote:
I can reproduce on simulator only and with messaging and perf in the pod
at the same time.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-ios-sdk/issues/3891?email_source=notifications&email_token=AADM577YGDR5JOZYRFFA2CTQKU7NZA5CNFSM4IYVR7B2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7H6GGQ#issuecomment-533717786,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADM573OWD7H7YNS7LINN5DQKU7NZANCNFSM4IYVR7BQ
.
This is because of the issue where Firebase Performance intercepts the network request made by Messaging and we are able to reproduce this successfully. We are working on a fix for this. Will update shortly on this thread.
Any updates on this topic?
@GoranLilja We made some changes to Fireperf in the recent version (6.10.0). Can you check if the issue still happening? Ideally this issue should not be reproducible now.
We verified this issue with 6.10.0 version of Firebase release and this is not reproducible. So closing the issue. Please re-open if you still find this issue.
Most helpful comment
This is because of the issue where Firebase Performance intercepts the network request made by Messaging and we are able to reproduce this successfully. We are working on a fix for this. Will update shortly on this thread.