0
在ios 10中有UNUserNotificationCenter
類和方法getNotificationSettingsWithCompletionHandler
它給你UNNotificationSettings
對象,你可以檢查用戶是否曾被要求過推送通知permissions.Is有辦法實現這一點的iOS 9和iOS 8 。推送通知未確定
在ios 10中有UNUserNotificationCenter
類和方法getNotificationSettingsWithCompletionHandler
它給你UNNotificationSettings
對象,你可以檢查用戶是否曾被要求過推送通知permissions.Is有辦法實現這一點的iOS 9和iOS 8 。推送通知未確定
沒有辦法。該功能從ios 10開始可用。
您可以使用這樣的事情:
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
}