detect “Allow Notifications” is on/off for iOS8

后端 未结 11 1383
我寻月下人不归
我寻月下人不归 2020-12-01 06:32

I am trying to detect the Local notification settings for the App in iOS 8

for UIUserNotificationSettings, it returns me 7 as I have turned on all Badge

11条回答
  •  温柔的废话
    2020-12-01 06:43

    check this out. code is tried and tested.

    - (BOOL)isUserNotificationAllowed {
        UIUserNotificationType types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
        if(types & UIUserNotificationTypeBadge || types & UIUserNotificationTypeSound || types & UIUserNotificationTypeAlert){
            return YES;
        }
        else {
            return NO;
        }
    }
    

提交回复
热议问题