检查“未确定状态”'并且'许可被拒绝状态' UILocalNotification

时间:2016-11-16 18:55:11

标签: ios objective-c uilocalnotification

此代码用于检查UILocalNotification权限

[[UIApplication sharedApplication] currentUserNotificationSettings];

UIUserNotificationSettings *grantedSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];

    NSMutableDictionary *localNotificationPermissions = [[NSMutableDictionary alloc]init];

        if (grantedSettings.types == UIUserNotificationTypeNone) {
        NSLog(@"No Permission Granted");
        } else {
        NSLog(@"Permission Granted");
    }

会告诉permission

但我不知道如何检查not determine statepermission denied state,上述代码打印No Permission Granted

1 个答案:

答案 0 :(得分:0)

对于UIUserNotificationType,只有四种

  
      
  1. UIUserNotificationTypeNone
  2.   
  3. UIUserNotificationTypeBadge
  4.   
  5. UIUserNotificationTypeSound
  6.   
  7. UIUserNotificationTypeAlert
  8.   

如果用户未授予权限或用户已关闭Allow Notifications选项,则您将在类型方法中获得UIUserNotificationTypeNone。无法准确确定用户关闭通知所采取的操作