攝像頭權(quán)限
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
switch (status) {
case AVAuthorizationStatusNotDetermined:{
// 許可對話沒有出現(xiàn)涕刚,發(fā)起授權(quán)許可
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
dispatch_async(dispatch_get_main_queue(), ^{
if (granted) {
ScanViewController *scanViewController = [[ScanViewController alloc] initWithType:3];;
[self.navigationController pushViewController:scanViewController animated:NO];
}else{
//用戶拒絕
ScanViewController *scanViewController = [[ScanViewController alloc] initWithType:3];
[self.navigationController pushViewController:scanViewController animated:NO];
}
});
}];
}
break;
case AVAuthorizationStatusAuthorized:{
// 已經(jīng)開啟授權(quán),可繼續(xù)
ScanViewController *scanViewController = [[ScanViewController alloc] initWithType:3];
[self.navigationController pushViewController:scanViewController animated:NO];
}
break;
case AVAuthorizationStatusDenied:
case AVAuthorizationStatusRestricted: {
// 用戶明確地拒絕授權(quán),或者相機設(shè)備無法訪問
ScanViewController *scanViewController = [[ScanViewController alloc] initWithType:3];
[self.navigationController pushViewController:scanViewController animated:NO];
}
break;
default:
break;
}
麥克風權(quán)限
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
dispatch_async(dispatch_get_main_queue(), ^{
AVAuthorizationStatus statusVideo = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
AVAuthorizationStatus statusAudio = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
[ws judgeLianMaiLocationWithVideoPermission:statusVideo AudioPermission:statusAudio];
[ws.lianMaiView initUIWithVideoPermission:statusVideo AudioPermission:statusAudio];
});
}];
iOS 隱私權(quán)限和通過openURL實現(xiàn)跳轉(zhuǎn)實例
<key>NSPhotoLibraryUsageDescription</key>
<string>訪問相冊</string>
<key>NSCameraUsageDescription</key>
<string>訪問相機</string>
<key>NSContactsUsageDescription</key>
<string>訪問通訊錄</string>
<key>NSMicrophoneUsageDescription</key>
<string>訪問麥克風</string>
<key>NSAppleMusicUsageDescription</key>
<string>訪問媒體資料庫</string>
<key>NSLocationUsageDescription</key>
<string>訪問位置</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>使用期間訪問位置</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>始終訪問位置</string>
<key>NSCalendarsUsageDescription</key>
<string>訪問日歷</string>
<key>NSRemindersUsageDescription</key>
<string>訪問提醒事項</string>
<key>NSMotionUsageDescription</key>
<string>訪問運動與健身</string>
<key>NSHealthUpdateUsageDescription</key>
<string>訪問健康更新 </string>
<key>NSHealthShareUsageDescription</key>
<string>訪問健康分享</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>訪問藍牙</string>
<key>NSSiriUsageDescription</key>
<string>訪問Siri</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>訪問語音識別</string>
openUrl
開發(fā)中使用以下代碼可以實現(xiàn)快速撥打電話
NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];
if
(phoneVersion.floatValue < 10.0) {
//iOS10 以前使用
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@
"[Tel://123456](tel://123456)"
]];
}
else
{
//iOS10 以后使用
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@
"[Tel://123456](tel://123456)"
]
options:@{}
completionHandler:nil];
}
只要給出對應的URL一膨,系統(tǒng)就可以直接跳:
//撥打電話
[NSURL URLWithString:@
"[tel://123456](tel://123456)"
]
//發(fā)送短信
[NSURL URLWithString:@
"[sms://123456](sms://123456)"
]
//發(fā)郵件
[NSURL URLWithString:@
"[mailto://123456@163.com](mailto://123456@163.com)"
]
//前往App Store
[NSURL URLWithString:@
"itms-[apps://](apps://)"
]
//使用Safari訪問網(wǎng)址
[NSURL URLWithString:@
"[http://www.baidu.com](http://www.baidu.com/)"
]
//前往iBook
[NSURL URLWithString:@
"itms-[books://](books://)"
]
//發(fā)起Facetime
[NSURL URLWithString:@
"[facetime://](facetime://)"
]
//8培己、調(diào)用 地圖Map
[NSURL URLWithString:@
"[maps://](maps://)"
]
//9、調(diào)用 Music
[NSURL URLWithString:@
"[music://](music://)"
]
//10胳嘲、跳轉(zhuǎn)到系統(tǒng)設(shè)置相關(guān)界面
// iOS10 以前
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@
"prefs:root=LOCATION"
] options:@{} completionHandler:nil];
// iOS10 以后
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@
"App-Prefs:root=LOCATION"
] options:@{} completionHandler:nil];
#pragma mark - 以下為跳轉(zhuǎn)設(shè)置的對應方式
//設(shè)置
[NSURL URLWithString:UIApplicationOpenSettingsURLString]
//iCloud
[NSURL URLWithString:@
"App-Prefs:root=CASTLE"
]
//WIFI
[NSURL URLWithString:@
"App-Prefs:root=WIFI"
]
//藍牙
[NSURL URLWithString:@
"App-Prefs:root=Bluetooth"
]
//蜂窩數(shù)據(jù)
[NSURL URLWithString:@
"App-Prefs:root=MOBILE_DATA_SETTINGS_ID"
]
//通知
[NSURL URLWithString:@
"App-Prefs:root=NOTIFICATIONS_ID"
]
//通用
[NSURL URLWithString:@
"App-Prefs:root=General"
]
//關(guān)于手機
[NSURL URLWithString:@
"App-Prefs:root=General&path=About"
]
//輔助功能
[NSURL URLWithString:@
"App-Prefs:root=General&path=ACCESSIBILITY"
]
//日期與時間
[NSURL URLWithString:@
"App-Prefs:root=General&path=DATE_AND_TIME"
]
//鍵盤設(shè)置
[NSURL URLWithString:@
"App-Prefs:root=General&path=Keyboard"
]
//顯示與亮度
[NSURL URLWithString:@
"App-Prefs:root=DISPLAY"
]
//墻紙設(shè)置
[NSURL URLWithString:@
"App-Prefs:root=Wallpaper"
]
//聲音
[NSURL URLWithString:@
"App-Prefs:root=Sounds"
]
//Siri
[NSURL URLWithString:@
"App-Prefs:root=Siri"
]
//隱私
[NSURL URLWithString:@
"App-Prefs:root=Privacy"
]
//定位
[NSURL URLWithString:@
"App-Prefs:root=Privacy&path=LOCATION"
]
//電池電量
[NSURL URLWithString:@
"App-Prefs:root=BATTERY_USAGE"
]
//iTunes Store 與 App Store
[NSURL URLWithString:@
"App-Prefs:root=STORE"
]
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者