2016-11-16 62 views
0

的 '權限被拒絕狀態' 這段代碼是檢查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我兩種情況。

回答

0

對於UIUserNotificationType,有隻有4種

  1. UIUserNotificationTypeNone
  2. UIUserNotificationTypeBadge
  3. UIUserNotificationTypeSound
  4. UIUserNotificationTypeAlert

如果用戶未授予權限或用戶關閉了Allow Notifications選項,那麼您將在類型方法中獲得UIUserNotificationTypeNone。無法確定用戶採取哪些措施來關閉通知