在ios 10中,UNUserNotificationCenter
类和方法getNotificationSettingsWithCompletionHandler
为您提供UNNotificationSettings
对象,您可以检查用户是否曾被要求提供推送通知权限。是否有办法为iOS 9和iOS 8实现这一目标。
答案 0 :(得分: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
}
答案 1 :(得分:0)
没有办法。该功能从ios 10开始提供。