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

Flutter

PDF
Focus Mode
Font Size
Last updated: 2025-03-20 16:43:48

TencentCloudChatPush

class TencentCloudChatPush: Push Plugin Interface Class.

API overview

Register/Unregister Push Service Interface

API
Description
Register Push Service, optionally override push information from interface parameter JSON.
Unregister Push Service.
RegistrationID is the unique identifier ID of the push receiving device. By default, this ID is automatically generated when the push service is successfully registered, but you can also customize the setting. You can push messages to the specified device based on the RegistrationID. Note that uninstalling and reinstalling the device will change the RegistrationID, so you need to call the setRegistrationID interface before registering the push service.
After successfully registering the push service, you can get the unique identifier ID of the push receiving device, that is, the RegistrationID, by calling the getRegistrationID interface. You can push messages to the specified device based on the RegistrationID.

Push global listening interface

API
Description
Add Push listener.
Remove Push listener.

Custom Configuration Interface

API
Description
Specify offline push to use the FCM channel for the device. This needs to be called before registering the push service.
Disable the notification bar when the app is in the foreground.

Interface Details

Push Plugin Class

TencentCloudChatPush(): Get the TencentCloudChatPush plugin instance, which is a static singleton. Subsequent steps are performed through this singleton instance for method calls.

Member Function Description

registerPush

Register Push Service, to be called after Chat account login is successful.
Sample code:
void _onNotificationClicked({required String ext, String? userID, String? groupID}) {
print("_onNotificationClicked: $ext, userID: $userID, groupID: $groupID");
/// Custom Processing
}
TencentCloudChatPush().registerPush(
onNotificationClicked: _onNotificationClicked,
sdkAppId: Your sdkAppId,
appKey: "client key",
apnsCertificateID: Your configured Certificate ID);
Parameter description:
Parameter
Type
Description

onNotificationClicked
ext
String
The complete ext information carried by the message is specified by the sender. If not specified, there is a default value. You can parse this field to navigate to the corresponding page.
userID
String?
This parameter corresponds to userID. It automatically tries to parse the ext JSON String to obtain the userID of the other party in a single chat.
Note:
If you have not customized the ext field, which is specified by the SDK or UIKit by default, you can use the default parsing here. If the parsing attempt fails, it will be null.
groupID
String?
This parameter corresponds to groupID. It automatically tries to parse the ext JSON String to obtain the groupID information for group chats.
Note:
If you have not customized the ext field, which is specified by the SDK or UIKit by default, you can use the default parsing here. If the parsing attempt fails, it will be null.
sdkAppId
int?
The application ID assigned to you by the Chat console



appKey
String?
Client key assigned to you by the Chat console
apnsCertificateID
int?
This item can be omitted if the setApnsCertificateID method is already configured separately.

unRegisterPush

Unregister offline push service.
Sample code:
TencentCloudChatPush().unRegisterPush();

setRegistrationID

Set the push ID used for registering the offline push service, that is, the RegistrationID, which needs to be called before registering the push service.
Parameter description:
Parameter
Description
registrationID
Device push ID, which will change after uninstalling and reinstalling.
Sample code:
TencentCloudChatPush().setRegistrationID(registrationID: registrationID);

getRegistrationID

After successfully registering for the offline push service, obtain the push ID, that is, the RegistrationID.
Sample code:
TencentCloudChatPush().getRegistrationID();

addPushListener

Add Push listener
Sample code:
TIMPushListener timPushListener = TIMPushListener(
onRecvPushMessage: (TimPushMessage message) {
String messageLog = message.toLogString();
debugPrint(
"message: $messageLog");
},

onRevokePushMessage: (String messageId) {
debugPrint(
"message: $messageId");
},

onNotificationClicked: (String ext) {
debugPrint(
"ext: $ext");
}
);
TencentCloudChatPush.addPushListener(listener: timPushListener);

removePushListener

Remove Push listener
Sample code:
TIMPushListener timPushListener = TIMPushListener(
onRecvPushMessage: (TimPushMessage message) {
String messageLog = message.toLogString();
debugPrint(
"message: $messageLog");
},

onRevokePushMessage: (String messageId) {
debugPrint(
"message: $messageId");
},

onNotificationClicked: (String ext) {
debugPrint(
"ext: $ext");
}
);
TencentCloudChatPush.removePushListener(listener: timPushListener);

forceUseFCMPushChannel

Specify offline push to use the FCM channel for the device. This needs to be called before registering the push service.
Parameter description:
Parameter
Description
enable
true: Use FCM channel.
false: use the native channel.
Sample code:
TencentCloudChatPush.forceUseFCMPushChannel(enable: true);

disablePostNotificationInForeground

Disable notification bar pop-ups when the app is in the foreground. When the Push SDK receives an online Push, it will automatically add a Notification to the notification bar. If you want to handle the online Push messages yourself, you can call this interface to disable the automatic notification bar pop-up feature.
Parameter description:
Parameter
Description
disable
true: disable
false: enable
Sample code:
TencentCloudChatPush.disablePostNotificationInForeground(disable: true);


Help and Support

Was this page helpful?

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

Feedback