This interface is asynchronous and returns a
Promiseobject.Supported starting from plugin version 2.4.0.
Initiate a call from Mini Program on the mobile client to the Android device running WMPF. After calling this interface, a VoIP room will be created, and a WMPF pushMsg notification will be pushed to the device. For details, refer to Calling a Device from WeChat Mobile (Android).
This interface can only be used within the WeChat client and cannot be used within WMPF. It is recommended to read the Interface Introduction first.
Parameters
Object req
| Property | Type | Default | Required | Description | Minimum Version |
|---|---|---|---|---|---|
| roomType | string | Yes | Call type. voice: audio call; video: video call | ||
| sn | string | Yes | Device SN of the receiving party | ||
| modelId | string | Yes | Device modelId of the receiving party | ||
| pushToken | string | Yes | The pushToken obtained from the device | ||
| nickName | string | Yes | WeChat user nickname displayed on the device | ||
| deviceName | string | No | Device name displayed on the WeChat side | 2.4.1 | |
| chargeType | string | 'license' | No | Billing method. duration: duration-based billing; license: license-based billing | |
| timeLimit | number | No | Maximum call duration. Must be a number greater than 0 | ||
| enableCallerCamera | boolean | true | No | Whether the caller enables the camera. | |
| enableListenerCamera | boolean | true | No | Whether the receiver enables the camera. | |
| envVersion | string | 'release' | No | The Mini Program version launched by the receiving party. Values: release: Release version; trial: Trial version; develop: Development version. Release version Mini Program can only call other Release versions; setting this field has no effect. |
|
| customQuery | string | No | When the receiving party launches the Mini Program, this value is appended as a query string to the plugin page path, in a format like a=1&b=2. It can be retrieved on the receiving side Mini Program via the getPluginOnloadOptions or getPluginEnterOptions API |
Return Value
This API call will throw an exception if it fails.
Object
If the interface call is successful, the following is returned:
| Attribute | Type | Description | Minimum Version |
|---|---|---|---|
| roomId | string | Room ID for this call |
Sample Code
const wmpfVoip = requirePlugin('wmpf-voip').default
try {
const { roomId } = await wmpfVoip.callWMPF({
roomType: 'video',
sn: 'Device SN',
modelId: 'Device modelId',
nickName: 'WeChat user name displayed on the device',
pushToken: 'xxxx*****xxxx',
})
if (/* Not currently on a plugin page */) {
wx.redirectTo({
url: wmpfVoip.CALL_PAGE_PATH,
})
}
} catch (e) {
console.error('callWMPF failed:', e)
wx.showToast({
title: 'Call failed',
icon: 'error',
})
}