// 通知的认证状态
func checkPushNotification(){
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().getNotificationSettings(){ (setttings) in
switch setttings.authorizationStatus{
case .authorized:
print("The application is authorized to post user notifications.")
case .denied:
print("The application is not authorized to post user notifications.")
case .notDetermined:
print("The user has not yet made a choice regarding whether the application may post user notifications.")
case .provisional:
print("The application is authorized to post non-interruptive user notifications.")
case .ephemeral:
print("The application is temporarily authorized to post notifications. Only available to app clips.")
@unknown default:
print("something vital went wrong here")
}
}
} else {
let isNotificationEnabled = UIApplication.shared.currentUserNotificationSettings?.types.contains(UIUserNotificationType.alert)
if isNotificationEnabled == true{
print("enabled notification setting")
}else{
print("setting has been disabled")
}
}
}
网友评论