tencent_cloud_chat_push
, you can introduce it into the pubspec.yaml dependency directory, or you can execute the following command to install it automatically.flutter pub addtencent_cloud_chat_push
TencentCloudChatPush().registerPush(apnsCertificateID: Your configured Certificate ID);
android/app/src/main/assets
directory of the project. If the directory does not exist, please create it manually.1.Choose to download the configuration file timpush-configs.json | 2.Add to the project |
![]() | ![]() |
ios/Runner/AppDelegate.swift
file, paste the highlighted code as shown in the image below. The code is attached after the image.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)}// To be deprecated,please use the new field businessID below.@objc func offlinePushCertificateID() -> Int32 {return TencentCloudChatPushFlutterModal.shared.offlinePushCertificateID();}// Add this function@objc func businessID() -> Int32 {return TencentCloudChatPushFlutterModal.shared.businessID();}// Add this function@objc func applicationGroupID() -> String {return TencentCloudChatPushFlutterModal.shared.applicationGroupID()}// Add this function@objc func onRemoteNotificationReceived(_ notice: String?) -> Bool {TencentCloudChatPushPlugin.shared.tryNotifyDartOnNotificationClickEvent(notice)return true}}
MainActivity
, for example, you can name it MyApplication.java
.Replace the package with your own. Generally, Android Studio will generate it automatically;import com.tencent.chat.flutter.push.tencent_cloud_chat_push.application.TencentCloudChatPushApplication;public class MyApplication extends TencentCloudChatPushApplication {@Overridepublic void onCreate() {super.onCreate();}}
extend TencentCloudChatPushApplication
and ensure that the onCreate()
function calls super.onCreate();
.android/app/src/main/AndroidManifest.xml
file and add an <application>
tag to specify an android:name
parameter, pointing to the custom Application
class you just created. As shown in the figure:dependencies {// Huaweiimplementation 'com.tencent.timpush:huawei:VERSION'// XiaoMiimplementation 'com.tencent.timpush:xiaomi:VERSION'// OPPOimplementation 'com.tencent.timpush:oppo:VERSION'// vivoimplementation 'com.tencent.timpush:vivo:VERSION'// Honorimplementation 'com.tencent.timpush:honor:VERSION'// Meizuimplementation 'com.tencent.timpush:meizu:VERSION'// Google Firebase Cloud Messaging (Google FCM)implementation 'com.tencent.timpush:fcm:VERSION'}
// 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'}}
pluginManagement {repositories {gradlePluginPortal()mavenCentral()maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" }// Configure the Maven repository address for HMS Core SDK.maven {url 'https://developer.huawei.com/repo/'}maven {url 'https://developer.hihonor.com/repo'}}}dependencyResolutionManagement {...repositories {mavenCentral()maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" }// Configure the Maven repository address for HMS Core SDK.maven {url 'https://developer.huawei.com/repo/'}maven {url 'https://developer.hihonor.com/repo'}}}}
buildscript {repositories {mavenCentral()maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" }// Configure the Maven repository address for HMS Core SDK.maven {url 'https://developer.huawei.com/repo/'}maven {url 'https://developer.hihonor.com/repo'}}dependencies {...classpath 'com.google.gms:google-services:4.2.0'classpath 'com.huawei.agconnect:agcp:1.4.1.300'classpath 'com.hihonor.mcs:asplugin:2.0.1.300'}}
allprojects {...repositories {mavenCentral()maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" }// Configure the Maven repository address for HMS Core SDK.maven {url 'https://developer.huawei.com/repo/'}maven {url 'https://developer.hihonor.com/repo'}}}
buildscript {repositories {mavenCentral()maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" }// Configure the Maven repository address for HMS Core SDK.maven {url 'https://developer.huawei.com/repo/'}maven {url 'https://developer.hihonor.com/repo'}}dependencies {...classpath 'com.google.gms:google-services:4.2.0'classpath 'com.huawei.agconnect:agcp:1.4.1.300'classpath 'com.hihonor.mcs:asplugin:2.0.1.300'}}allprojects {repositories {mavenCentral()maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" }// Configure the Maven repository address for HMS Core SDK.maven {url 'https://developer.huawei.com/repo/'}maven {url 'https://developer.hihonor.com/repo'}}}
apply plugin: 'com.google.gms.google-services'apply plugin: 'com.huawei.agconnect'apply plugin: 'com.hihonor.mcs.asplugin'
TIMPushListener timPushListener = TIMPushListener(onNotificationClicked: (String ext) {debugPrint("ext: $ext");// Getting ext for Definition redirect});tencentCloudChatPush.addPushListener(listener: timPushListener);
{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) {// Redirect to the corresponding Message page based on userID or groupID.} else {// Based on the ext field, write your own parsing method to redirect to the corresponding page.}}
TencentCloudChatPush().registerPush
method, you can receive offline push notifications.TencentCloudChatPush().registerPush(onNotificationClicked: _onNotificationClicked,sdkAppId: Your sdkAppId,appKey: "client key",apnsCertificateID: Your configured Certificate ID);
Callback Address Configuration | Configure Receipt ID in the IM Console |
![]() Receipt Address: Singapore :https://apisgp.im.qcloud.com/v3/offline_push_report/vivo Korea: https://apikr.im.qcloud.com/v3/offline_push_report/vivo USA: https://apiusa.im.qcloud.com/v3/offline_push_report/vivo Germany: https://apiger.im.qcloud.com/v3/offline_push_report/vivo Indonesia: https://apiidn.im.qcloud.com/v3/offline_push_report/vivo China: https://api.im.qcloud.com/v3/offline_push_report/vivo | ![]() |
Enable Receipt Switch | Configure Receipt Address |
![]() | ![]() |
Was this page helpful?