Taro.requestSubscribeMessage(option)
Request a subscription message
Type
(option: Option) => Promise<SuccessCallbackResult | FailCallbackResult>
Parameters
Option
| Property | Type | Required | Description |
|---|---|---|---|
| tmplIds | any[] | Yes | The set of ids of the message templates to subscribe to. |
| complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
| fail | (res: any) => void | No | The callback function for a failed API call |
| success | (res: Result) => void | No | The callback function for a successful API call |
FailCallbackResult
| Property | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error message |
SuccessCallbackResult
| Property | Type | Description |
|---|---|---|
| [TEMPLATE_ID] | "accept" | "reject" | "ban" | Dynamic keys, i.e. template ids |
| errMsg | string | Call 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
| Property | Description |
|---|---|
| accept | Indicates that the user agrees to subscribe to the template message corresponding to the id |
| reject | Indicates that the user refuses to subscribe to the template message corresponding to the id |
| ban | Indicates that the user has been blocked by the backend |
Sample Code
Taro.requestSubscribeMessage({
tmplIds: [''],
success: function (res) { }
})
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| Taro.requestSubscribeMessage | ✔️ |