此代码用于检查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 state
和permission denied state
,上述代码打印No Permission Granted
。
答案 0 :(得分:0)
对于UIUserNotificationType,只有四种
- UIUserNotificationTypeNone
- UIUserNotificationTypeBadge
- UIUserNotificationTypeSound
- UIUserNotificationTypeAlert
醇>
如果用户未授予权限或用户已关闭Allow Notifications
选项,则您将在类型方法中获得UIUserNotificationTypeNone
。无法准确确定用户关闭通知所采取的操作