Skip to main content
Version: 3.x

Taro.requestSubscribeMessage(option)

Request a subscription message

Reference

Type

(option: Option) => Promise<SuccessCallbackResult | FailCallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
tmplIdsany[]YesThe set of ids of the message templates to subscribe to.
complete(res: any) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: any) => voidNoThe callback function for a failed API call
success(res: Result) => voidNoThe callback function for a successful API call

FailCallbackResult

PropertyTypeDescription
errCodenumberError code
errMsgstringError message

SuccessCallbackResult

PropertyTypeDescription
[TEMPLATE_ID]"accept" | "reject" | "ban"Dynamic keys, i.e. template ids
errMsgstringCall result

Sample Code

Indicates that the user agrees to subscribe to the message zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE

{
"errMsg": "requestSubscribeMessage:ok",
"zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE": "accept"
}

template_reflex

Template message subscription types

PropertyDescription
acceptIndicates that the user agrees to subscribe to the template message corresponding to the id
rejectIndicates that the user refuses to subscribe to the template message corresponding to the id
banIndicates that the user has been blocked by the backend

Sample Code

Taro.requestSubscribeMessage({
tmplIds: [''],
success: function (res) { }
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.requestSubscribeMessage✔️