iOS: OnTokenRefresh will NEVER fire if autoRegistration=false
See original GitHub issueHi there,
great plugin, thanks.
Quick question.
I assume that OnTokenRefresh Event:
CrossFirebasePushNotification.Current.OnTokenRefresh += (s,p) => { System.Diagnostics.Debug.WriteLine($"TOKEN : {p.Token}"); };
Is only called when the token gets refreshed and NOT when the app is launched / token is initially generated?
Would the correct method be to check for and save the initial token on app launch using
CrossFirebasePushNotification.Current.Token
In the RegisteredForRemoteNotifications
override of AppDeligate on iOS?
Thanks
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
flutter - Why is onTokenRefresh not firing?
According to the flutter firebase_messaging package docs, onTokenRefresh is fired when a new FCM token is generated. And according to Google's ...
Read more >FirebasePushNotification plugin iOS - token not refreshing
I am using the FirebasePushNotification plugin, and in iOS i have always issues. In debug mode it works ok, but in release it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @rdelrosario - I’ve done some further investigation, and have found the issue.
Using plugin 3.1.6 on iOS 13.4 does NOT call OnTokenRefresh if the plugin is initialised as:
FirebasePushNotificationManager.Initialize(options, autoRegistration: false);
Even if at a later date you callCrossFirebasePushNotification.Current.RegisterForPushNotifications();
-OnTokenRefresh
will still never be invoked.However if you initialise the plug in as:
FirebasePushNotificationManager.Initialize(options);
The whole plugin works as expected on iOS and
OnTokenRefresh
is called as expected.So the bug is with the
autoRegistration
argument on iOS being set to false.Hope this helps.
So on further investigation, it appears that
OnTokenRefresh
event is called on Android after initially registering for notifications, but is NOT called on iOS after initially registering for notifications.Therefore I am assuming that on iOS the correct procedure is to update the token to the remote server in
RegisteredForRemoteNotifications
andOnTokenRefresh
Would be greatful is someone else could confirm this behaviour? Thanks