Full Flow
Notification Flow
Send inbox notifications to SuperQi users
This guide walks you through sending inbox notifications to SuperQi users. Before implementing notifications, ensure you have completed the authentication flow with the proper scope to obtain the user's access token.
Overview
To send notifications to users, you need:
- Frontend: Request authorization with
NOTIFICATION_INBOXscope - Backend: Use the access token to send inbox messages
Important: The user's access token must include the
NOTIFICATION_INBOX scope to send notifications.Step 1: Frontend - Request Notification Permission
Auth Scope Requirement
When requesting user authorization, include the NOTIFICATION_INBOX scope:
my.getAuthCode({
scopes: [
"auth_base",
"NOTIFICATION_INBOX", // Required for sending notifications
],
success: (res) => {
// Send res.authCode to your backend to exchange for access token
console.log("Authorization Code:", res.authCode);
// TODO: Implement your backend API call here
},
fail: (res) => {
// Handle authorization failure
console.error("Authorization failed:", res);
// TODO: Implement your error handling here
},
});
For a complete list of available scopes, see the Frontend Documentation.
Step 2: Backend - Send Inbox Message
API Endpoint
URL: POST /v1/messages/sendInbox
Request Body
{
"accessToken": "2019112719074101000700000077771xxxx",
"requestId": "20191127190741010007013213123xxxx",
"templateCode": "MINI_APP_COMMON_INBOX",
"templates": [
{
"templateParameters": {
"Title": "Notification Title",
"Content": "Your notification message content here",
"Url": "mini://platformapi/startapp?_ariver_appid=888888"
}
}
]
}
Request Parameters
accessToken (String, Required)
- The access token obtained from the authentication flow
- Must include
NOTIFICATION_INBOXscope - Max length: 128 characters
requestId (String, Required)
- Unique ID to identify the request
- Used for idempotence - same requestId will only send message once
- Max length: 128 characters
templateCode (String, Required)
- Template code for the notification format
- Use:
"MINI_APP_COMMON_INBOX" - Max length: 256 characters
templates (Array, Required)
- Array of content templates for the inbox message
templateParameters:Title: Notification title displayed to userContent: Main notification message contentUrl: Deep link URL generated by the mini program platform
Expected Response
{
"messageId": "20201235900212xxxx",
"extendInfo": "",
"result": {
"resultCode": "SUCCESS",
"resultStatus": "S",
"resultMessage": "success"
}
}
Response Status
| resultStatus | Description | Action |
|---|---|---|
S | Success - Message sent successfully | Continue normal flow |
A | Accepted - Request accepted by wallet | Message is being processed |
U | Unknown - Unknown exception occurred | Retry the request |
F | Failed - Message sending failed | Check error code and message |
Common Error Codes
Notification-Specific Errors
| resultCode | resultMessage | Solution |
|---|---|---|
ACCESS_TOKEN_NOT_COVER_THE_SCOPE | The access token permission scope does not contain specified scope | Ensure NOTIFICATION_INBOX scope was included during authentication |
INVALID_ACCESS_TOKEN | The access token is invalid | Refresh the token or restart OAuth flow |
Notification Flow Sequence
- Frontend: Request authorization with
NOTIFICATION_INBOXscope - User: Confirms authorization in SuperQi app
- Backend: Exchange auth code for access token (with notification scope)
- Backend: Send inbox message using access token
- SuperQi: Delivers notification to user's inbox
- User: Receives notification in SuperQi app
Best Practices
Message Content Guidelines
- Keep titles concise and descriptive
- Provide clear, actionable content
- Use deep links to direct users to relevant app sections ::
Request ID Management
- Use unique
requestIdfor each notification - Same
requestIdwill prevent duplicate messages - Store request IDs to avoid accidental duplicates ::
Scope Validation
- Always verify the access token includes
NOTIFICATION_INBOXscope - Handle
ACCESS_TOKEN_NOT_COVER_THE_SCOPEerrors gracefully - Request proper scope during initial authentication ::
Additional Resources
- Authentication Flow: Complete Authentication Guide
- Frontend Scopes: Frontend Documentation
- Backend Implementation: Backend Documentation
- API Reference: SendInbox API Documentation