Nhảy tới nội dung

my.makePhoneCall

makePhoneCall

my.makePhoneCall là API dùng để gọi tới 1 số điện thoại cụ thể.

Khả dụng: hỗ trợ từ version 1.77.1 trở lên.

Quét mã để trải nghiệm

Xem code mẫu trên Tini Studio

Demo

Trải nghiệm thử với trình giả lập bên dưới

API Params

Thuộc tínhKiểu dữ liệuBắt buộcMô tả
numbernumberSố điện thoại cần gọi
successFunctionCallback function khi việc gọi điện thành công
failFunctionCallback function khi gọi điện bất thành
completeFunctionCallback function khi hoàn tất việc gọi bất kể thành công hay thất bại

Callback function payload

  • Fail callback payload
Thuộc tínhKiểu dữ liệuMô tả
errorstringTên lỗi
errorMessagestringChi tiết lỗi

Sample Code

index.js
Page({
data: {
phone: undefined
},
phoneChange(e) {
this.setData({
phone: e.detail.value
});
},
onPhoneCall() {
my.makePhoneCall({
number: this.data.phone,
success: (res) => {
console.log(res);
},
fail: (e) => {
my.alert({ title: error, content: JSON.stringify(e) });
}
});
}
});
index.txml
<view>
<block-header title="Usage" description="Make phone call" />
<view class=" block-content">
Input the number to call

</view>
<input class="form-value" placeholder="Phone number" name="phone" onInput="phoneChange"></input>
<view class="block-content">
<button class="button-full" onTap="onPhoneCall">Call</button>
</view>
</view>

|