uni-app ios端makePhoneCall功能无法正常使用

uni-app ios端makePhoneCall功能无法正常使用

开发环境 版本号 项目创建方式
Mac macOS 10.15.6 HBuilderX
iOS iOS 13.4 -

示例代码:

<view class="box_text_title" @click="go" :data-tel="(datauser.story_tel)">
<image src="../../static/images/dianhua.jpg" style="width: 30rpx;height: 30rpx;"></image>
手机号:{{ datauser.story_tel }}
</view>
go: function(e) {
let that = this;
uni.makePhoneCall({
phoneNumber: e.currentTarget.dataset.tel
//phoneNumber: '123456789'
});
}

操作步骤:

预期结果:

实际结果:

bug描述:

使用makePhoneCall将phoneNumber直接写为数字可以成功吊起拨号操作,使用变量只有回调success,并没有吊起拨打电话操作,安卓测试无此问题,可以吊起


更多关于uni-app ios端makePhoneCall功能无法正常使用的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

phoneNumber必须为字符串格式的,注意下后台返回的值,是不是有特殊字符或者空格的问题~~

更多关于uni-app ios端makePhoneCall功能无法正常使用的实战教程也可以访问 https://www.itying.com/category-93-b0.html


根据您描述的问题,在iOS端使用变量调用uni.makePhoneCall时无法正常唤起拨号界面,这可能是由于iOS平台的特殊性导致的。以下是解决方案:

  1. 首先确保变量中的电话号码格式正确,iOS对电话号码格式要求更严格:
go: function(e) {
    let tel = e.currentTarget.dataset.tel;
    // 去除所有非数字字符
    tel = tel.replace(/\D/g, '');
    uni.makePhoneCall({
        phoneNumber: tel
    });
}
  1. 检查变量绑定方式,建议改为更可靠的获取方式:
<view @click="go(datauser.story_tel)">...</view>

go: function(tel) {
    tel = String(tel).replace(/\D/g, '');
    uni.makePhoneCall({
        phoneNumber: tel
    });
}
  1. 如果问题仍然存在,可能是iOS权限问题,请检查是否在manifest.json中正确配置了权限:
"ios": {
    "permissions": {
        "Contacts": {
            "description": "用于拨打电话"
        }
    }
}
回到顶部