Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to interrogate UIUserNotificationSettings types

I am trying to implement the application:didRegisterUserNotificationSettings: App Delegate method to try and identify if i am allowed to send local notifications to the user in iOS 8. The following is the kind of thing i'm trying to achieve, but this is obviously the incorrect way of going about it.

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{

    if (notificationSettings.types /*How do i check which types are contained */) {

        NSLog(@"Allowed");

    } else {

        NSLog(@"Not Allowed");
    }

}
like image 530
Sammio2 Avatar asked Sep 19 '14 12:09

Sammio2


1 Answers

Here you go

if (notificationSettings.types == UIUserNotificationTypeNone) {
      NSlog(@"Permission not Granted by user");
}
else{
      NSlog(@"Permission Granted");
}

To interrogate a specific setting:

BOOL allowsSound = (notifSettings.types & UIUserNotificationTypeSound) != 0;
like image 125
Bhumit Mehta Avatar answered Nov 04 '22 00:11

Bhumit Mehta