相机权限

1.1 使用说明

  1. 在合适的地方导入#import <AVFoundation/AVFoundation.h>
  2. 使用AVAuthorizationStatus类获取当前权限状态
  3. 在没有权限的情况下弹出alertView提示跳转。

1.2 代码示例

  • 权限判断
#import <AVFoundation/AVFoundation.h>
...
// 相机权限判断
- (void)getPhotoAuthorizationStatus
{AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; if (authStatus == AVAuthorizationStatusDenied || authStatus == AVAuthorizationStatusRestricted) { // 没有权限。弹出alertView [self showAlert]; }else{ //获取了权限,直接调用相机接口 } }
  • 弹出alertView
- (void)showAlert
{UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"相机权限未开启"message:@"相机权限未开启,请进入系统【设置】>【隐私】>【相机】中打开开关,开启相机功能" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"立即开启", nil]; @weakify(self); [[alertView rac_buttonClickedSignal] subscribeNext:^(NSNumber *buttonIndex) { @strongify(self); if ([buttonIndex isEqualToNumber:@1]) { #ifdef __IPHONE_8_0 //跳入当前App设置界面, [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; #else //适配iOS7 ,跳入系统设置界面 [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"prefs:General&path=Reset"]]; #endif } }]; [alertView show]; }

1.3 参数说明

  • 当前权限状态
typedef NS_ENUM(NSInteger, AVAuthorizationStatus) {AVAuthorizationStatusNotDetermined = 0, // 用户尚未做出选择这个应用程序的问候 AVAuthorizationStatusRestricted, // 此应用程序没有被授权访问的照片数据。可能是家长控制权限 AVAuthorizationStatusDenied, // 用户已经明确否认了应用程序访问 AVAuthorizationStatusAuthorized // 用户已经授权应用访问相机 }
  • 跳转到系统设定界面的字段
About — prefs:root=General&path=About
Accessibility — prefs:root=General&path=ACCESSIBILITY
AirplaneModeOn— 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=Keyboard iCloud — prefs:root=CASTLE iCloud Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUP International — prefs:root=General&path=INTERNATIONAL Location Services — prefs:root=LOCATION_SERVICES Music — prefs:root=MUSIC Music Equalizer — prefs:root=MUSIC&path=EQ Music VolumeLimit— prefs:root=MUSIC&path=VolumeLimit Network — prefs:root=General&path=Network Nike + iPod — prefs:root=NIKE_PLUS_IPOD Notes — prefs:root=NOTES Notification — prefs:root=NOTIFICATIONS_ID Phone — prefs:root=Phone Photos — prefs:root=Photos Profile — prefs:root=General&path=ManagedConfigurationList Reset — prefs:root=General&path=Reset Safari — prefs:root=Safari Siri — prefs:root=General&path=Assistant Sounds — prefs:root=Sounds SoftwareUpdate— prefs:root=General&path=SOFTWARE_UPDATE_LINK Store — prefs:root=STORE Twitter — prefs:root=TWITTER Usage — prefs:root=General&path=USAGE VPN — prefs:root=General&path=Network/VPN Wallpaper — prefs:root=Wallpaper Wi-Fi — prefs:root=WIFI Setting—prefs:root=INTERNET_TETHERING

注意:需要info中,添加 URL Schemes为 prefs的url

相册权限

1.1 使用说明

  1. 在合适的地方导入#import <AssetsLibrary/AssetsLibrary.h>
  2. 使用ALAuthorizationStatus类获取当前权限状态
  3. 在没有权限的情况下弹出alertView提示跳转。

1.2 代码示例

代码如下所示,alertView如相机权限中所示.

//相册权限判断
- (void)getAlbumAuthorizationStatus
{ALAuthorizationStatus authStatus = [ALAssetsLibrary authorizationStatus];if (authStatus == ALAuthorizationStatusDenied || authStatus == ALAuthorizationStatusRestricted) {// 没有权限[self showAlert]; }else{ // 已经获取权限 } }

1.3 参数说明

typedef NS_ENUM (NSInteger, ALAuthorizationStatus) {kCLAuthorizationStatusNotDetermined = 0, // 用户尚未做出选择这个应用程序的问候 kCLAuthorizationStatusRestricted, // 此应用程序没有被授权访问的照片数据。可能是家长控制权限 kCLAuthorizationStatusDenied, // 用户已经明确否认了这一照片数据的应用程序访问 kCLAuthorizationStatusAuthorized // 用户已经授权应用访问照片数据 } CLAuthorizationStatus;

定位权限

1.1 使用说明

  1. 在合适的地方导入#import <CoreLocation/CLLocation.h>
  2. 使用[CLLocationManager authorizationStatus]获取当前权限状态
  3. 在没有权限的情况下弹出alertView提示跳转。

1.2 代码示例

代码如下所示,alertView如相机权限中所示.

- (void)servicesEnabled
{if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted) {// 没有权限, [self alertAuth]; } }

1.3 参数说明

typedef NS_ENUM(int, CLAuthorizationStatus) {kCLAuthorizationStatusNotDetermined = 0, // 用户尚未做出选择这个应用程序的问候 kCLAuthorizationStatusRestricted, // 受限制的,非用户行为,此应用程序没有被授权访问的照片数据。 kCLAuthorizationStatusDenied, / 用户已经明确否认了这一应用程序访问 kCLAuthorizationStatusAuthorizedAlways 定位服务授权状态已经被用户允许在任何状态下获取位置信息。 kCLAuthorizationStatusAuthorizedWhenInUse 定位服务授权状态仅被允许在使用应用程序的时候。 kCLAuthorizationStatusAuthorized NS_ENUM_DEPRECATED(10_6, NA, 2_0, 8_0, "Use kCLAuthorizationStatusAuthorizedAlways") __TVOS_PROHIBITED __WATCHOS_PROHIBITED = kCLAuthorizationStatusAuthorizedAlways }

iOS 权限判断 跳转对应设置界面相关推荐

  1. android 强制打开gps定位_Android 6.0动态权限及跳转GPS设置界面的方法

    1.动态权限申请 模糊的位置信息android.permission.ACCESS_COARSE_LOCATION权限为例 在AndroidManifest文件中加入权限 然后java代码中动态申请 ...

  2. iOS 应用内跳转到设置页

    我参加了CSDN博客之星的的评选, 请为我投上一票. 我的投票入口 CSDN博客之星我的投票入口 直接点击跳转到系统设置界面, 设置通知定位等等 在操作之前, 你需要info中设置 URLTypes, ...

  3. Android 判断是否网络连接, 判断是否为WIFI,移动网络以及跳转网络设置界面

    这个自己在项目中总结了一个工具类 如下 public class NetWorkUtils {private NetWorkUtils() {/* cannot be instantiated */t ...

  4. iOS应用内跳转系统设置相关界面的方法

    在iOS开发中,有时会有跳转系统设置界面的需求,例如提示用户打开蓝牙或者WIFI,提醒用户打开推送或者位置权限等.在iOS6之后,第三方应用需要跳转系统设置界面,需要在URL type中添加一个pre ...

  5. android无网络状态栏,Android中检查网络连接状态的变化,无网络时跳转到设置界面...

    在AndroidManifest.xml中加一个声明 1. 2. 3. 4. 5. NetCheckReceive.java文件如下 1.import android.content.Broadcas ...

  6. ios wifi 定位_iOS最新跳转手机设置WIFI定位等界面方法适配iOS11

    iOS的"人性化"不言而喻,就是访问位置,打开WiFi,,,,都需要得到用户的允许,而有些请款下,用户暂时不想打开这些,甚至手抖选错了关闭,这个时候,就需要你去提醒用户去打开权限, ...

  7. iOS开发之如何跳到系统设置里的各种设置界面

    一·iOS开发之如何跳到系统设置里的WiFi界面 之前以为,苹果不支持直接从应用跳到系统设置里的WiFi界面.后来发现,这个小功能是可以实现的,而且实现起来并不麻烦.让我们一起来看看吧! 需求 从应用 ...

  8. OC如何跳到系统设置里的各种设置界面

    当 iOS系统版本 <= iOS7时 , 只能跳转到 系统设置页面 ,楼主试了下,非真机是没有任何效果的 当iOS系统版本 < iOS 10.0 时 NSURL *url= [NSURL ...

  9. android跳转到系统的各项设置界面

    前言: 由于需求需要,有很多时候都需要跳转到android的各项设置界面,比如说Wi-Fi列表页,系统设置主页,应用权限管理界面等等,但是很多人都不知道对应的Activity Action是什么,现在 ...

最新文章

  1. 新材料,比钢硬一倍,但重量只有钢1/6
  2. 成功解决采用ax.bar进行三维绘图绘制柱状图的时候,横坐标只显示三列而不是数据中的四列
  3. 迷宫pascal程序
  4. opencv轻松入门面向python下载_OpenCV轻松入门:面向Python
  5. 在前端中如何在表格中最后一行加入输入框_UI设计进阶干货 — 如何制定UI规范...
  6. iOS即时通讯输入框随字数自适应高度
  7. Hi!怂程见证我开博。
  8. MOSS 2010 无法同步用户配置文件
  9. 11-linux基础八-正则表达式
  10. Linux c语言 creat参数,C语言open和creat函数
  11. FPGA——三段式状态机(1)
  12. 前端项目开发流程(附思维导图PC)
  13. 毕业生签约时必须知道三件事:三方协议、干部身份、派遣证
  14. 黑帽SEO的作弊手法:
  15. 解决无法修改日志时间的问题(Local time zone must be set--see zic manual page 2019 )
  16. 电脑配置jdk环境变量_苹果电脑配置环境变量
  17. 我的STM32 IAP BOOT跳转到APP进入HardFault_Handler解决方案
  18. vue组件中的data为什么是一个函数
  19. 详解各种布隆过滤器原理及使用场景
  20. 【Windows下设置全局以管理员身份运行cmd】

热门文章

  1. LeetCode--75.颜色分类(三路快排,计数排序)
  2. C++中公有继承、保护继承、私有继承
  3. 4024-砾石的交换排序(C++,附思路)
  4. 动态规划之最长公共子序列
  5. 输入一个以回车结束的字符串,判断该字符串是否对称(正序与逆序相同,如aBc2cBa为对称字符串)
  6. php5.2 array,详解php 5.2.x 数组操作实例
  7. 怎么将layui导入php中,layui怎么导入Excel
  8. SecureCRT打开文件中文乱码
  9. # 20180908 2018-2019-2 《密码与安全新技术专题》第9周作业
  10. [翻译] 编写高性能 .NET 代码--第二章 GC -- 配置选项