Integrating Xiaomi Push
Follow this guide to integrate Xiaomi Mi Push (China or Global version) to enable Xiaomi push support for the RC SDK.
Before integrating third-party push services, ensure you have configured the Android Application ID in the Console. Refer to Push Integration Overview.
IMLib SDK has supported Xiaomi Global Push Service since version 5.6.8.
Configuring Xiaomi Push in the Console
To receive push notifications from RC server via Xiaomi Push, you need to provide your Xiaomi Push application details in the Console.
-
Go to Xiaomi Developer Platform, select the Xiaomi application corresponding to your current project, click Application Info, and record the AppID, AppKey, and AppSecret.
tipIf you don't have a Xiaomi developer account or haven't created an application, refer to Xiaomi Push documentation:
- Mainland China - Push Service Activation Guide
- Global - Push Service Activation Guide. Currently, Xiaomi has data centers in Mumbai (India), Frankfurt (Germany), Moscow (Russia), and Singapore. Choose the appropriate region when creating your application.


The AppSecret serves as the identity credential for Xiaomi Push server-side. It's required when using Xiaomi Push server SDK to send messages to clients and must be provided to RC in the Console's Xiaomi Push configuration. The AppId and AppKey are client-side credentials for Xiaomi Push, which will be provided to the RC SDK later for initializing the Xiaomi Push client SDK.
-
Open the Console, navigate to the Application Identifier page. Click Configure Push, locate Android > Xiaomi Push, and enter the AppSecret obtained in the previous step.
-
(Optional) Configure Xiaomi Push Notification Title. Set the default push notification title. Normally, this title setting isn't used when converting client messages to Push. When calling RC server APIs
/push.json,/push/user.json, or/push/custom.jsonto send push notifications, if no title is provided, this configured title will be used. For messages sent from the server, if the sender's user ID doesn't have a username registered on RC server, this "Push Notification Title" will also be used. -
Select Push Channel Type. Xiaomi Push offers two message types: normal messages and notification messages. Refer to Xiaomi Push Message Restrictions Documentation.
- Normal messages (default channel used by RC) have limitations.
- Notification messages have no restrictions but require providing a channelId applied from Xiaomi backend.
-
Save settings. All configurations take effect after 15 minutes.
You've now completed all required Xiaomi Push configurations in the Console. Proceed to client-side integration.
Configuring Client to Receive Xiaomi Push
Important
We recommend configuring Xiaomi's App ID and App Key via
gradle.properties. If you prefer to write these directly in the app'sbuild.gradle, ensure to add escape characters as shown below:
XIAOMI_APP_ID: "\"1882303761517473625\""XIAOMI_APP_KEY : "\"1451747338625\"".
You can integrate Xiaomi Push using either of these approaches:
-
Option 1: Configure Xiaomi's App ID and App Key via
gradle.properties. Reference the properties configured ingradle.propertiesunder themanifestPlaceholderssection inbuild.gradleforXIAOMI_APP_IDandXIAOMI_APP_KEY.Example
gradle.propertiesconfiguration:MI_PUSH_APPID="9882303761517473625"
MI_PUSH_APPKEY="9451747338625"
Example build.gradle configuration:
android {
defaultConfig {
manifestPlaceholders = [
// Xiaomi application parameters
XIAOMI_APP_ID : "${MI_PUSH_APPID}",
XIAOMI_APP_KEY : "${MI_PUSH_APPKEY}",
]
}
// ...other configurations
}
-
Option 2: Add dependencies directly in the app's
build.gradle.Note If configuring directly in build.gradle, remember to add escape characters as shown:
android {
defaultConfig {
manifestPlaceholders = [
// Xiaomi application parameters
XIAOMI_APP_ID : "\"9882303761517473625\""
XIAOMI_APP_KEY : "\"9451747338625\"",
]
}
// ...other configurations
}Complete the corresponding configuration based on Xiaomi Push service region:
-
Mainland China: Integrate Xiaomi Push client for Mainland China and configure
XIAOMI_APP_IDandXIAOMI_APP_KEY.android {
defaultConfig {
//...
manifestPlaceholders = [
XIAOMI_APP_ID : "xxxxxxxx",
XIAOMI_APP_KEY: "xxxxxxxx"
]
}
}
dependencies {
// x.y.z represents current IM SDK version
implementation 'cn.rongcloud.sdk.push:xiaomi:x.y.z'
} -
Global Regions: Xiaomi has data centers in Mumbai (India), Frankfurt (Germany), Moscow (Russia), and Singapore. If using Xiaomi Global Push service, you must integrate the global version of Xiaomi Push client and configure
XIAOMI_APP_ID,XIAOMI_APP_KEY, and region.android {
defaultConfig {
//...
manifestPlaceholders = [
XIAOMI_APP_ID : "xxxxxxxx",
XIAOMI_APP_KEY: "xxxxxxxx",
XIAOMI_APP_REGION : "" // Global, Europe, Russia, India
]
}
}
dependencies {
// x.y.z represents current IM SDK version
implementation 'cn.rongcloud.sdk.push:xiaomi_global:x.y.z'
}
-
Enabling Xiaomi Push Service
Before initializing the SDK, call the following code to initialize the RongPushPlugin module.
RongPushPlugin.init(getContext());
If the RongPushPlugin module cannot be found, verify whether you've integrated RC's built-in push channel.
Obfuscation Configuration
If your app uses obfuscation, apply these obfuscation rules:
-dontwarn com.xiaomi.mipush.sdk.**
-keep public class com.xiaomi.mipush.sdk.* {*; }
Handling Push Notification Clicks
- Customizing Push Notification Click Actions: Learn how to implement SDK's default redirect behavior or customize click handling. See Customizing Push Notification Click Actions.
- Customizing Push Notification Styles: Notifications received from third-party vendors are system notifications displayed directly by the OS, so custom styling isn't supported.