I am having issues with the (un)register functions for mobile notifications.
To activate notifications I use this code:
if not NotificationCenter.RegisteredForRemoteNotifications() then
NotificationCenter.RequestAuthorization(MobileNotifications.AuthorizationOptions.Badge, MobileNotifications.AuthorizationOptions.Sound, MobileNotifications.AuthorizationOptions.Alert)
NotificationCenter.RegisterForRemoteNotifications()
end if
And if the user no longer wants notifications I execute this code:
if NotificationCenter.RegisteredForRemoteNotifications() then
NotificationCenter.UnregisterForRemoteNotifications()
end if
Registering for notifications initially works ( get a token through the RemoteRegistrationSucceeded() event ). When the user unregisters for notifications it does call NotificationCenter.UnregisterForRemoteNotifications() ( I have checked by putting a messagebox right before it)
But NotificationCenter.RegisteredForRemoteNotifications() always stays true. So it will never reregister for notifications and notificatsion also keep working so it looks like NotificationCenter.UnregisterForRemoteNotifications() just doesn’t work.
I’m not sure what the boolean property is for?
I’m doing manually:
Starting from a new application the first time registration works. After receiving the token I manually click a button to execute the UnregisterForRemoteNotifications() method.
Even after killing and restarting the app now NotificationCenter.RegisteredForRemoteNotifications() stays true for ever. It seems to never unregister?
You should call this method in rare circumstances only, such as when a new version of the app removes support for all types of remote notifications. Users can temporarily prevent apps from receiving remote notifications through the Notifications section of the Settings app. Apps unregistered through this method can always re-register.
Could be a Xojo bug. Nonetheless, do you really need the trouble of adding an unregister button?
Users can disable notifications directly from the settings app and are used to doing it that way.