Open finalspace opened 5 years ago
there's no callback from permission prompt, so I use NotificationManager.DeviceNotificationsAllowed() inside Update() to retrieve the status.
Hi @finalspace ,
May I clarify a few things regarding that issue?
NotificationManager.DeviceNotificationsAllowed()
in UTNotifications. Are you speaking about UTNotifications.Manager.Instance.NotificationsAllowed()
or in fact it's something completely else I've no idea about?NotificationsAllowed
and not NotificationsEnabled
?Best regards, Yuriy, Universal Tools team.
Hi @yuriy-universal-ivanov thanks for the response. I pasted the method of the wrapper. the wrapper does nothing but simply call UTNotifications.Manager.Instance.NotificationsAllowed(). Sorry for that.
I trigger the permission prompt by executing the following methods:
UTNotifications.Manager.Instance.Initialize(false); UTNotifications.Manager.Instance.SetNotificationsEnabled(true); UTNotifications.Manager.Instance.SetPushNotificationsEnabled(true);
when user denies the permission, UTNotifications.Manager.Instance.NotificationsAllowed() gives me TRUE in MonoBehaviour.Update()
the workaround that I figured out is that I need to reset the status of the manager by calling
UTNotifications.Manager.Instance.SetNotificationsEnabled(false); UTNotifications.Manager.Instance.SetPushNotificationsEnabled(false);
in the next frame.
after this, UTNotifications.Manager.Instance.NotificationsAllowed() gives me the correct value.
in case user allows the permission, I tried re-enable notification by doing
if (UTNotifications.Manager.Instance.NotificationsAllowed()) { UTNotifications.Manager.Instance.SetNotificationsEnabled(true); UTNotifications.Manager.Instance.SetPushNotificationsEnabled(true); }
in the next frame
so basically the bug I found is that I need to call
UTNotifications.Manager.Instance.SetNotificationsEnabled(false); UTNotifications.Manager.Instance.SetPushNotificationsEnabled(false);
after the promt to have UTNotifications.Manager.Instance.NotificationsAllowed() work correctly.
Is it because the way I use that cause this problem? I'm using Unity 2017.4.10f1 UTNotification 1.7.3 Xcode 9.2 (for local build)
Hi @finalspace ,
I tried and couldn't reproduce your issue. It works absolutely as expected for me:
NotificationsAllowed
returns false
before Initialize is called or before the permission dialog is closedtrue
if you chose to allow in the dialogfalse
if you chose to not allow in the dialog.The same thing: the check is in Update()
, having
UTNotifications.Manager.Instance.SetNotificationsEnabled(true); UTNotifications.Manager.Instance.SetPushNotificationsEnabled(true);
after the initialization doesn't matter (I tried adding it and not adding it, it doesn't change the behaviour anyhow).
Could you maybe post here your complete script which reproduces the issue? Please also tell me the version of iOS on the device you're running it.
Best regards, Yuriy, Universal Tools team.
I have this use case (iOS): 1) start app
2) trigger local notification permission prompt in app, and choose "deny" 3) NotificationManager.DeviceNotificationsAllowed() returns TRUE (expecting FALSE) 4) close app, check system settings, notification is disabled 5) restart app, NotificationManager.DeviceNotificationsAllowed() returns TRUE (expecting FALSE)
6) turn off notifications by calling UTNotifications.Manager.SetNotificationsEnabled(false); UTNotifications.Manager.SetPushNotificationsEnabled(false); this time NotificationManager.DeviceNotificationsAllowed() returns false correctly
more info: with notification enabled in app. close app, turn off notification in system settings. restart app, NotificationManager.DeviceNotificationsAllowed() returns FALSE as expected