uni-app 判断手机摄像头、麦克风有没有打开没有的话打开设置页面

时间:2024-02-25 07:51:59

 

示例:

import permision from "@/js_sdk/wa-permission/permission.js"


let valueCamera = await this.requestAndroidPermission(\'android.permission.CAMERA\'); let valueRecord = await this.requestAndroidPermission(\'android.permission.RECORD_AUDIO\'); if (valueCamera === 0) {   permision.gotoAppPermissionSetting()  } else if (valueRecord === 0) {   permision.gotoAppPermissionSetting() } else {   let userName = uni.getStorageSync(\'userInfo\').userMsg.userId.replace(/-/g, \'\');   let nickName = `${uni.getStorageSync(\'userInfo\').userMsg.displayName}-${uni.getStorageSync(\'userInfo\').userMsg.ouName}`;   let password = uni.getStorageSync("video-passWord");   uni.navigateTo({   url: \'../huanXin_im/im?url=\' + urls.webim_url + \'&userId=\' + userName + \'&nickName=\' + nickName + \'&password=\' + password,   }); }

参考网址:

https://ext.dcloud.net.cn/plugin?id=594