# VoIP Calling Plugin

This plug-in is mainly used to provide "Weixin Mini Program audio and video calling (for hardware)" part of the basic capabilities and unified call interface.For a complete access process and development guide, please refer to related documentation .

Plug-in access can refer to: Weixin Mini Program sample code

# 1. Weixin Mini Program Introduction of plug-ins

About Weixin Mini Program Plug-in Please refer to the Plug-in documentation

After adding a plug-in to the "Weixin Mini Program" admin background, the user also needs to declare the plug-in in the apagejson`of the Mini Program.It can be introduced in a master package or in a sub-package.

// The main package was introduced
{
  "plugins": {
    "wmpf-voip": {
      "version": "latest", // latest 表示自动使用最新版本。也可使用具体版本,如 2.3.8
      "provider": "wxf830863afde621eb"
    }
  }
}
// Subcontracting introduced
{
  "subpackages": [
    {
      "root": "xxxx",
      "pages": [],
      "plugins": {
        "wmpf-voip": {
          "version": "latest", // latest 表示自动使用最新版本。也可使用具体版本,如 2.3.8
          "provider": "wxf830863afde621eb"
        }
      }
    }
  ]
}

After the declaration is complete, you can confirm whether the introduction was successful in Weixin Mini Program

const wmpfVoip = requirePlugin('wmpf-voip').default
console.log(wmpfVoip) // 有结果即表示引入插件成功

# 2. Plug-in Interface

Functionally, the interface provided by the plug-in can be divided into the following categories

# 2.1 Start a call

In initiating a call, the plug-in is primarily responsible for the call room creation, the receipt reminder, and the display of the call page. initByCaller can be called from the Weixin Mini Program page or from the plugin pageStart a call.

# 2.2 End the call

Typically, the end of a call requires the user to click an action.In some scenarios, Weixin Mini Program can also call forceHangUpVoip Proactively end the current call.

There may be the following scenarios when a non-user clicks to end a call:

  • The user controls certain buttons on the hardware device to end the call. For example, when the device has a separate phone receiver, the user hangs the receiver.
  • The duration of a user's call exceeded the limit.initByCaller``timeLimitparameter is recommended.The plug-in version can also calculate the call duration based on thecallingevent'skeepTimefield.

# 2.3 Call incident

Developers can use onVoipEvent Bind the listening of call events to better analyze the call process.

# 2.4 Custom settings

The plug-in provides the following interfaces to set up the call process and interface

# 2.5 Authorization query

Within the WeChat Guest Account, wx.getDeviceVoIPList Query which devices the currently logged in user has agreed to / refused to authorize.

On the hardware side, you can use plug-ins getIotBindContactList The interface queries whether a user has authorized a device.

It is recommended that developers store the SN and openId in the background when WeChat user authorizes the device, that is, afterwx.requestDeviceVoIPcallback success.In the device side link page, with thegetIotBindContactListinterface for authorization verification.

# 2.6 Page parameters

Weixin Mini Program can be accessed via plug-ins getPluginEnterOptions Gets the boot parameter of when enters the Mini Program from the plug-in page.

If Weixin Mini Program enters the plug-in page in the foreground, you need to use getPluginOnloadOptions Gets the parameters in the** page path when the plug-in **calls page onLoad.

# 3. Update the log

Please refer to < Weixin Mini Program AV Call Plug-in Changelog >