在 ios 10 中有UNUserNotificationCenter
类和方法getNotificationSettingsWithCompletionHandler
可以为您提供UNNotificationSettings
对象,您可以检查用户是否曾被要求提供推送通知权限。iOS 9 和 iOS 8 有没有办法实现这一点。
问问题
201 次
2 回答
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
}
于 2016-12-27T16:31:49.480 回答
0
没有办法。该功能从 ios 10 开始可用。
于 2017-04-25T08:14:26.180 回答