The package name of this plugin on pub.dev is: 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
Step 2: Push Parameter Configuration
iOS
Android
Please upload the iOS APNs push certificate you obtained in the manufacturer configuration step to the IM console.
The IM console will allocate a Certificate ID for you, see the image below:
To register for push notifications, you need to pass in this Certificate ID (apnsCertificateID):
After completing the console manufacturer push information, download and add the configuration file to the project. Add the downloaded timpush-configs.json file to the 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
Step 3: Client Code Configuration
In this step, you will need to write some native code, such as Swift, Java, XML, etc.
Please do not worry. Just follow the instructions and copy the provided code into the specified file.
iOS
Android
You can edit using Xcode, or directly in Visual Studio Code or Android Studio.
Open the ios/Runner/AppDelegate.swift file, paste the highlighted code as shown in the image below. The code is attached after the image.
1. For the iOS console, please set the certificate ID to use businessID. The offlinePushCertificateID is deprecated.
2. The old field offlinePushCertificateID is still supported, but you need to add the @objc keyword.
It is recommended to use Android Studio to complete this part of the editing.
In the android path of your project, create a new Application class file at the same directory level as MainActivity, for example, you can name it MyApplication.java.
If you have already customized an Application class, you can directly reuse it without creating a new one.
Paste the following code into the file as shown above:
Replace the packagewithyourown. Generally,AndroidStudio will generate it automatically;
If you have already created your own Application for other purposes, directly extend TencentCloudChatPushApplication and ensure that the onCreate() function calls super.onCreate();.
Open the 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:
Step 4: Client Manufacturer Configuration
iOS
Android
This step is not required for iOS.
Open the android/app/build.gradle file and add the dependencies configuration at the end. According to your needs, introduce all or some of the following manufacturer push packages. The native push capability of a manufacturer is enabled only after the corresponding manufacturer’s push package is introduced.
dependencies {
// The version number "VERSION" can be obtained from the Update Log.
According to Vivo and Honor manufacturer access guidelines, the APPID and APPKEY need to be added to the manifest file.
Method 1
Method 2
// android/app/build.gradle
android {
...
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
Huawei, HONOR, and Google FCM Adaptation
Follow the vendor method to integrate the corresponding plugin and JSON configuration file.
Note:
The following adaptation for HONOR only requires configuration for version 7.7.5283 and above.
1.1 Download the configuration file and place it under the root directory/Android/app of the project.
Huawei
HONOR
Google FCM
Operation Path
1.2 Add the following configuration under buildscript -> dependencies in your project-level build.gradle file:
For Gradle version 7.1 and above
Gradle version 7.0
Versions Below Gradle 7.0
Add the following configuration under buildscript -> dependencies in your project-level build.gradle file:
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'
}
}
Add the following repository configuration under buildscript -> repositories and allprojects -> repositories in your project-level settings.gradle file:
Please define a function to receive the push message click callback event.
Define the function with the parameter format {required String ext, String? userID, String? groupID}.
Among them, the ext field carries the complete ext information specified by the sender. If not specified, there is a default value. You can parse this field to navigate to the corresponding page.
The userID and groupID fields are automatically parsed by the plugin from the ext Json String to get the single chat userID and group chat groupID information. If you do not customize the ext field, the ext field is specified by the SDK or UIKit by default, and you can use this default parsing. If parsing fails, it will be null.
You can define a function to receive this callback and use it to navigate to the corresponding Session Page or your Business Page.
Huawei Push Certificate ID <= 11344, using Huawei Push v2 interface, does not support Reach and Click Receipt, please regenerate and update Certificate ID.
After turning on the receipt toggle, please make sure the receipt address is correctly configured. Not configuring it or configuring the wrong address will affect the push notification feature.
No configuration needed for other supported manufacturers. FCM currently does not support push notification statistics feature.
Congratulations! You have completed the integration of the push plugin. Please be reminded: After the trial period or subscription expires, the push service (including regular message offline push, all-staff/Tag push, etc.) will automatically cease. To avoid affecting the normal use of your services, please make sure to purchase/renew in advance.