ios 系统权限检测

来源:互联网 发布:math js w3c 编辑:程序博客网 时间:2024/05/17 09:10

权限判断

// 是否有相册访问权限- (BOOL)checkPhotoAuth{        ALAuthorizationStatus author = [ALAssetsLibrary authorizationStatus];        if(author == ALAuthorizationStatusRestricted || author == ALAuthorizationStatusDenied){                //无权限                NSError *error = [NSError errorWithDomain:@"访问相册" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"无权访问相册"}];}// 是否有相机访问权限- (BOOL)checkCameraAuth{        AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];        if(authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied){                //无权限} // 定位权限 // 手机是否开启了定位服务    BOOL service = [CLLocationManager locationServicesEnabled];    // 方向服务是否支持    BOOL heading = [CLLocationManager headingAvailable];    // 后台位置刷新    BOOL backRefresh = [CLLocationManager significantLocationChangeMonitoringAvailable];    CLAuthorizationStatus status = [CLLocationManager authorizationStatus];    if (status == kCLAuthorizationStatusRestricted || status == kCLAuthorizationStatusDenied)    {        // 无权限    }

系统权限scheme

// 使用此方法打开系统设置NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];  [[UIApplication sharedApplication] openURL:url]; 关于:About — prefs:root=General&path=About辅助功能:Accessibility — prefs:root=General&path=ACCESSIBILITY飞行模式:Airplane Mode On — prefs:root=AIRPLANE_MODE自动锁定:Auto-Lock — prefs:root=General&path=AUTOLOCK亮度:Brightness — prefs:root=Brightness蓝牙:Bluetooth — prefs:root=General&path=Bluetooth日期:Date & Time — prefs:root=General&path=DATE_AND_TIME视频:FaceTime — prefs:root=FACETIME通用:General — prefs:root=General键盘:Keyboard — prefs:root=General&path=KeyboardiCloud登录:iCloud — prefs:root=CASTLE语言和地区:International — prefs:root=General&path=INTERNATIONAL定位服务:Location Services — prefs:root=LOCATION_SERVICES音乐:Music — prefs:root=MUSIC备忘录:Notes — prefs:root=NOTES推送:Notification — prefs:root=NOTIFICATION相册:Photos — prefs:root=Photos描述文件:Profile — prefs:root=General&path=ManagedConfigurationList还原:Reset — prefs:root=General&path=Reset声音:Sounds — prefs:root=Sounds系统更新:Software Update — prefs:root=General&path=SOFTWARE_UPDATE_LINKAppStore:Store — prefs:root=STORE墙纸:Wallpaper — prefs:root=WallpaperWiFi:Wi-Fi — prefs:root=WIFI热点 — prefs:root=INTERNET_TETHERING指定应用设置:prefs:root=应用bundleID

更多权限

// 部分权限似乎不可用,跟上面的有重复,上面的权限已经测试过,真机都可以用#define About   @"prefs:root=General&path=About"#define Accessibility  @"prefs:root=General&path=ACCESSIBILITY"#define AirplaneModeOn  @"prefs:root=AIRPLANE_MODE"#define AutoLock @"prefs:root=General&path=AUTOLOCK"#define Brightness  @"prefs:root=Brightness"#define Bluetooth  @"prefs:root=General&path=Bluetooth"#define DateTime  @"prefs:root=General&path=DATE_AND_TIME"#define FaceTime  @"prefs:root=FACETIME"#define General  @"prefs:root=General"#define Keyboard  @"prefs:root=General&path=Keyboard"#define iCloud  @"prefs:root=CASTLE"#define iCloudStorageBackup  @"prefs:root=CASTLE&path=STORAGE_AND_BACKUP"#define International  @"prefs:root=General&path=INTERNATIONAL"#define LocationServices  @"prefs:root=LOCATION_SERVICES"#define Music @"prefs:root=MUSIC"#define MusicEqualizer  @"prefs:root=MUSIC&path=EQ"#define MusicVolumeLimit  @"prefs:root=MUSIC&path=VolumeLimit"#define Network  @"prefs:root=General&path=Network"#define NikeiPod  @"prefs:root=NIKE_PLUS_IPOD"#define Notes  @"prefs:root=NOTES"#define Notification  @"prefs:root=NOTIFICATI*****_ID"#define Phone  @"prefs:root=Phone"#define Photos  @"prefs:root=Photos"#define Profile  @"prefs:root=General&path=ManagedConfigurationList"#define Reset  @"prefs:root=General&path=Reset"#define Safari  @"prefs:root=Safari"#define Siri  @"prefs:root=General&path=Assistant"#define Sounds  @"prefs:root=Sounds"#define Software Update  @"prefs:root=General&path=SOFTWARE_UPDATE_LINK"#define Store  @"prefs:root=STORE"#define Twitter  @"prefs:root=TWITTER"#define Usage  @"prefs:root=General&path=USAGE"#define VPN  @"prefs:root=General&path=Network/VPN"#define Wallpaper  @"prefs:root=Wallpaper"#define WiFi  @"prefs:root=WIFI"#define Hot  @"prefs:root=INTERNET_TETHERING"
0 0
原创粉丝点击