Flutter
TencentCloudChatPush
class TencentCloudChatPush: Push Plugin Interface Class.
API Overview
Register/Unregister Push Service Interface
After initialization and successful log in to IM, you can register for the push service.
API | Description |
registerOnNotificationClickedEvent | Register message click callback in advance. |
registerPush | Register Push Service, optionally override the push message from interface parameter json. |
unRegisterPush | Unregister the offline push service when logging out of the IM account. |
FCM Custom Ringtone Configuration Interface
Once configured, the custom ringtone is effective. The sender must include the channelId in the offline message.
API | Description |
configFCMPrivateRing | To configure the custom ringtone for FCM, it needs to be called before registering for the push service. |
Special Configuration Interface for Push Channel
API | Description |
setPushBrandId | To specify the vendor channel type for device offline push, it needs to be called before registering for the push service. |
getPushBrandId | Obtain the vendor channel type currently in use for device offline push. |
checkPushStatus | After completing the access configuration for each vendor, you can use this interface to test the push status on the corresponding vendor devices. |
setApnsCertificateID | Configure the push certificate ID for APNs separately. |
setApplicationGroupID | Configure the Application Group ID for the iOS project. |
getAndroidPushToken | Retrieve Android device manufacturer Token. |
setAndroidPushToken | Manually specify the Android device manufacturer Token. |
setAndroidCustomTIMPushConfigs | Manually replace the default push configuration file timpush-configs.json read by the plugin with a self-defined one. This needs to be invoked before registering the push service. |
Interface details
Push Plugin Class
TencentCloudChatPush(): Retrieves the TencentCloudChatPush push plugin instance, which is a Static Singleton. All subsequent steps will invoke methods through this singleton instance.
Member Function Description
registerOnNotificationClickedEvent
Configure Message Click Callback Function.
You can call or adjust the callback function dynamically as needed, or directly pass it during
registerPush
.Sample Code:
void _onNotificationClicked({required String ext, String? userID, String? groupID}) { print("_onNotificationClicked: $ext, userID: $userID, groupID: $groupID"); /// Custom processing } TencentCloudChatPush().registerOnNotificationClickedEvent(onNotificationClicked: _onNotificationClicked);
Parameter Description:
Parameter | Type | Description | |
onNotificationClicked | ext | String | This is the complete ext information carried by the message, specified by the sender. If not specified, a default value is used. You can navigate to the corresponding page by resolving this field. |
| userID | String? | This parameter corresponds to userID, automatically attempts to parse the ext Json String, to retrieve the One-on-one Chat counterpart's userID within. Note: If you have not defined the ext field yourself, and it is set by default by the SDK or UIKit, you can use the default parsing here. If the attempt to parse fails, it will be null empty. |
| groupID | String? | This parameter corresponds to groupID, automatically attempts to parse the ext Json String, to retrieve the Group Chat groupID information within. Note: If you have not defined the ext field yourself, and it is set by default by the SDK or UIKit, you can use the default parsing here. If the attempt to parse fails, it will be null empty. |
registerPush
Register the offline push service, call after the IM account logs in successfully.
Sample Code:
TencentCloudChatPush().registerPush( onNotificationClicked: _onNotificationClicked, androidPushOEMConfig: "can be left null", apnsCertificateID: 0, );
Parameter Description:
Parameter | Type | Description | |
onNotificationClicked | ext | String | This is the complete ext information carried by the message, specified by the sender. If not specified, a default value is used. You can navigate to the corresponding page by resolving this field. |
| userID | String? | This parameter corresponds to userID, automatically attempts to parse the ext Json String, to retrieve the One-on-one Chat counterpart's userID within. Note: If you have not defined the ext field yourself, and it is set by default by the SDK or UIKit, you can use the default parsing here. If the attempt to parse fails, it will be null empty. |
| groupID | String? | This parameter corresponds to groupID, automatically attempts to parse the ext Json String, to retrieve the Group Chat groupID information within. Note: If you have not defined the ext field yourself, and it is set by default by the SDK or UIKit, you can use the default parsing here. If the attempt to parse fails, it will be null empty. |
androidPushOEMConfig | | String | If the timpush-configs.json configuration file has been imported, then this item can be left blank. The purpose of this item is to override the parameters in the json file, or to use it when the json file cannot be found
Optional Android-side parameters json:
|
apnsCertificateID | | int | If setApnsCertificateID method has already been called separately, this item can be omitted. |
unRegisterPush
Unregister the offline push service, to be called after the IM account logs out.
Sample Code:
TencentCloudChatPush().unRegisterPush();
configFCMPrivateRing
To configure the custom ringtone for FCM, it needs to be called before registering for the push service.
Sample Code:
TencentCloudChatPush().configFCMPrivateRing(channelId: channelId, ringName: ringName, enable: enable);
Parameter Description:
Parameter Name | Type | Description |
channelId | String | FCM channel custom notification bar's channel ID, unique within the app. |
ringName | String | FCM channel's custom push ringtone name, located in the raw directory and does not require a file suffix. |
enable | bool | Setting whether the offline push prompt ringtone uses a custom ringtone. |
Note:
Once configured, the custom ringtone is effective. The sender must include the channelId in the offline message.
setPushBrandId
To specify the vendor channel type for device offline push, it needs to be called before registering for the push service.
Note:
This interface allows specifying the use of a manufacturer's push channel type, for example, specifying the use of the FCM channel for push on Xiaomi devices abroad with setPushBrandId(TencentCloudChatPushBrandID.FCM).
Generally, there's no need to specify the channel type, as the component will automatically identify the device manufacturer category to register and use the corresponding manufacturer channel.
Sample Code:
TencentCloudChatPush().setPushBrandId(brandID: brandID);
Parameter description
:Parameter | Description | |
brandID | Vendor | Device Type |
| XiaoMi | TencentCloudChatPushBrandID.XiaoMi |
| HuaWei | TencentCloudChatPushBrandID.HuaWei |
| FCM | TencentCloudChatPushBrandID.FCM |
| Meizu | TencentCloudChatPushBrandID.Meizu |
| Oppo | TencentCloudChatPushBrandID.Oppo |
| Vivo | TencentCloudChatPushBrandID.Vivo |
| Honor | TencentCloudChatPushBrandID.Honor |
getPushBrandId
Obtain the vendor channel type currently in use for device offline push.
Sample Code:
final res = await TencentCloudChatPush().getPushBrandId(); if(res.code == 0){ final TencentCloudChatPushBrandID brandID = res.data; }
Return Type:
Future<TencentCloudChatPushResult<TencentCloudChatPushBrandID>>
checkPushStatus
After completing the access configuration for each vendor, you can use this interface to test if the corresponding vendor devices can receive pushes.
Sample Code:
final res = await TencentCloudChatPush().checkPushStatus(brandID: 2002); if(res.code == 0){ final status = res.data; }
Parameter Description:
Parameter Name | Type | Description |
brandID | TencentCloudChatPushBrandID |
Return Type:
Future<TencentCloudChatPushResult<String>>
If true, push notifications can be successfully sent.
setApnsCertificateID
Separately configure the APNs Push Certificate ID. You can call or dynamically adjust the Certificate ID as needed, or directly pass it during
registerPush
.Sample Code:
TencentCloudChatPush().setApnsCertificateID(apnsCertificateID: 0);
Parameter Description:
Parameter Name | Type | Description |
apnsCertificateID | int | The Certificate ID assigned to the APNs certificate in the Tencent Cloud IM Console. |
setApplicationGroupID
Configure the Application Group ID for the iOS project.
Sample Code:
TencentCloudChatPush().setApplicationGroupID(applicationGroupID: "");
Parameter Description:
Parameter Name | Type | Description |
applicationGroupID | String | The format is: group + [Main Bundle ID] + key. |
getAndroidPushToken
Retrieve Android device manufacturer Token.
Sample Code:
TencentCloudChatPush().getAndroidPushToken();
Return Type:
Future<TencentCloudChatPushResult<String>>
The returned String type data is the vendor's push Token..
setAndroidPushToken
Manually specify the Android device manufacturer Token.
Sample Code:
TencentCloudChatPush().setAndroidPushToken(businessID: 10000, pushToken: "pushToken");
Parameter Description:
Parameter Name | Type | Description |
businessID | String | Push certificate ID, available from the Tencent Cloud IM console, under the push certificate card. |
pushToken | String | Obtain the vendor’s push Token in your own way. |
setAndroidCustomTIMPushConfigs
Manually replace the default push configuration file timpush-configs.json read by the plugin with a custom one. This needs to be invoked before registering the push service (registerPush).
Note:
Mainly used for dynamically switching different configuration files for push registration in various environments, for example: integrating and testing push features under different configuration files in production and testing environments.
Sample Code:
TencentCloudChatPush().setAndroidCustomTIMPushConfigs(configs: "");
Parameter Description:
Parameter Name | Type | Description |
configs | String | The name of the custom configuration file, the path must remain unchanged: "Engineering Root Directory/android/app/src/assets/". |