HarmonyOS 鸿蒙Next web页面电话有标准的phone标识,点击却无法跳转拨号盘
HarmonyOS 鸿蒙Next web页面电话有标准的phone标识,点击却无法跳转拨号盘
问题描述:web页面电话有标准的phone标识,ios & android 均可以跳转拨号盘,鸿蒙却无法跳转拨号盘,鸿蒙webview可能存在缺陷。
2 回复
参考这个demo:
import web_webview from '@ohos.web.webview';
import { BusinessError } from '@kit.BasicServicesKit';
import { call, observer } from '@kit.TelephonyKit';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
testMethod() {
// 调用查询能力接口
let isSupport = call.hasVoiceCapability();
if (isSupport) {
// 如果设备支持呼叫能力,则继续跳转到拨号界面,并显示拨号的号码
call.makeCall("021-50504728", (err: BusinessError) => {
if (!err) {
console.log("make call success.");
} else {
console.log("make call fail, err is:" + JSON.stringify(err));
}
});
// 订阅通话业务状态变化(可选)
class SlotId {
slotId: number = 0
}
class CallStateCallback {
state: call.CallState = call.CallState.CALL_STATE_UNKNOWN;
number: string = "";
}
let slotId: SlotId = { slotId: 0 }
observer.on("callStateChange", slotId, (data: CallStateCallback) => {
console.log("call state change, data is:" + JSON.stringify(data));
});
}
}
build() {
Column() {
Web({ src: '', controller: this.controller })
.onLoadIntercept((event) => {
if (event) {
if (event.data.getRequestUrl().startsWith('tel')) {
this.testMethod()
return true
}
}
return false;
})
}
}
}
更多关于HarmonyOS 鸿蒙Next web页面电话有标准的phone标识,点击却无法跳转拨号盘的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html