This topic describes how to configure Mobile Push when you integrate a native third-party push channel SDK.
Introduction
You can integrate third-party push channel SDKs yourself, instead of using the ones provided by EMAS.
If you integrate the SDK yourself, you are responsible for the integration and initialization. After the third-party push channel is initialized, you must call an API to upload the vendor's device ID. This approach is useful in the following scenarios:
The third-party push channel SDK provided by EMAS conflicts with another SDK.
EMAS does not provide a specific version of a third-party push channel SDK.
Preparations
You have integrated the Mobile Push SDK. For more information, see Android SDK integration.
Step 1: Add the SDK to your application
In your module-level Gradle file, typically <project>/<app-module>/build.gradle, add the SDK dependency to the dependencies block.
Read the Android SDK Version Guide to select the correct SDK version.
dependencies {
implementation 'com.aliyun.ams:alicloud-android-third-push:x.x.x'
}The Mobile Push SDK for third-party channels only supports Maven dependencies.
Step 2: Configure the SDK
1. SDK initialization
Initialize the SDK according to the integration guide for your chosen third-party push channel.
2. Upload the vendor device ID
After the third-party push channel is initialized, call ThirdPushManager.reportToken() to upload the vendor device ID:
/**
* Example for Huawei
*
* @param context The context object. Passing ApplicationContext is recommended.
* @param thirdTokenKeyword The identifier for the vendor device ID. This is described in detail below.
* @param token The vendor device ID. The name for this ID varies by vendor. We use 'token' as a general term.
*/
ThirdPushManager.reportToken(context, ThirdPushReportKeyword.HUAWEI.thirdTokenKeyword, token);3. Register a data decoder for third-party push notifications
A helper dialog box receives and processes push data when a user taps a third-party push notification. You must register the corresponding data decoder to enable this process.
// For Huawei devices
ThirdPushManager.registerImpl(new HuaweiMsgParseImpl());
// For Honor devices
ThirdPushManager.registerImpl(new HonorParserImpl());
// For Xiaomi devices
ThirdPushManager.registerImpl(new XiaoMiMsgParseImpl());
// For vivo devices
VivoMsgParseImpl listener = new VivoMsgParseImpl();
listener.setContext(getApplicationContext());
ThirdPushManager.registerImpl(listener);
// For OPPO devices
ThirdPushManager.registerImpl(new OppoMsgParseImpl());
// For Meizu devices
ThirdPushManager.registerImpl(new MeizuMsgParseImpl());Supported message decoders include HuaweiMsgParseImpl, HonorParserImpl, XiaoMiMsgParseImpl, OppoMsgParseImpl, VivoMsgParseImpl, and MeizuMsgParseImpl.
4. Process pass-through message data from third-party push channels
When your application receives a pass-through message from a third-party push channel, call ThirdPushManager.onPushMsg to send the message content to the EMAS Mobile Push SDK for processing.
/**
* Example for Huawei
*
* @param context The context object. Passing ApplicationContext is recommended.
* @param thirdTokenKeyword The identifier for the third-party message.
* @param msgContent The content of the third-party message.
*/
ThirdPushManager.onPushMsg(context, ThirdPushReportKeyword.HUAWEI.thirdMsgKeyword, msgContent);