FirebasePushNotificationPlugin icon indicating copy to clipboard operation
FirebasePushNotificationPlugin copied to clipboard

Manual registration does not work (no messages retrieved) - iOS

Open jochencschmidt opened this issue 4 years ago • 2 comments

Bug Information

This applies to iOS in a Xamarin.forms project. Registration does not work if done manually by calling CrossFirebasePushNotification.Current.RegisterForPushNotifications(); This affects scenarios where the registration is done on demand after the startup.

This works:

  • Call FirebasePushNotificationManager.Initialize(options, false); in AppDelegate.cs
  • Call CrossFirebasePushNotification.Current.RegisterForPushNotifications(); in App.OnStart()
  • Then calling CrossFirebasePushNotification.Current.Subscribe() somewhere else does result in a working subscription.

This does not work:

  • Call FirebasePushNotificationManager.Initialize(options, false); in AppDelegate.cs
  • Call CrossFirebasePushNotification.Current.RegisterForPushNotifications(); in a Command tied to a button.
  • Then calling CrossFirebasePushNotification.Current.Subscribe() somewhere else does not result in a working subscription. Still, there is no error during the procedure and the token is actually retrieved but the subscription just does not work.

Version Number of Plugin: 3.3.16-beta Device Tested On: iPhone 8 running iOS 14.4 Simulator Tested On: n/a Version of VS: Microsoft Visual Studio Professional 2019, Version 16.9.0 Version of Xamarin: 4.5.0.725 (did also not work with 5.0.0.2012) Versions of other things you are using: n/a

Steps to reproduce the Behavior

see above

Expected Behavior

Subscription should work in both cases.

Actual Behavior

see above

Code snippet

see above

Screenshots

n/a

jochencschmidt avatar Mar 19 '21 10:03 jochencschmidt

We are also having this same issue. The only work around we as the OP has stated is to initiate the registration on App.OnStart, but that makes for terrible UX. We want to the PN dialog to be user driven and explain why our app is asking for Push Notification requests prior to just having the device prompt show up. Once the user declines, its very difficult for them to allow notifications.

jmemaxwell avatar May 21 '21 16:05 jmemaxwell

@jochencschmidt @jmemaxwell Try first unregister, then call the register method, see if that helps.

In my case I wanted to do OnDemand registrations (i.e. after showing a dialog explaining to the user about the benefits of enabling push notification and getting his consent). The only ways this has worked on iOS is by called unregister, then register.

darrabam avatar Jun 19 '21 13:06 darrabam