Integrate Honor Push
Follow this guide to integrate Honor Push Service, enabling the RC SDK to receive push notifications from the Honor Push Service.
Before integrating third-party push services, ensure that the Android Application ID has been configured in the RC Console. For details, refer to Push Integration Overview.
The IMLib SDK (development version) has supported Honor Push since version 5.6.7. Important
If your project integrates or upgrades to the IM SDK (development version) 5.6.7, you must also integrate Honor Push; otherwise, devices running Honor Magic OS 8.0 and later may not receive push notifications.
Configure Honor Push in the RC Console
To receive push notifications from the RC IM service via Honor Push, you need to provide detailed information about your Honor Push application in the RC Console.
-
Go to the Honor Developer Service Platform, and on the Push Service page, select the application you created.
tip- If you do not have a Honor Developer account or have not created a project and application, please create an account, project, and application first, and enable the push service. For details, refer to the Honor Developer documentation Create Account, Create Application, and Apply to Enable Push Service.
- Before proceeding with the following steps, ensure that the push service has been enabled for the application on the Honor Developer Service Platform and that the signature certificate fingerprint has been configured. If you have any questions about the process of configuring the push service on the Honor Console, refer to the official Honor Developer documentation App Submission Guide.
You need to note down the App ID, Client ID, and Client Secret under the Application.
-
Open the RC Console, and on the Application Identifier page, click Set Push. Under Android > Honor Push, fill in the Client ID and Client Secret obtained in the previous step.
-
(Optional) Configure the Intent for customizing the click action of the message to open a custom page in the application. This field corresponds to the
ClickAction.action
whenClickAction.type
is1
in the official Honor downlink message interface. For questions, refer to the Honor Developer documentation Message Push. After customizing the intent, you need to configure theintent-filter
in the Activity ofAndroidManifest.xml
to receive the custom intent. -
(Optional) Configure the push badge.
- badgeAddNum: The badge add number is not the actual number displayed on the application badge but an integer greater than 0 and less than 100. For example, if an application currently has N unread messages and the add_num is set to 3, each message sent will increase the badge number by 3, resulting in N+3. This field corresponds to
BadgeNotification.addNum
in the official Honor downlink message interface. For questions, refer to the Honor Developer documentation Message Push. - Activity: The full path of the application entry Activity class. Example: com.example.honortest.MainActivity. This field corresponds to
BadgeNotification.badgeClass
in the official Honor downlink message interface. For questions, refer to the Honor Developer documentation Message Push.
- badgeAddNum: The badge add number is not the actual number displayed on the application badge but an integer greater than 0 and less than 100. For example, if an application currently has N unread messages and the add_num is set to 3, each message sent will increase the badge number by 3, resulting in N+3. This field corresponds to
-
Configure the Push Notification Title. Set the default push notification title. Generally, this title setting is not used when the client sends messages converted to Push. When calling the RC server API
/push.json
,/push/user.json
, and/push/custom.json
interfaces to push notifications, if the notification title is not passed in, the title set here will be used. When sending messages from the server, if the sender’s user ID does not have a username on the RC server, this "Push Notification Title" will also be used. -
Save the settings. All settings will take effect after 30 minutes.
You have completed all the necessary Honor Push configurations in the RC Console. Now you can proceed to set up client integration.
Configure the Client to Receive Honor Push
First, you need to add the Honor Push client SDK to your Android project.
Download the Honor Service Configuration File
The following steps are from the Honor Developer documentation Add Application Configuration File:
-
Log in to the Honor Developer Service Platform, click Application Management, find the target application in the application list, and click Application Details.
-
On the application basic information view page, in the SDK configuration area, download the
mcs-services.json
configuration file. -
Copy the downloaded
mcs-servics.json
file to the root directory of the application level.
Import the Honor Push SDK
Important
The configuration of the Honor Push SDK Maven repository differs for Gradle plugin versions below 7.0, version 7.0, and versions 7.1 and above. This step uses the Gradle plugin version below 7.0 as an example, as described in the official Honor documentation. For configuration methods for other Gradle versions, refer to the official Honor documentation Integrate SDK.
-
Configure the official Honor Maven repository, using Gradle version below 7.0 as an example.
Open the
build.gradle
file in the project:- Configure the Maven repository address of the SDK in buildscript > repositories.
- Configure the Maven repository address of the SDK in allprojects > repositories.
- If the App has added the mcs-services.json file, you need to add the asplugin plugin configuration in buildscript > dependencies.
buildscript {
repositories {
google()
jcenter()
// Configure the Maven repository address of the SDK.
maven {url 'https://developer.hihonor.com/repo'}
}
dependencies {
...
// Add the asplugin plugin configuration. It is recommended to use the latest version.
classpath 'com.hihonor.mcs:asplugin:2.0.0'
// Add the gradle plugin configuration. Select the corresponding plugin version number based on the gradle version.
classpath 'com.android.tools.build:gradle:4.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
// Configure the Maven repository address of the SDK.
maven {url 'https://developer.hihonor.com/repo'}
}
} -
Add the Honor asplugin plugin configuration. Using Gradle version below 7.0 as an example, add the following configuration at the beginning of the application-level
build.gradle
file:apply plugin: 'com.hihonor.mcs.asplugin'
tipIntroducing the asplugin plugin requires configuring the gradle jdk version to 11 or higher in Android Studio. For details, refer to the official Honor documentation Configure Development Environment.
-
If your application’s
targerSdkVersion
is greater than or equal to 30, you need to add a tag inAndroidManifest.xml
specifying the intent action that the application can handle.<queries>
<intent>
<action android:name="com.hihonor.push.action.BIND_PUSH_SERVICE" />
</intent>
</queries> -
Add the following compile dependency in the application-level
build.gradle
to integrate the RC Push 2.0 SDK.android {
defaultConfig {
//...
manifestPlaceholders = [
HONOR_APP_ID : "xxxxxxxxxx"
]
}
}
dependencies {
// x.y.z is the current IM SDK version number
implementation 'cn.rongcloud.sdk.push:honor:x.y.z'
}
HONOR_APP_ID
corresponds to the APP ID of the Honor application.
Configure the Signature
Refer to the official Honor documentation, copy the signature file generated in the Generate Signature Certificate Fingerprint step to the App directory of the project, and configure the signature in the build.gradle
file.
android {
signingConfigs {
config {
// Replace the xxxx in the following parameters with your actual signature information.
keyAlias 'xxxx'
keyPassword 'xxxx'
storeFile file('xxxx.jks')
storePassword 'xxxx'
}
}
buildTypes {
debug {
signingConfig signingConfigs.config
}
release {
signingConfig signingConfigs.config
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
Enable the Honor Push Service
The SDK has supported Honor Push since version 5.6.7 and reports the Honor Push Token to the RC server.
Please enable the Honor Push service before initializing the RC SDK. The RC SDK will register the device with the Honor Push service and report the Honor Push Token obtained from the Honor Push server to the RC Push server.
Before SDK initialization, call the following code to initialize the RongPushPlugin
module.
RongPushPlugin.init(getContext());
If the RongPushPlugin
module cannot be found, check if you have Integrated the RC Self-built Push Channel.
Configure Obfuscation
Refer to the official Honor Push documentation Configure Obfuscation Script.
Handle Push Notification Click Events
- Customize Push Notification Click Events: Learn how to implement the SDK's default jump behavior and how to customize the handling of click events. For details, refer to Customize Push Notification Click Events.
- Customize Push Notification Styles: After the SDK receives push notifications from other third-party vendors, the notifications popped up are system notifications, which are directly popped up by the underlying system of the phone, so customization is not supported.
Badge Unread Count
RC does not maintain the application badge count, and the RC client SDK does not support controlling badge display. For details on implementing badge control related to vendor push notifications, refer to the knowledge base document Push Badge.