uniapp authorization, call again after the user refuses

Make a note of today's recording authorization

//这个是写在点击事件里面的
let that = this
uni.authorize({
	scope: 'scope.record',//这里选择scope.(录音、位置、用户信息...都可以)
	success() { //1.1 允许授权
		that.timer = setInterval(that.startTimer, 1000),//录音定时器
		recorderManager.start()//开始录音
	},
	fail() { // 拒绝授权
		uni.showModal({
		    content: '检测到您没打开录音功能权限,是否去设置打开?',
			confirmText: "确认",
			cancelText: '取消',
			success: (res) => {
				if (res.confirm) {
					uni.openSetting({//opensetting是调起设置页面的
						success: (res) => {
							console.log(res.authSetting);
								if(res.authSetting == true){//判断res.authsetting的值是true还是false
									that.timer = setInterval(that.startTimer,1000),
							               recorderManager.start()
								}else{
									console.log("什么也不做");
									}	
								}
							})
					} else {
						console.log('取消');
						return false;
					}
				}
			})
			return false;
		}
	})

Acho que você gosta

Origin blog.csdn.net/xybhua/article/details/129103928
Recomendado
Clasificación