tencent_cloud_chat_push
on pub.dev. You can include it in your pubspec.yaml dependency directory, or run the following command for automatic installation.flutter pub addtencent_cloud_chat_push
TencentCloudChatPush().setApnsCertificateID
method to pass in the certificate ID.TencentCloudChatPush().setApnsCertificateID(apnsCertificateID: Certificate ID);
android/app/src/main/assets
directory. If the directory does not exist, please create it manually.1. Choose to download the configuration file timpush-configs.json | 1. Add to the project |
![]() | ![]() |
ios/Runner/AppDelegate.swift
file, paste the following outlined code into it, as shown in the figure. The code is attached after the picture.import UIKitimport Flutter// Add these two import linesimport TIMPushimport tencent_cloud_chat_push// Add `, TIMPushDelegate` to the following line@UIApplicationMain@objc class AppDelegate: FlutterAppDelegate, TIMPushDelegate {override func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {GeneratedPluginRegistrant.register(with: self)return super.application(application, didFinishLaunchingWithOptions: launchOptions)}// Add this functionfunc offlinePushCertificateID() -> Int32 {return TencentCloudChatPushFlutterModal.shared.offlinePushCertificateID();}// Add this functionfunc applicationGroupID() -> String {return TencentCloudChatPushFlutterModal.shared.applicationGroupID()}// Add this functionfunc onRemoteNotificationReceived(_ notice: String?) -> Bool {TencentCloudChatPushPlugin.shared.tryNotifyDartOnNotificationClickEvent(notice)return true}}
MainActivity
under your project's Android path, create a new Application file class, for example, it can be named MyApplication.java
.Replace 'package' with your own, usually Android Studio will generate it automatically; import com.tencent.chat.flutter.push.tencent_cloud_chat_push.application.TencentCloudChatPushApplication; public class MyApplication extends TencentCloudChatPushApplication { @Override public void onCreate() { super.onCreate(); } }
extend TencentCloudChatPushApplication
and ensure in the onCreate()
function, you call super.onCreate();
.android/app/src/main/AndroidManifest.xml
file, add a specified android:name
parameter for the <application>
tag, pointing to the newly made custom Application
class. As shown in the figure:dependencies { // Huaweiimplementation 'com.tencent.timpush:huawei:${Push Plugin version number}'// XiaoMiimplementation 'com.tencent.timpush:xiaomi:${Push Plugin version number}'// vivoimplementation 'com.tencent.timpush:vivo:${Push Plugin version number}'// Honorimplementation 'com.tencent.timpush:honor:${Push Plugin version number}'// Meizuimplementation 'com.tencent.timpush:meizu:${Push Plugin version number}'// Google Firebase Cloud Messaging (Google FCM)implementation 'com.tencent.timpush:fcm:${Push Plugin version number}'// Choose one of the two below for OPPO// For the China Region, choose to integrate this packageimplementation 'com.tencent.timpush:oppo:${Push Plugin version number}'// For other regions, choose to integrate this packageimplementation 'com.tencent.timpush:oppo-intl:${Push Plugin version number}' }
// android/app/build.gradleandroid {...defaultConfig {...manifestPlaceholders = ["VIVO_APPKEY" : "`APPKEY` of the certificate assigned to your application","VIVO_APPID" : "`APPID` of the certificate assigned to your application","HONOR_APPID" : "`APPID` of the certificate assigned to your application"]}}
// android/app/src/main/AndroidManifest.xml// Vivo begin<meta-data tools:replace="android:value"android:name="com.vivo.push.api_key"android:value="`APPKEY` of the certificate assigned to your application" /><meta-data tools:replace="android:value"android:name="com.vivo.push.app_id"android:value="`APPID` of the certificate assigned to your application" />// Vivo end// Honor begin<meta-data tools:replace="android:value"android:name="com.hihonor.push.app_id"android:value="`APPID` of the certificate assigned to your application" />// Honor end
buildscript {dependencies {...classpath 'com.huawei.agconnect:agcp:1.6.0.300' classpath 'com.hihonor.mcs:asplugin:2.0.1.300' classpath 'com.google.gms:google-services:4.4.0'}}
pluginManagementbuildscript {repositories {gradlePluginPortal() mavenCentral() maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" } // Configure the Maven repository address for the HMS Core SDK.
{required String ext, String? userID, String? groupID}
.void _onNotificationClicked({required String ext, String? userID, String? groupID}) { print("_onNotificationClicked: $ext, userID: $userID, groupID: $groupID"); if (userID != null || groupID != null) { // Navigate to the corresponding Message Page based on userID or groupID. } else { // Write your own parsing method based on the ext Field and navigate to the corresponding page. } }
TencentCloudChatPush().registerPush
method, passing in a callback function defined for clicks.apnsCertificateID
for the iOS push certificate ID and androidPushOEMConfig
for the Android push vendor configuration. These two configurations should have been specified in previous steps, and if no modification is necessary, they do not need to be passed again.TencentCloudChatPush().registerPush(onNotificationClicked: _onNotificationClicked);
TencentCloudChatPush().registerPush
and place it as early as possible in the code.TencentCloudChatPush().registerOnNotificationClickedEvent(onNotificationClicked: _onNotificationClicked);
https://api.im.qcloud.com/v3/offline_push_report/huawei
https://api.im.qcloud.com/v3/offline_push_report/honor
Callback Address Configuration | Receipt ID Configuration in the IM Console |
![]() Receipt Address: https://api.im.qcloud.com/v3/offline_push_report/vivo | ![]() |
Enable Receipt Switch | Configure Receipt Address |
![]() | ![]() |
https://api.im.qcloud.com/v3/offline_push_report/meizu
Was this page helpful?