推送通知未确定
问题描述:
在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
}