tencent cloud

Chat

문서ChatPush ServiceClient APIsMini Program Multi-platform Framework

Mini Program Multi-platform Framework

다운로드
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-09-21 16:13:02
AI 번역

API overview

API
Description
setRegistrationID
Sets the push ID used for registration (RegistrationID). Call this before registering the push service.
getRegistrationID
Gets the push ID (RegistrationID) after the push service is registered successfully.
registerPush
Registers the push service (call this API only after the app user has agreed to the privacy policy and you are ready to provide push for the user).
unRegisterPush
Unregisters and disables the push service.
addPushListener
Subscribes to push events, such as notification click events.
removePushListener
Unsubscribes from push events.
disablePostNotificationInForeground
Enable or disable notification bar alerts when the app is in the foreground (enabled by default).
createNotificationChannel
Creates a client notification channel. This API can be used to implement a custom ringtone.
setCustomBadgeNumber
Sets the app badge number (Huawei and iOS only).

API details

Register the push service

Note:
Call this API to use the push service only after the app user has agreed to the privacy policy and you are ready to provide push for the user. Calling it earlier may access user privacy prematurely and cause app store rejection.

API

registerPush(sdkAppID: number, appKey: string): Promise<JSON>;

Parameters

Parameter
Type
Description
sdkAppID
number
SDKAppID of the Push app.
appKey
string
Client key of the Push app.

Return value

Return value
Description
Promise
On success: {"errCode":0,"errMsg":"success","data":{"token":"xxx"}}. On failure: { errCode: number, errMsg: string }.

Unregister and disable the push service

API

unRegisterPush(): Promise<JSON>;

Return value

Return value
Description
Promise
On success: {"errCode":0,"errMsg":"success"}. On failure: { errCode: number, errMsg: string }.

Set push ID (RegistrationID)

Note:
Call this before registering the push service.

API

setRegistrationID(registrationID: string): Promise<JSON>;

Parameters

Parameter
Type
Required
Description
registrationID
string
Yes
Device push ID. Changes after uninstall and reinstall.

Return value

Return value
Description
Promise
On success: {"errCode":0,"errMsg":"success"}. On failure: { errCode: number, errMsg: string }.

Get push ID (RegistrationID)

Note:
Call this after the push service is registered successfully.

API

getRegistrationID(): Promise<JSON>;

Return value

Return value
Description
Promise
On success: {"errCode":0,"errMsg":"success","data":{"registrationID":"xxx"}}. On failure: { errCode: number, errMsg: string }.

Subscribe to push events (such as notification click)

API

addPushListener(eventName: string, listener: (res: any) => void): void;

Parameters

Parameter
Type
Required
Description
eventName
string
Yes
Push event type. See Push.EventName.
listener
(res: any) => void
Yes
Push event handler.

Unsubscribe from push events

API

removePushListener(eventName: string, listener: (res: any) => void): void;

Parameters

Parameter
Type
Required
Description
eventName
string
Yes
Push event type. See Push.EventName.
listener
(res: any) => void
Yes
Push event handler.

Enable/disable notification bar alerts in foreground

API

disablePostNotificationInForeground(disable: boolean): void;

Parameters

Parameter
Type
Required
Description
disable
boolean
Yes
Enable or disable notification bar alerts when the app is in the foreground (enabled by default):
true: hide notification bar alerts when the app is in the foreground.
false: show notification bar alerts when the app is in the foreground.

Create a client notification channel

Note:
If ChannelIDs differ across manufacturers, create a channel for each one.

API

createNotificationChannel(options: {
channelID: string;
channelName: string;
channelDesc?: string;
channelSound?: string;
}): Promise<JSON>;

Parameters

Parameter
Type
Required
Description
options.channelID
String
Yes
Custom channel ID.
options.channelName
String
Yes
Custom channel name.
options.channelDesc
String
No
Custom channel description.
options.channelSound
String
No
Audio file name of the custom channel ringtone, without the file extension. Place the audio file under xxx/android/nativeResources/res/raw.
Example: options.channelSound = private_ring sets xxx/android/nativeResources/res/raw/private_ring.mp3 as the custom ringtone.

Return value

Return value
Description
Promise
On success: {"errCode":0,"errMsg":"success"}. On failure: { errCode: number, errMsg: string }.

Set the app badge number

Note:
Call this after registering the push service.
Supported only on Huawei and iOS.

API

setCustomBadgeNumber(badgeNumber: number): Promise<JSON>;

Parameters

Parameter
Type
Required
Description
badgeNumber
number
Yes
App badge number.

Return value

Return value
Description
Promise
On success: {"errCode":0,"errMsg":"success"}. On failure: { errCode: number, errMsg: string }.


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백