question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS: OnTokenRefresh will NEVER fire if autoRegistration=false

See original GitHub issue

Hi 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:open
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Lydeckercommented, Apr 12, 2020

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 call CrossFirebasePushNotification.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.

1reaction
Lydeckercommented, Apr 11, 2020

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 and OnTokenRefresh

Would be greatful is someone else could confirm this behaviour? Thanks

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found