未确定推送通知
Posted
技术标签:
【中文标题】未确定推送通知【英文标题】:Push notification not determined 【发布时间】:2016-12-27 14:13:30 【问题描述】:在 ios 10 中有 UNUserNotificationCenter
类和方法 getNotificationSettingsWithCompletionHandler
为您提供 UNNotificationSettings
对象,您可以检查用户是否曾被要求提供推送通知权限。有没有办法在 iOS 9 和iOS 8。
【问题讨论】:
【参考方案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
【讨论】:
【参考方案2】:没有办法。该功能从 ios 10 开始可用。
【讨论】:
以上是关于未确定推送通知的主要内容,如果未能解决你的问题,请参考以下文章
应用程序未运行时推送通知 - launchOptions 字典为空