1. Choose to download the configuration file timpush-configs.json | 1. Add to the project |
![]() | ![]() |
// Integration of the push main package is mandatoryimplementation 'com.tencent.timpush:timpush:8.0.6897'// Integrate the corresponding manufacturer as neededimplementation 'com.tencent.timpush:fcm:8.0.6897'implementation 'com.tencent.timpush:huawei:8.0.6897'implementation 'com.tencent.timpush:xiaomi:8.0.6897'implementation 'com.tencent.timpush:vivo:8.0.6897'implementation 'com.tencent.timpush:honor:8.0.6897'implementation 'com.tencent.timpush:meizu:8.0.6897'// Choose one of the two below// For the China region, choose to integrate this packageimplementation 'com.tencent.timpush:oppo:8.0.6897'// For other regions, choose to integrate this packageimplementation 'com.tencent.timpush:oppo-intl:8.0.6897'
def projects = this.rootProject.getAllprojects().stream().map { project -> project.name }.collect() api projects.contains("tuicore") ? project(':tuicore') : "com.tencent.liteav.tuikit:tuicore:8.0.6897"
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"]}}
// 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.google.gms:google-services:4.3.15'classpath 'com.huawei.agconnect:agcp:1.6.0.300'classpath 'com.hihonor.mcs:asplugin:2.0.1.300'}}
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.3.15'classpath 'com.huawei.agconnect:agcp:1.6.0.300'classpath 'com.hihonor.mcs:asplugin:2.0.1.300'}}
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.3.15'classpath 'com.huawei.agconnect:agcp:1.6.0.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'
-keep class com.tencent.qcloud.** { *; }-keep class com.tencent.timpush.** { *; }
Singapore https://apisgp.im.qcloud.com/v3/offline_push_report/huawei
South Korea https://apikr.im.qcloud.com/v3/offline_push_report/huawei
USA https://apiusa.im.qcloud.com/v3/offline_push_report/huawei
Germany https://apiger.im.qcloud.com/v3/offline_push_report/huawei
Indonesia https://apiidn.im.qcloud.com/v3/offline_push_report/huawei
Others in China https://api.im.qcloud.com/v3/offline_push_report/huawei
Singapore https://apisgp.im.qcloud.com/v3/offline_push_report/honor
South Korea https://apikr.im.qcloud.com/v3/offline_push_report/honor
USA https://apiusa.im.qcloud.com/v3/offline_push_report/honor
Germany https://apiger.im.qcloud.com/v3/offline_push_report/honor
Indonesia https://apiidn.im.qcloud.com/v3/offline_push_report/honor
Others in China https://api.im.qcloud.com/v3/offline_push_report/honor
Callback Address Configuration | Configure Receipt ID in the IM Console |
![]() Receipt Address: Singapore https://apisgp.im.qcloud.com/v3/offline_push_report/vivo
South 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
Others in China https://api.im.qcloud.com/v3/offline_push_report/vivo | ![]() |
Enable Receipt Switch | Configure Receipt Address |
![]() | ![]() |
Singapore https://apisgp.im.qcloud.com/v3/offline_push_report/meizu
South Korea https://apikr.im.qcloud.com/v3/offline_push_report/meizu
USA https://apiusa.im.qcloud.com/v3/offline_push_report/meizu
Germany https://apiger.im.qcloud.com/v3/offline_push_report/meizu
Indonesia https://apiidn.im.qcloud.com/v3/offline_push_report/meizu
China https://api.im.qcloud.com/v3/offline_push_report/meizu
V2TIMOfflinePushInfo v2TIMOfflinePushInfo = new V2TIMOfflinePushInfo();v2TIMOfflinePushInfo.setTitle("Push Title");v2TIMOfflinePushInfo.setDesc("Push Content");OfflinePushExtInfo offlinePushExtInfo = new OfflinePushExtInfo(); offlinePushExtInfo.getBusinessInfo().setSenderId("senderID");offlinePushExtInfo.getBusinessInfo().setSenderNickName("senderNickName"); if (chatInfo.getType() == V2TIMConversation.V2TIM_GROUP) { offlinePushExtInfo.getBusinessInfo().setChatType(V2TIMConversation.V2TIM_GROUP); offlinePushExtInfo.getBusinessInfo().setSenderId("groupID"); } v2TIMOfflinePushInfo.setExt(new Gson().toJson(offlinePushExtInfo).getBytes());// For OPPO, you must set the `ChannelID` to receive push messages. The `ChannelID` must be identical with that in the console.v2TIMOfflinePushInfo.setAndroidOPPOChannelID("tuikit");v2TIMOfflinePushInfo.setAndroidHuaWeiCategory("IM");v2TIMOfflinePushInfo.setAndroidVIVOCategory("IM");final V2TIMMessage v2TIMMessage = message.getTimMessage();String msgID = V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, isGroup ? null : userID, isGroup ? groupID : null,V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, v2TIMOfflinePushInfo, new V2TIMSendCallback<V2TIMMessage>() {@Overridepublic void onProgress(int progress) {}@Overridepublic void onError(int code, String desc) {TUIChatUtils.callbackOnError(callBack, TAG, code, desc);}@Overridepublic void onSuccess(V2TIMMessage v2TIMMessage) {TUIChatLog.v(TAG, "sendMessage onSuccess:" + v2TIMMessage.getMsgID());message.setMsgTime(v2TIMMessage.getTimestamp());TUIChatUtils.callbackOnSuccess(callBack, message);}});
TUICore.registerEvent(TUIConstants.TIMPush.EVENT_NOTIFY, TUIConstants.TIMPush.EVENT_NOTIFY_NOTIFICATION, new ITUINotification() {@Overridepublic void onNotifyEvent(String key, String subKey, Map<String, Object> param) {Log.d(TAG, "onNotifyEvent key = " + key + "subKey = " + subKey);if (TUIConstants.TIMPush.EVENT_NOTIFY.equals(key)) {if (TUIConstants.TIMPush.EVENT_NOTIFY_NOTIFICATION.equals(subKey)) {if (param != null) {String extString = (String)param.get(TUIConstants.TIMPush.NOTIFICATION_EXT_KEY);// Getting ext for Definition redirect// Example: Redirect to the corresponding chat interfaceOfflinePushExtInfo offlinePushExtInfo = null;try {offlinePushExtInfo = new Gson().fromJson(extString, OfflinePushExtInfo.class);if (offlinePushExtInfo.getBusinessInfo().getChatAction() == OfflinePushExtInfo.REDIRECT_ACTION_CHAT) {String senderId = offlinePushExtInfo.getBusinessInfo().getSenderId();if (TextUtils.isEmpty(senderId)) {return;}TUIUtils.startChat(senderId, offlinePushExtInfo.getBusinessInfo().getSenderNickName(), offlinePushExtInfo.getBusinessInfo().getChatType());}} catch (Exception e) {Log.e(TAG, "getOfflinePushExtInfo e: " + e);}}}}}});
// Dynamic Broadcast RegistrationIntentFilter intentFilter = new IntentFilter();intentFilter.addAction(TUIConstants.TIMPush.NOTIFICATION_BROADCAST_ACTION);LocalBroadcastManager.getInstance(context).registerReceiver(localReceiver, intentFilter);// Broadcast Receiverpublic class OfflinePushLocalReceiver extends BroadcastReceiver {public static final String TAG = OfflinePushLocalReceiver.class.getSimpleName();@Overridepublic void onReceive(Context context, Intent intent) {DemoLog.d(TAG, "BROADCAST_PUSH_RECEIVER intent = " + intent);if (intent != null) {String ext = intent.getStringExtra(TUIConstants.TIMPush.NOTIFICATION_EXT_KEY);// Getting ext for Custom Redirect// Example: Redirect to the corresponding chat interfaceOfflinePushExtInfo offlinePushExtInfo = null;try {offlinePushExtInfo = new Gson().fromJson(extString, OfflinePushExtInfo.class);if (offlinePushExtInfo.getBusinessInfo().getChatAction() == OfflinePushExtInfo.REDIRECT_ACTION_CHAT) {String senderId = offlinePushExtInfo.getBusinessInfo().getSenderId();if (TextUtils.isEmpty(senderId)) {return;}TUIUtils.startChat(senderId, offlinePushExtInfo.getBusinessInfo().getSenderNickName(), offlinePushExtInfo.getBusinessInfo().getChatType());}} catch (Exception e) {Log.e(TAG, "getOfflinePushExtInfo e: " + e);}} else {Log.e(TAG, "onReceive ext is null");}}}
Was this page helpful?