uniapp中拨打电话遇到的坑

uniapp中在安卓端中若是已经拒绝过一次申请拨打电话权限后则再次,调用uni.makemakePhoneCall会到成功的回调,但是却没有反应

错误代码

uni.makePhoneCall({
						phoneNumber,
						success:(res)=>{
							console.log('拨打电话成功')
							console.log(res)
						},
						fail:(err)=>{
							console.log('拨打电话失败')
							console.log(err)
						}
					})

改进后

makePhone(phoneNumber) {
		// console.log(phoneNumber)
		
		plus.android.requestPermissions(
			['android.permission.CALL_PHONE'],
			function (resultObj) {
				let result = 0
				for (let i = 0; i < resultObj.granted.length; i++) {
					let grantedPremission = resultObj.granted[i]
					console.log('已获取权限',grantedPremission)
					result =1
				}
				for(let i =0 ;i<resultObj.deniedPresent.length;i++){
					let deniedPresentPremission = resultObj.deniedPresent[i]
					console.log('拒绝本次申请的权限',deniedPresentPremission)
					result=0
				}
				for(let i=0;i>resultObj.deniedAlways.length;i++){
					let deniedAlwaysPremission = resultObj.deniedAlways[i]
					console.log('永久拒绝申请的权限',deniedAlwaysPremission)
					result=-1
				}
				if(result==1){
					uni.makePhoneCall({
						phoneNumber,
						success:(res)=>{
							console.log('拨打电话成功')
							console.log(res)
						},
						fail:(err)=>{
							console.log('拨打电话失败')
							console.log(err)
						}
					})
				}else{
					this.tips('请在设置中打开拨打电话权限')
				}

			},
			function(err){
				console.log('申请权限错误:' + error.code + " = " + error.message);

			}
		)
	}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值