增加权限认证
This commit is contained in:
+36
-18
@@ -2,7 +2,7 @@
|
||||
* 本模块封装了Android、iOS的应用权限判断、打开应用权限设置界面、以及位置系统服务是否开启
|
||||
*/
|
||||
|
||||
var isIos
|
||||
let isIos
|
||||
// #ifdef APP-PLUS
|
||||
isIos = (plus.os.name == "iOS")
|
||||
// #endif
|
||||
@@ -80,18 +80,34 @@ function judgeIosPermissionRecord() {
|
||||
|
||||
// 判断相机权限是否开启
|
||||
function judgeIosPermissionCamera() {
|
||||
var result = false;
|
||||
var AVCaptureDevice = plus.ios.import("AVCaptureDevice");
|
||||
var authStatus = AVCaptureDevice.authorizationStatusForMediaType('vide');
|
||||
console.log("authStatus:" + authStatus);
|
||||
if (authStatus == 3) {
|
||||
result = true;
|
||||
console.log("相机权限已经开启");
|
||||
} else {
|
||||
console.log("相机权限没有开启");
|
||||
const authSetting = uni.getAppAuthorizeSetting();
|
||||
const state = authSetting.cameraAuthorized;
|
||||
console.log('state', state);
|
||||
switch (state) {
|
||||
case 'authorized':
|
||||
console.log("相机权限已经开启");
|
||||
return 'authorized';
|
||||
case 'denied':
|
||||
return 'denied';
|
||||
case 'not determined':
|
||||
return 'undetermined';
|
||||
case 'config error':
|
||||
return 'undetermined';
|
||||
default:
|
||||
return 'undetermined';
|
||||
}
|
||||
plus.ios.deleteObject(AVCaptureDevice);
|
||||
return result;
|
||||
// var result = false;
|
||||
// var AVCaptureDevice = plus.ios.import("AVCaptureDevice");
|
||||
// var authStatus = AVCaptureDevice.authorizationStatusForMediaType('vide');
|
||||
// console.log("authStatus:" + authStatus);
|
||||
// if (authStatus == 3) {
|
||||
// result = true;
|
||||
// console.log("相机权限已经开启");
|
||||
// } else {
|
||||
// console.log("相机权限没有开启");
|
||||
// }
|
||||
// plus.ios.deleteObject(AVCaptureDevice);
|
||||
// return result;
|
||||
}
|
||||
|
||||
// 判断相册权限是否开启
|
||||
@@ -264,9 +280,11 @@ function checkSystemEnableLocation() {
|
||||
}
|
||||
}
|
||||
|
||||
export default ({
|
||||
judgeIosPermission: judgeIosPermission,
|
||||
requestAndroidPermission: requestAndroidPermission,
|
||||
checkSystemEnableLocation: checkSystemEnableLocation,
|
||||
gotoAppPermissionSetting: gotoAppPermissionSetting
|
||||
})
|
||||
|
||||
|
||||
export default {
|
||||
judgeIosPermission,
|
||||
requestAndroidPermission,
|
||||
checkSystemEnableLocation,
|
||||
gotoAppPermissionSetting
|
||||
}
|
||||
Reference in New Issue
Block a user