You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accessing the fcm token via Messaging.messaging().fcmToken at first app start after update to sdk version 10.19.0 is nil and does not return the previous fcm token immediately. Only after the messaging:didReceiveRegistrationToken: delegate callback the fcm token is available again.
The reason for this seems to be the change to NSSecureCoding for the internal classes which was done in this sdk version. #12075#12110
Maybe it is related to the parsing changes in FIRMessagingTokenInfo.m which do not seem to be backwards compatible when decoding the previous value in the first session after the update (resulting in the nil return, see diff).
The FCM registration token is sometimes refreshed automatically. In your Messaging delegate, the delegate method messaging(_:didReceiveRegistrationToken:) will be called once a token is available, or has been refreshed. Typically it should be called once per app start, but may be called more often if the token is invalidated or updated.
Token invalidation/update is not the case, since the app installation did not change and the fcm token stays the same.
So accessing the fcm token via Messaging.messaging().fcmToken should be immediately available and return the current fcm token. This should not be impacted and change behavior by updating the sdk version.
To clarify, this is change in behavior is only happening in the first session with this sdk version, in subsequent sessions it is immediately available again. In previous sdk updates the fcm token was immediately available also in the first session.
Reproducing the issue
Steps to reproduce
Create a sample app and configure Firebase Cloud Messaging
Access the fcm token at app start. E.g. print(Messaging.messaging().fcmToken) in application(_:didFinishLaunchingWithOptions:)
Make sure to use a previous sdk version first and run the app to enable/configure notifications (e.g. version 10.17.0)
Update the sdk version to version 10.18.0 or lower
Restart the app -> this prints the current fcm token ✅
Update the sdk version to 10.19.0 or higher
Restart the app -> the printed fcm token is nil ❌
Firebase SDK Version
10.19
Xcode Version
15
Installation Method
Swift Package Manager
Firebase Product(s)
Messaging
Targeted Platforms
iOS
Relevant Log Output
No response
If using Swift Package Manager, the project's Package.resolved
Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
The text was updated successfully, but these errors were encountered:
Description
Actual behavior
Accessing the fcm token via
Messaging.messaging().fcmToken
at first app start after update to sdk version10.19.0
is nil and does not return the previous fcm token immediately. Only after themessaging:didReceiveRegistrationToken:
delegate callback the fcm token is available again.The reason for this seems to be the change to
NSSecureCoding
for the internal classes which was done in this sdk version. #12075 #12110Maybe it is related to the parsing changes in
FIRMessagingTokenInfo.m
which do not seem to be backwards compatible when decoding the previous value in the first session after the update (resulting in the nil return, see diff).Expected behavior
From the docs:
Token invalidation/update is not the case, since the app installation did not change and the fcm token stays the same.
So accessing the fcm token via
Messaging.messaging().fcmToken
should be immediately available and return the current fcm token. This should not be impacted and change behavior by updating the sdk version.To clarify, this is change in behavior is only happening in the first session with this sdk version, in subsequent sessions it is immediately available again. In previous sdk updates the fcm token was immediately available also in the first session.
Reproducing the issue
Steps to reproduce
print(Messaging.messaging().fcmToken)
inapplication(_:didFinishLaunchingWithOptions:)
10.17.0
)10.18.0
or lower10.19.0
or higherFirebase SDK Version
10.19
Xcode Version
15
Installation Method
Swift Package Manager
Firebase Product(s)
Messaging
Targeted Platforms
iOS
Relevant Log Output
No response
If using Swift Package Manager, the project's Package.resolved
Expand
Package.resolved
snippetReplace this line with the contents of your Package.resolved.
If using CocoaPods, the project's Podfile.lock
Expand
Podfile.lock
snippetReplace this line with the contents of your Podfile.lock!
The text was updated successfully, but these errors were encountered: