tencent cloud

Chat

News and Announcements
Release Notes
Announcements
Product Introduction
Overview
Basic Concepts
Scenarios
Features
Account System
User Profile and Relationship Chain
Message Management
Group Related
Official Account
Audio/Video Call
Use Limits
Purchase Guide
Billing Overview
Pricing
Purchase Instructions
Renewal Guide
Service Suspension Explanation
Refund Policy
Development Guidelines
Demo Zone
Activate Service
Free Demos
Quick Run
Download
SDK and Demo Source Code
Update Log
Chat Interaction (UI Included)
TUIKit Introduction
Getting Started
Full-feature Integration
Single-function Integration
Build with AI
Build Basic Interfaces
More Features
Customizing Appearance
Internationalization
Push Service
Overview
Noun explanation
Activate the Service
Quick Start
Manufacturer Channel
Statistics
Troubleshooting Tool
Client APIs
REST API
Push Callback
Advanced Features
Release Notes
Error Codes
FAQS
Desk
Overview
Quick Start
Integration Guide
Admin Operation Manual
Agent Manual
More Practices
Live Streaming Setup Guide
AI Chatbot
Super Large Entertainment and Collaboration Community
Discord Implementation Guide
How to Integrate Chat into Games
WhatsApp Channel-style Official Account Integration Solution
Send Red Packet
Firewall Restrictions
No UI Integration
Quick Start
SDK Integration
Initialization
Login and Logout
Message
Conversation
Group
Community Topic
User Profile and Relationship Chain
Offline Push
Cloud Search
Local Search
Official Channel Management
Client APIs
JavaScript
Android
iOS & macOS
Swift
Flutter
Electron
Unity
React Native
C APIs
C++
Server APIs
Secure authentication with UserSig
RESTful APIs
Webhooks
Console Guide
New Console Introduction
Creating and Upgrading an Application
Basic Configuration
Feature Configuration
Account Management
Group Management
Official Channel Management
Webhook Configuration
Usage
Viewing Guide for Resource Packages
Real-Time Monitor
Auxiliary Development Tools
Access Management
Advanced Features
FAQs
uni-app FAQs
Purchase
SDK
Account Authentication
User Profile and Relationship Chain
Message
Group
Audio-Video Group
Nickname and Profile Photo
Security Compliance Certification
Service Level Agreement
Security Compliance Certification
Chat Policies
Privacy Policy
Data Privacy and Security Agreement
Migration
Migration Solutions
Migration Solutions Lite
Error Codes
Contact Us

uni-app

PDF
Focus Mode
Font Size
Last updated: 2024-12-30 16:16:11

API Overview

API
Description
registerPush
Register for push service (must be called after the App user agrees to the Privacy Policy to use the push service).
unRegisterPush
Unregister to disable push service.
setRegistrationID
Set Push Device ID.
RegistrationID is the unique identification ID of the push receiving device. By default, this ID is automatically generated when the push service is successfully registered, but you can also set it manually. Note! If you call this API, make sure to call it before registerPush.
Use cases:
If you have integrated both the Chat message service and the Push service on a device, and the user login Chat userID is assumed to be "user123", if you want to push messages to "user123", you need to call this interface to set the device identification ID as follows:
Push.setRegistrationID("user123", () => {});
getRegistrationID
After successfully registering the push service, you can call this interface to obtain the unique identification ID of the push receiving device, which is the RegistrationID.
getNotificationExtInfo
Upon receiving offline push notifications, click the notification bar to pull up the App, and call this interface to get the push extension information.
addPushListener
Add a Push listener.
removePushListener
Remove a Push listener.
disablePostNotificationInForeground
When the app is in the foreground, turn on/off notification bar notifications (default is on).
createNotificationChannel
Create a client notification channel. This API can implement custom ringtone feature on the Android platform.

Interface details

Registering Push Service

API

registerPush(SDKAppID, appKey, onSuccess, onError)

Parameter description:

Parameters
Type
Description
Access Path
SDKAppID
Number
SDKAppID for Push Service Push.



appKey
String
Client key for Push Service Push.
onSuccess
Function
Callback for successful push registration.
-
onError
Function |undefined
Callback for failed push registration.
-

Unregister to disable push service

API

unRegisterPush(onSuccess, onError)

Parameter description:

Parameters
Type
Description
onSuccess
Function
Callback for successful push unregistration.
onError
Function |undefined
Callback for failed push unregistration.

Set push ID identifier RegistrationID

Note:
1. If you call this API, make sure to call it before registerPush.

API

setRegistrationID(registrationID, onSuccess)

Parameter description:

Parameters
Type
Description
registrationID
String
Customized push ID identifier.
onSuccess
Function
Callback after successfully setting the customized push ID identifier.

Get push ID identifier RegistrationID

Note:
1. If you have called the setRegistrationID interface to set the identifier ID, this interface will return the identifier ID you set, otherwise, it will return a random value generated by the Push SDK.

API

getRegistrationID(onSuccess)

Parameter description:

Parameters
Type
Description
onSuccess
Function
Callback for successfully obtaining the push ID.

Getting Push Extension Information

API

getNotificationExtInfo(onSuccess)

Parameter description:

Parameters
Type
Description
onSuccess
Function
Callback for successfully getting the clicked pass-through content.

Adding a Push Listener

API

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

Parameter description:

Parameters
Type
Description
eventName
String
Push Event Type.
listener
Function
Push Event Handling Method.

Removing a Push Listener

API

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

Parameter description:

Parameters
Type
Description
eventName
String
Push Event Type.
listener
Function | undefined
Push Event Handling Method.

Turning On/Off Notification Bar Notifications When the App is in the Foreground

API

disablePostNotificationInForeground(disable: boolean);

Parameter description:

Parameters
Type
Description
disable
boolean
Turning On/Off Notification Bar Notifications When the App is in the Foreground, Default On:
true: Turning off notification bar notifications when the app is in the foreground
false: Turning on notification bar notifications when the app is in the foreground

Creating a Client Notification Channel

API

createNotificationChannel(options: any, listener: (data: any) => void);

Parameter description:

Parameters
Type
Description
options.channelID
String
The ID of the custom channel.
OPPO: The channelID in Console -> Access Configuration.
options.channelName
String
The name of the custom channel.
options.channelDesc
String | undefined
The description of the custom channel.
options.channelSound
String | undefined
The alert tone of the custom channel, audio file name without suffix. The audio file needs to be placed in xxx/nativeResources/android/res/raw.
For example:
options.channelSound = private_ring, which sets xxx/nativeResources/android/res/raw/private_ring.mp3 as the custom alert tone.
listener
Function
Callback function for successful API invocation.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback