# callWMPF(Object req)
This interface is asynchronous and returns the
Promiseobject.Support needs to start with the plug-in version 2.4.0
Call a device running Android WMPF from Weixin Mini Program on the mobile home.When this interface is called, a VoIP room is created and a WMPF pushMsg reminder is pushed to the device.For details refer to WeChat Calling Device (Android) .
This interface can only be used in WeChat Guest, not in WMPF.It is recommended to read interface introduction first.
# parameter
# Object req
| attribute | type | Default values | Required to fill in | Introductions | Minimum version |
|---|---|---|---|---|---|
| roomType | string | yes | The type of call. Voice: audio call;video: Video calling | ||
| sn | string | yes | Receiver device SN | ||
| modelId | string | yes | Receiver device modelId | ||
| pushToken | string | yes | pushToken acquired from the device | ||
| nickName | string | yes | WeChat user name displayed on the device side | ||
| deviceName | string | no | Device name displayed on WeChat | 2.4.1 | |
| chargeType | string | 'license' | no | The method of billing. Duration: duration billing; License: license billing | |
| timeLimit | number | no | Maximum call time, needs a number > 0 | ||
| enableCallerCamera | boolean | true | no | Whether the caller turned on the camera. | |
| enableListenerCamera | boolean | true | no | Does the receiver turn on the camera? | |
| envVersion | string | 'release' | no | 接听方打开的小程序类型。 取值:release: 正式版; trial: 体验版; develop: 开发版。 正式版小程序只能拨打给正式版,设置这一字段无效。 | |
| customQuery | string | no | When the receiver opens Weixin Mini Program, it will be spliced to the plug-in page path as a query, formatted asa = 1 & b = 2. Can be accessed within the Receiver Mini Program via thegetPluginOnloadOptionsorgetPluginEnterOptionsinterface |
# Return value
Failure to invoke this interface throws an exception .
# Object
When the interface is called successfully, it returns as follows:
| attribute | type | Introductions | Minimum version |
|---|---|---|---|
| roomId | string | The room number for this call |
# sample code
const wmpfVoip = requirePlugin('wmpf-voip').default
try {
const { roomId } = await wmpfVoip.callWMPF({
roomType: 'video',
sn: '设备 SN',
modelId: '设备 modelId',
nickName: '设备端显示的微信用户名称',
pushToken: 'xxxx*****xxxx',
})
if (/* 当前不在插件页面 */) {
wx.redirectTo({
url: wmpfVoip.CALL_PAGE_PATH,
})
}
} catch (e) {
console.error('callWMPF failed:', e)
wx.showToast({
title: '呼叫失败',
icon: 'error',
})
}