推送通知未确定

时间:2016-12-27 14:13:31

标签: ios ios8 apple-push-notifications unusernotificationcenter

在ios 10中,UNUserNotificationCenter类和方法getNotificationSettingsWithCompletionHandler为您提供UNNotificationSettings对象,您可以检查用户是否曾被要求提供推送通知权限。是否有办法为iOS 9和iOS 8实现这一目标。

2 个答案:

答案 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开始提供。