# VoIP Call plugin

This pluginPrimarily used to provideMini Program audio and video calls (for Hardware)Part of the basic capabilities and unified call interface. For a complete access process and development guide, please refer toRelated Documents

Plug-in access can refer to:[Mini Program sample code](https://git.weixin.qq.com /wxa_iot/voip-wxapp-demo )

# 1. Mini Program to introduce plug-ins

Please refer to the Mini Program plug-in for detailsMini Program using plug-in documentation

inMini Program management backgroundAfter adding the plug-in, the user also needs to be in the Mini Program's app.json Declare this plug-in in. Can be introduced in the main package or in the subcontract.

// Main Package Introduction
{
  "plugins": {
    "wmpf-voip":  {
      "version": "latest", // latest Indicates that the latest version is automatically used. Specific versions can also be used, such as 2.3.8
      "provider": "wxf830863afde621eb"
    }
  }
}
// Subcontract introduction
{
  "subpackages": [
    {
      "root": "xxxx",
      "pages": [],
      "plugins": {
        "wmpf-voip":  {
          "version": "latest", // latest Indicates that the latest version is automatically used. Specific versions can also be used, such as 2.3.8
          "provider": "wxf830863afde621eb"
        }
      }
    }
  ]
}

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

const wmpfVoip = requirePlugin('wmpf-voip' ).default
console.log(wmpfVoip) // Results indicate successful introduction of plug-ins

# 2. Plug-in interface

Functionally, the interfaces provided by plug-ins can be divided into the following categories

# 2.1 Initiate a call

In the process of initiating a call, the plug-in is mainly responsible for creating the call room, sending and receiving reminders, and displaying the call page. Can be called on the Mini Program page or the plugin pageinitByCaller Initiate the call.

# 2.2 End call

Usually, the end of the call requires the user to click the action. In some cases, the Mini Program can also call forceHangUpVoip Actively end the current call.

Non-users clicking to end the call may have the following scenarios:

  • The user operates certain buttons on the hardware device to end the call. For example, when the device has a separate handset, the user hangs up the handset.
  • User talk longer than the limit. Suggested Use initByCaller of timeLimit Parameters. The lower version of the plugin can also be based on the calling The event's keepTime Field to calculate the length of the call.

# 2.3 Call Events

Developers can use onVoipEvent Binding call event monitoring for better analysis of 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 client, you can use[wx.getDeviceVoIPList]((wx.getDeviceVoIPList ))Query the currently logged in user consent/Which devices were denied authorization.

On the hardware side, you can use the plug-ingetIotBindContactListInterface queries whether a user authorizes a device.

Recommend the developer when the WeChat user authorizes the device, i.e. wx.requestDeviceVoIP Callback success Later, stored in the background SN and openId。In the Device Side Contacts page, cooperate with getIotBindContactList Interface for authorization validation.

# 2.6 Page Parameters

Small programs can be accessed via plug-insgetPluginEnterOptionsObtainWhen entering the Mini Program from the plugin pageOf the startup parameters.

If the Mini Program gets to the plugin page while in the foreground, you need to usegetPluginOnloadOptionsGet the pluginCall page onLoad timeParameters in the page path.

# 3. Update log

Please refer to theMini Program audio and video call plug-in update log