SendPushMessage
Workflow#
- The mini app calls the js api
bn.requestSubscribeMessage({tmplIds: $template\_ids})
to the mini program framework, the later will popup a authorization page for the user to approve, and return the $template_ids and $push_tokens if the user approves - The mini app uploads the $template_ids and $push_tokens to the merchant’s backend
- The backend calls the sendPushMessage with the $push_tokens and other parameters , and sends the message to the user.
You can get all the required APIs in the reference.
Requirements:
Binance APP >=2.52.0
SDK >= 3.13.0
Preparation#
Please refer to Preparation Of Open Service
Mini Program#
On the mini program, the developer can call the js api: bn.requestSubscribeMessage()
to pop-up an authorization page for the user. After getting the user’s approval, the api will return the $template_ids and their $push_tokens, which can be used to push messages to users on the backend.
Backend#
SendPushMessage#
Host: dip-cb.binanceapi.com
POST /mp-api/v1/apps/{appId}/message/send
Parameters
Parameter | Description |
---|---|
appId | required appId of the mini program |
pushToken | required push_token from previous steps |
templateId | required templateId of the template |
language | required language of the message |
path | optional pages path when user clicks the message, the path to the entry page by default |
parameters | required arrays of parameters to the template,[{“name”:string, “value”:string }] |
Note:
1. pushToken Only valid for seven days
2. One pushToken only can be used once
3. You need to call this api by carrying a jwt token in the header X-Mp-Open-Api-Token
. For the method of generating JWT token, please refer to Description of External Interface Signature Authentication Algorithm
Request
Response
HTTP 200
Code
ErrorCode | Remark |
---|---|
000000 | Success |
900001 | Invalid Param |
900002 | Jwt auth failed |
900003 | Unexpected error |
900230 | Invalid pushToken or pushToken expired |
900231 | Rate limit |
statusCode
statusCode | Remark |
---|---|
000000 | Success |
900240 | The user refuses to receive all messages from the mini-program |
900241 | The user refuses to receive the message corresponding to the mini-program template |