swift4.0用户是否打开推送判断

if #available(iOS 10.0, *) {
                UNUserNotificationCenter.current().getNotificationSettings { (set) in
                    
                    if set.authorizationStatus == UNAuthorizationStatus.notDetermined{
                        print("推送不允许")
                    }else if set.authorizationStatus == UNAuthorizationStatus.denied{
                        print("推送不允许")

                    }else if set.authorizationStatus == UNAuthorizationStatus.authorized{
                        print("推送允许")

                    }
                }
            
            } else {
                
                let ty = UIApplication.shared.currentUserNotificationSettings?.types
                if Int(ty!.rawValue) == 0{
                    print("用户不允许推送")
                }else{
                    print("用户允许推送")

                }
                
            }

你可能感兴趣的:(swift4.0用户是否打开推送判断)