目录

Message Subscription

has.requestSubscribeMessage

has.requestSubscribeMessage(Object object)

Subscribes to messages.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
tmplIds Array<string> Yes IDs of the message templates to be subscribed to. A maximum of three messages can be subscribed to at a time.
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Return value of success

Parameter Type Description
errMsg string 'requestSubscribeMessage:ok' if the API call is successful.
[TEMPLATE_ID:string] string TEMPLATE_ID indicates the template ID. The string can be any of the following: 'accept': The user agrees to subscribe to the message of the specified template. 'reject': The user rejects subscribing to the message of the specified template. 'ban': The template is banned by the background. 'filter': The template is filtered out by the background due to duplicate template titles.

Error codes

Error Code Error Message
101 context is undefined.
102 tmplIds is out of max bounds.
11000801 requestSubscribeMessage error.

Example:

has.requestSubscribeMessage({
  tmplIds: [''],
  success: (res) => {
    console.info('requestSubscribeMessage success', res);
  },
  fail: (err) => {
    console.error('requestSubscribeMessage fail', err);
  },
  complete: (res) => {
    console.info('requestSubscribeMessage complete', res);
  }
});