if (@available(iOS 10.0, *)) {
[[UNUserNotificationCenter currentNotificationCenter]getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
if (settings.authorizationStatus == UNAuthorizationStatusDenied) {
// 用户未授权通知
dispatch_async(dispatch_get_main_queue(), ^{
});
}else if (settings.authorizationStatus == UNAuthorizationStatusAuthorized) {
dispatch_async(dispatch_get_main_queue(), ^{
});
}
}];
} else {
if ([[UIApplication sharedApplication] currentUserNotificationSettings].types == UIRemoteNotificationTypeNone) {
dispatch_async(dispatch_get_main_queue(), ^{
});
}else {
dispatch_async(dispatch_get_main_queue(), ^{
});
}
}
如有错误欢迎指正
网友评论