0

在ios 10中有UNUserNotificationCenter類和方法getNotificationSettingsWithCompletionHandler它給你UNNotificationSettings對象,你可以檢查用戶是否曾被要求過推送通知permissions.Is有辦法實現這一點的iOS 9和iOS 8 。推送通知未確定

回答

0

沒有辦法。該功能從ios 10開始可用。

1

您可以使用這樣的事情:

let notificationType = UIApplication.sharedApplication().currentUserNotificationSettings()!.types 

if notificationType == UIUserNotificationType.None { 
    // Push notifications are disabled in setting by user. 
} else { 
// Push notifications are enabled in setting by user. 
} 

if notificationType != UIUserNotificationType.None { 
    // Push notifications are enabled in setting by user. 
} 

if notificationType == UIUserNotificationType.Badge { 
    // the application may badge its icon upon a notification being received 
} 

if notificationType == UIUserNotificationType.Sound { 
    // the application may play a sound upon a notification being received 
} 

if notificationType == UIUserNotificationType.Alert { 
    // the application may display an alert upon a notification being received 
}