通话 call
接口声明
{ "name": "vivo.call" }
导入模块
import call from '@vivo.call' 或 const call = require('@vivo.call')
接口定义
注:“手表平台参数” 表示开发手表应用必填参数
call.dial(OBJECT)
拨打电话
参数:
参数名 |
类型 |
必填 |
说明 |
number |
String |
是 |
拨号号码 |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
simSlot |
Integer |
否 |
sim 卡槽 id |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.dial({
number: '130xxxx1234',
phoneType: 0,
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.cancel(OBJECT)
取消拨打电话
参数:
参数名 |
类型 |
必填 |
说明 |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.cancel({
phoneType: 0,
success: function () {
console.log('handling success')
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.hangup(OBJECT)
挂断/结束通话
参数:
参数名 |
类型 |
必填 |
说明 |
callId |
Integer |
是 |
通话 id |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.hangup({
callId: 1,
phoneType: 0,
success: function () {
console.log('handling success')
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.answer(OBJECT)
接听来电
参数:
参数名 |
类型 |
必填 |
说明 |
callId |
Integer |
是 |
通话 id |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.answer({
callId: 1,
phoneType: 0,
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.reject(OBJECT)
拒接来电
参数:
参数名 |
类型 |
必填 |
说明 |
callId |
Integer |
是 |
通话 id |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.reject({
callId: 1,
phoneType: 0,
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.switch(OBJECT)
交换两路通话状态
参数:
参数名 |
类型 |
必填 |
说明 |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.switch({
phoneType: 0,
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.sendDTMF(OBJECT)
发送 DTMF 指令
参数:
参数名 |
类型 |
必填 |
说明 |
callId |
Integer |
是 |
通话 id |
dtmf |
String |
是 |
dtmf 指令 |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.sendDTMF({
callId: 1,
dtmf: '1',
phoneType: 0,
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.onstatechange = function(data)
监听通话状态变化的事件
data 返回值:
参数名 |
类型 |
必填 |
说明 |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
callList |
Object[] |
是 |
通话列表 |
callList 返回值:
参数名 |
类型 |
必填 |
说明 |
callId |
Integer |
是 |
通话 id |
state |
Integer |
是 |
通话状态:1 为已挂断,2 为开始拨号,3 为通话,4 为呼出对方振铃,5 为来电,6 为保持,7 为等待 |
number |
String |
否 |
号码 |
simSlot |
Integer |
否 |
sim 卡槽 id |
示例:
call.onstatechange = function (data) {
console.log(`handling onstatechange`)
}
call.openAudioRoute(OBJECT)
打开/设置通话音频通路
参数:
参数名 |
类型 |
必填 |
说明 |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
routeType |
Integer |
是 |
音频通路类型:0 表示 watch 外放,1 表示耳机 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.openAudioRoute({
phoneType: 0,
routeType: 0,
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.closeAudioRoute(OBJECT)
关闭音频通路
参数:
参数名 |
类型 |
必填 |
说明 |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.closeAudioRoute({
phoneType: 0,
success: function (data) {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.setCallMute(OBJECT)
设置通话麦克风是否静音
参数:
参数名 |
类型 |
必填 |
说明 |
isMute |
Boolean |
是 |
true 表示静音,false 表示取消静音 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.setCallMute({
isMute: true,
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.setCallVolume(OBJECT)
设置通话音量大小
参数:
参数名 |
类型 |
必填 |
说明 |
volume |
Integer |
是 |
音量大小,0 - 100 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.setCallVolume({
volume: 50,
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.startRinging(OBJECT)
播放来电铃声
参数:
参数名 |
类型 |
必填 |
说明 |
phoneType |
Integer |
否 |
手表平台参数,通话类型:0 表示 esim,1 表示蓝牙 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.startRinging({
phoneType: 0,
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.stopRinging(OBJECT)
停止播放来电铃声
参数:
参数名 |
类型 |
必填 |
说明 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.stopRinging({
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.setRingingMute(OBJECT)
设置来电铃声静音
参数:
参数名 |
类型 |
必填 |
说明 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.setRingingMute({
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})
call.setRingingVolume(OBJECT)
设置铃声音量大小
参数:
参数名 |
类型 |
必填 |
说明 |
volume |
Integer |
是 |
音量大小,0 - 100 |
success |
Function |
否 |
成功回调 |
fail |
Function |
否 |
失败回调 |
complete |
Function |
否 |
执行结束后的回调 |
示例:
call.setRingingVolume({
volume: 50,
success: function () {
console.log(`handling success`)
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
},
})