推送通知未确定

Push notification not determined

在 ios 10 中有 UNUserNotificationCenter class 和方法 getNotificationSettingsWithCompletionHandler 给你 UNNotificationSettings 对象,你可以检查用户是否被问过对于推送通知 permissions.Is iOS 9 和 iOS 8.

你可以这样使用:

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
}

没有办法。该功能从 ios 10 开始可用。