1

I created a mobile app using Ionic and Cordova.

But, I got an issue with the cordova PushPlugin

When I manually deactivate Push on my Iphone 4s (ios 8.4) in app settings, the PushPlugin register function does nothing (no success, no errors, nothing ^^) The plugin works well when I reactivate them manually

I read a lot of answer about issue with IOS8 : How to update code using enabledRemoteNotificationTypes because it is "not supported in iOS 8"?

I tried 3/4 repo from the community and also the Telerik plugin. But same issue, nothing happens when Pushs are not enabled.

What I want :

  • at least an error in the error callback when not enabled
  • or better, handle it like cordova camera : when I disable photos manually, a popup opens saying to activate it

Like Objective C is a language totally unknown for me, any help would be appreciated

Thanks

Community
  • 1
  • 1
JeromeModi
  • 117
  • 1
  • 7

1 Answers1

2

You can check the current push status on applicationDidBecomeActive (on your appDelegate.m)

- (void)applicationDidBecomeActive:(UIApplication *)application
{

        if ([[UIApplication sharedApplication]  respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {
            if ([[UIApplication sharedApplication]  isRegisteredForRemoteNotifications]){
                NSLog(@"iOS 8, notifications enabled");
            } else {
                NSLog(@"iOS 8, notifications not enabled");
            }
        } else {
            UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
            if (types & UIRemoteNotificationTypeAlert)
            {
                NSLog(@"Notifications Enabled");
            }
            else
            {
                NSLog(@"Notifications not enabled");
            }
        }

}

You can also put that code into a plugin and listen for the applicationDidBecomeActive notification

Anyway, you should open issues on the plugins you tried, they should call the fail callback it the push are not enabled

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • This is logging fine ! Thanks, I will try to use it to throw an error They don't use 'isRegisteredForRemoteNotifications' in the plugin I don't know if there is a way to open phone settings (I think it's a bit more complicated) I will post on the plugin page, thanks – JeromeModi Jul 22 '15 at 12:35
  • On iOS 8 you can open you the phone settings for your app – jcesarmobile Jul 22 '15 at 12:40