I'm using Distriqt Push Notifications Extension and I can't get it working correctly if the user does not allow PNs on first run: the application ends registering the user because it states that PNs are enabled and available.
I do the following:
if (PushNotifications.isSupported()) {
registerPushNotifications();
}
private function registerPushNotifications():void {
PushNotifications.service.addEventListener(PushNotificationEvent.REGISTER_SUCCESS, onPushNotificationToken);
PushNotifications.service.register(MODEL.Configuration.GCM_SENDER_ID);
}
private function onPushNotificationToken(event:PushNotificationEvent):void {
if (PushNotifications.service.isEnabled) { registerDevice(); }
}
Does not PushNotifications.service.isEnabled
supposed to be false if the user disallows it? When does it become false? How am I supposed to handle this case scenario?
I've found what was happening in my application:
I'm handling activate/deactivate events to enable and disable background execution:
NativeApplication.nativeApplication.executeInBackground = true;
. This makes your application able to run on background, ignoring the UI which asks for user permission and it happens thatPushNotifications.service.isEnabled
istrue
on first run after installation.What I've done is delaying adding activation and deactivation listeners till one of this things happen first:
PushNotifications.isEnabled == false
I hope this helps someone.