Settings Module SDK

Last Updated on : 2024-10-11 02:16:04download

The @ray-js/wechat-ms-setting SDK integrates capabilities that enable users to subscribe to messages and manage message configurations through the miniapp.

Installation

yarn add @ray-js/wechat-ms-setting

// or

npm install @ray-js/wechat-ms-setting

Query whether WeChat messages are allowed to be pushed

bizTypeConfig

Request parameters

Parameter Type Description Required
device_id string The device ID. true

Response parameters

Parameter Type Description
office_account_fans boolean Indicates whether the WeChat official account is followed.
use_applet_send boolean Indicates whether the miniapp is allowed to push messages.
use_office_account_send boolean Indicates whether the WeChat official account is allowed to push messages.

Sample request

import MsSettingApi from '@ray-js/wechat-ms-setting';

MsSettingApi.bizTypeConfig(device_id)
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

{
  office_account_fans: false;
  use_applet_send: false;
  use_office_account_send: false;
}

Get the list of the WeChat message configurations

msgConfigList

Request parameters

Parameter Type Description Required
device_id string The device ID. true

Response parameters

Parameter Type Description
config_v_o_list ConfigListItem[] The list of the WeChat message configurations.

Description of ConfigListItem

Parameter Type Description
prop_code string The code of the WeChat message configuration.
prop_value string The value of the WeChat message configuration.

Codes of WeChat message configurations

  • LOCK_SEND_REMOTE_APPLY_MSG_SWITCH: Indicates whether to push a message in the event of a remote unlocking request.
  • LOCK_SEND_ALARM_MSG_SWITCH: Indicates whether to push a message in the event of an alert.
  • LOCK_SEND_OPEN_INSIDE_SWITCH: Indicates whether to push a message when the door is unlocked from the inside.
  • LOCK_SEND_OFFLINE_PWD_SWITCH: Indicates whether to push a message when the door is unlocked with a local password.
  • LOCK_SEND_REMOTE_UNLOCK_SWITCH: Indicates whether to push a message when the door is unlocked remotely.
  • LOCK_SEND_FINGER_UNLOCK_SWITCH: Indicates whether to push a message when the door is unlocked with a fingerprint.
  • LOCK_SEND_TEMP_UNLOCK_SWITCH: Indicates whether to push a message when the door is unlocked with a temporary password.
  • LOCK_SEND_CARD_UNLOCK_SWITCH: Indicates whether to push a message when the door is unlocked with a card.
  • LOCK_SEND_FINGER_ALARM_SWITCH: Indicates whether to push a message when the door is unlocked with a fingerprint due to coercion.
  • LOCK_SEND_CLOSE_SWITCH: Indicates whether to push a message when the door is locked.

Sample request

import MsSettingApi from '@ray-js/wechat-ms-setting';

MsSettingApi.msgConfigList(device_id)
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

{
  config_v_o_list: [
    {
      prop_code: "LOCK_SEND_REMOTE_APPLY_MSG_SWITCH"
      prop_value: "true"
    },
    {
      prop_code: "LOCK_SEND_ALARM_MSG_SWITCH"
      prop_value: "true"
    }
  ]
}

Update a WeChat message configuration

msgConfigUpdate

Request parameters

Parameter Type Description Required
device_id string The device ID. true
prop_code string The code of the WeChat message configuration. true
prop_value string The value of the WeChat message configuration. true

Response parameters

Return a boolean value to indicate whether the WeChat message configuration is updated.

Sample request

import MsSettingApi from '@ray-js/wechat-ms-setting';

MsSettingApi.msgConfigUpdate({
  device_id: 'xxxx',
  prop_code: 'LOCK_SEND_TEMP_UNLOCK_SWITCH',
  prop_value: 'true',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => console.log(error));

Sample response

true;

Set callback functions for miniapp message subscriptions

handleMiniProgramSubscribe

Request parameters

Parameter Type Description Required
device_id string The device ID. true
isAppletSend bool Specifies whether to allow the miniapp to push messages. true
success (success) => void The success callback. false
fail (fail) => void The failure callback. false

Sample request

import MsSettingApi from '@ray-js/wechat-ms-setting';

MsSettingApi.handleMiniProgramPush({
  device_id: 'xxxx',
  isAppletSend: true,
  success: success => console.log(success),
  fail: fail => console.log(fail),
});