This topic describes how to integrate the Honor channel software development kit (SDK) provided by Mobile Push.
Prerequisites
You have integrated the Mobile Push SDK as described in Android SDK Integration.
You have registered an application on HONOR Developers. If you have not done so, log on to HONOR Developers to register your application. You can obtain the App ID, Client ID, and Client Secret from Application Services > Push Service > View Application.
You have configured a signing certificate fingerprint on the HONOR Developers platform. If you have not done so, see the official Honor document Certificate Fingerprint Generation Guide.
You have set up message receipts. If you have not done so, see Message receipts for instructions.
ImportantWhen you use the auxiliary pop-up window, the delivery rate statistics for the Honor channel include only scenarios where users click the push notifications in the Honor pop-up window. Scenarios where users do not click the notifications are not included. You can set up message receipts on the Honor platform to help Mobile Push better collect push data.
To enable receipts, configure the webhook address: https://amspush-ack.aliyuncs.com/ho/.
You have configured the Honor push key (App ID) in the EMAS console. If you have not done so, log on to the EMAS Mobile Push console and set your Honor push key (App ID). For more information, see Configure third-party channel keys.
Step 1: Add the SDK to your application
1.1 Configure the Maven repository
The following sections describe the recommended dependencyResolutionManagement configuration for Gradle 7.0 and later and the recommended allprojects configuration for Gradle versions earlier than 7.0.
1.1.1 dependencyResolutionManagement method
In your root-level (project-level) Gradle file (<project>/settings.gradle), add the Maven repository address to the repositories block in dependencyResolutionManagement.
dependencyResolutionManagement {
repositories {
maven {
url 'https://developer.hihonor.com/repo'
}
}
}
1.1.2 allprojects method
In your root-level (project-level) Gradle file (<project>/build.gradle), add the Maven repository address to the repositories block in the allprojects block.
allprojects {
repositories {
maven {
url 'https://developer.hihonor.com/repo'
}
}
}
1.2 Add SDK dependencies
In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle), add the SDK dependency to the dependencies block.
Read the Android SDK Version Guide and add a dependency on the correct SDK version.
dependencies {
implementation 'com.aliyun.ams:alicloud-android-third-push:x.x.x'
implementation 'com.aliyun.ams:alicloud-android-third-push-honor:x.x.x'
}
The Mobile Push third-party channel SDK supports only Maven dependencies.
Step 2: Configure and use the SDK
1. Configure the AppID
In the AndroidManifest.xml file of your application, add metadata under the application node to configure the AppID.
<meta-data
android:name="com.hihonor.push.app_id"
android:value="Your Honor AppID" />
2. Initialize the SDK
Initialize the SDK in the Application class and place its initialization code after the push SDK's initialization code. Otherwise, vendor channel registration may fail.
Initialize the SDK as follows:
// The registration method automatically checks if the device supports Honor push. If not, the registration is skipped.
HonorRegister.register(application)
// The registration method automatically checks if the device supports Honor push. If not, the registration is skipped.
HonorRegister.register(application);
The registration method automatically checks if the device supports Honor push. If not, the registration is skipped.
3. Configure obfuscation
If code obfuscation is enabled in a project that integrates the push SDK, you must add the following ProGuard configuration for the vendor channel.
# Honor channel
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.hihonor.push.**{*;}
Android Push SDK 3.8.7 upgrades the Honor channel to version 7.0.61.302. The obfuscation configuration for this version has changed, so you must update your obfuscation configuration file.
Step 3: Verify the integration
1. Enable SDK logs
val pushService = PushServiceFactory.getCloudPushService()
// This line is for debug packages only and is not required for release packages.
pushService.setLogLevel(CloudPushService.LOG_DEBUG)
CloudPushService pushService = PushServiceFactory.getCloudPushService();
// This line is for debug packages only and is not required for release packages.
pushService.setLogLevel(CloudPushService.LOG_DEBUG);
2 Confirmation method
To check whether the Honor channel is registered successfully, filter the logs for the MPS:HonorRegister keyword. If no logs related to getToken failure appear, the registration was successful.
What to do next
You can now use the EMAS console to send push notifications to the notification bar on mobile devices through the Honor channel. However, to handle the logic after a user clicks a notification, you must use an auxiliary pop-up window to receive push data. For more information, see Integrate an auxiliary pop-up window.
When you use the Mobile Push console or OpenAPI to send notifications through a third-party channel, you must configure the server-side parameters as described in the auxiliary pop-up window documentation. Otherwise, notifications are not sent through the third-party channel.