- <!-- 相冊 -->
- <key>NSPhotoLibraryUsageDescription</key>
- <string>App需要您的同意,才能訪問相冊</string>
- <!-- 相機 -->
- <key>NSCameraUsageDescription</key>
- <string>App需要您的同意,才能訪問相機</string>
- <!-- 麥克風 -->
- <key>NSMicrophoneUsageDescription</key>
- <string>App需要您的同意,才能訪問麥克風</string>
- <!-- 位置 -->
- <key>NSLocationUsageDescription</key>
- <string>App需要您的同意,才能訪問位置</string>
- <!-- 在使用期間訪問位置 -->
- <key>NSLocationWhenInUseUsageDescription</key>
- <string>App需要您的同意,才能在使用期間訪問位置</string>
- <!-- 始終訪問位置 -->
- <key>NSLocationAlwaysUsageDescription</key>
- <string>App需要您的同意,才能始終訪問位置</string>
- <!-- 日歷 -->
- <key>NSCalendarsUsageDescription</key>
- <string>App需要您的同意,才能訪問日歷</string>
- <!-- 提醒事項 -->
- <key>NSRemindersUsageDescription</key>
- <string>App需要您的同意,才能訪問提醒事項</string>
- <!-- 運動與健身 -->
- <key>NSMotionUsageDescription</key> <string>App需要您的同意,才能訪問運動與健身</string>
- <!-- 健康更新 -->
- <key>NSHealthUpdateUsageDescription</key>
- <string>App需要您的同意,才能訪問健康更新 </string>
- <!-- 健康分享 -->
- <key>NSHealthShareUsageDescription</key>
- <string>App需要您的同意,才能訪問健康分享</string>
- <!-- 藍牙 -->
- <key>NSBluetoothPeripheralUsageDescription</key>
- <string>App需要您的同意,才能訪問藍牙</string>
- <!-- 媒體資料庫 -->
- <key>NSAppleMusicUsageDescription</key> <string>App需要您的同意,才能訪問媒體資料庫</string>
info.plist中逐個添加 KEY直接復制 value的string字符串就是提示的文字 可以根據自己需要填寫
#import<AVFoundation/AVCaptureDevice.h>
#import <AVFoundation/AVMediaFormat.h>
#import<AssetsLibrary/AssetsLibrary.h>
#import<CoreLocation/CoreLocation.h>
//相機權限
AVAuthorizationStatus authStatus = [AVCaptureDeviceauthorizationStatusForMediaType:AVMediaTypeVideo];
if (authStatus ==AVAuthorizationStatusRestricted ||//此應用程序沒有被授權訪問的照片數據。可能是家長控制權限
authStatus ==AVAuthorizationStatusDenied) //用戶已經明確否認了這一照片數據的應用程序訪問
{
// 無權限 引導去開啟
NSURL *url = [NSURLURLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplicationsharedApplication]canOpenURL:url]) {
[[UIApplicationsharedApplication]openURL:url];
}
}
//相冊權限
ALAuthorizationStatus author = [ALAssetsLibraryauthorizationStatus];
if (author ==kCLAuthorizationStatusRestricted || author ==kCLAuthorizationStatusDenied){
//無權限 引導去開啟
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
}