Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push Notifications Permissions

Trying to work around a few corner cases for when push notifications are denied in the app and I have two questions:

1) Is there a way to reset whether the user has seen the notification request pop up?

2) Is there any way to determine if the user has said no to the notification request?

like image 250
Brian King Avatar asked Aug 27 '10 18:08

Brian King


2 Answers

1) No, unless there's some private API that does that, but that's not allowed by Apple

2) The first time your app is started, after calling registerForRemoteNotificationTypes, you can check if didRegisterForRemoteNotificationsWithDeviceToken is called. If it's not, the user said "No thanks".

like image 179
Philippe Leybaert Avatar answered Oct 01 '22 20:10

Philippe Leybaert


You can always check the status of the permissions if the user changes them, you can check them on applicationDidBecomeActive

- (void)applicationDidBecomeActive:(UIApplication *)application
{
     if ([[UIApplication sharedApplication]  respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {
        if ([[UIApplication sharedApplication]  isRegisteredForRemoteNotifications]){
            NSLog(@"Notifications Enabled ios 8");
        } else {
            NSLog(@"Notifications not Enabled ios 8");
        }
    } else {
        UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
        if (types & UIRemoteNotificationTypeAlert)
        {
            NSLog(@"Notifications Enabled");
        }
        else
        {
            NSLog(@"Notifications not Enabled");
        }
    }

}

updated to make it work on iOS 8 too

like image 21
jcesarmobile Avatar answered Oct 01 '22 19:10

jcesarmobile