天天看点

检测是否开启推送通知功能

一般应用中会用到检测手机是否开启推送通知功能,下面是检测是否开启推送通知功能的检测方法:

-(BOOL)isOpenNotificationFun{

    if([[[UIDevice currentDevice] systemVersion]floatValue]>=8.0){

        UIUserNotificationType types=[[UIApplication sharedApplication]currentUserNotificationSettings].types;

        return (types & UIRemoteNotificationTypeAlert);

    }else{

        UIRemoteNotificationType types=[[UIApplication sharedApplication]enabledRemoteNotificationTypes];

        return (types & UIRemoteNotificationTypeAlert);

    }

}