美文网首页
ios 判断用户是否开启通知

ios 判断用户是否开启通知

作者: 被风吹乱的思念 | 来源:发表于2018-04-19 17:05 被阅读34次
     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(), ^{
    
                });
            }
            
        }
    

    如有错误欢迎指正

    相关文章

      网友评论

          本文标题:ios 判断用户是否开启通知

          本文链接:https://www.haomeiwen.com/subject/kaowkftx.html