# wx.requestSubscribeMessage(Object object)
Start from base library version 2.4.4. Please remaining backward compatible.
with Promise style call: Supported
Mini Program plugin: Not supported
Set up the client Mini Program subscription message interface and return the result of user subscription message. When the user has checked "always keep the above options and no longer ask" in the subscription panel, the template message is added to the user s Mini Program settings page by wx.getSetting Interface to get user subscription status for related template messages.
# Note
- One-time template id And permanent templates id Do not use both.
- Low Base Library 2.4.42.8.3 Subscribing to message interface calls is supported, with only one pass in tmplId / permanent tmplId。
- 2.8.2 At the beginning of the version, users click behavior or launch payment callback, you can call up subscription message interface.
- 2.10.0 Template messages will be banned from the development and trial versions of the Mini Program formId。
- In an authorization call, each tmlId corresponding to the template title cannot exist the same, if the same occurs, only one.
- 2.10.0 Support subscription voice message alerts,details
# parameter
# Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
tmplIds | Array | yes | Collection of the id of the message template that you want to subscribe to, up to 3 messages in one call (note: one-time subscriptions after iOS 7.0.6 or Android 7.0.7)/Multiple template messages are supported by long term subscriptions. Prior to iOS 7.0.5 and Android 7.0.6, only one template message was supported by a subscription.[WeChat Official Platform(mp. WeChat.qq.com)- Features - Subscribe Messages]Configuration in. The template title for each tmlId needs to be different or it will be filtered. | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
# object.success callback
# parameter
# Object res
attribute | type | Introductions |
---|---|---|
errMsg | String | The errMsg value is' requestSubscribeMessage: ok' |
&lbrackTEMPLATE_ID: string&rbrack | String | [TEMPLATE_ID]Is a dynamic key, the template id, with values including 'accept', 'reject','ban ', and' filter '. 'accept 'means the user agrees to subscribe to the template message corresponding to the id,' reject 'means that the user refuses to subscribe, 'ban 'means that the template has been blocked in the background, and' filter 'means the template is filtered by the background because the template title has the same name. for example { errMsg: "requestSubscribeMessage:ok", zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: "accept"} Indicates that the user agrees to subscribe zun-LzcQyW, edafCVvz PkK4 de2Rllr1fFp2A_X0oXE this message |
# object.fail callback
# parameter
# Object res
attribute | type | Introductions |
---|---|---|
errMsg | String | Interface call failure error message |
errCode | Number | Interface call failure error code |
# Error code
errCode | errMsg | Introductions |
---|---|---|
10001 | TmplIds can't be empty | Parameter passed empty. |
10002 | Request list fail | Network problem, failed request message list |
10003 | Request subscribe fail | Network problem, failed to send subscription request |
10004 | Invalid template id | Parameter Type Error |
10005 | Cannot show subscribe message UI | Unable to show UI, is generally a Mini Program this time back to the background caused by |
20001 | No template data return, verify the template id exist | No template data, usually templates ID Does not exist Or does not correspond to the template type Cause |
20002 | Templates type must be same | Template Message Type Both one-time and permanent. |
20003 | Templates count out of Max bounds | Number of template messages exceeds limit |
20004 | The main switch is switched off | The user turned off the main switch and could not subscribe |
20005 | This mini program was banned from subscribing messages | Mini Program banned |
# sample code
wx.requestSubscribeMessage({
tmplIds: [''],
success (res) { }
})