【问题标题】:Push notification not determined未确定推送通知
【发布时间】:2016-12-27 14:13:30
【问题描述】:
在 ios 10 中有 UNUserNotificationCenter 类和方法 getNotificationSettingsWithCompletionHandler 为您提供 UNNotificationSettings 对象,您可以检查用户是否曾被要求提供推送通知权限。有没有办法在 iOS 9 和iOS 8。
【问题讨论】:
标签:
ios
ios8
apple-push-notifications
unusernotificationcenter
【解决方案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
}