Xiaomi Gateway Integration


Xiaomi has issued a notice regarding the discontinuation of the Mi Push service outside Mainland China, due to operational concerns.

For more details, visit Discontinuation of Xiaomi Push Service. We highly recommend to follow the steps mentioned here to remove Netcore Xiaomi SDK integration at the earliest to avoid unknown errors on app side.

Chinese smartphones have occupied a large share of the smartphone market. To achieve longer battery support, Chinese smartphones have imposed some restrictions on background processes. Due to these restrictions, many users are unable to receive push notifications.

To improve notification delivery rates, Netcore has now added the support of the Xiaomi Push gateway. Netcore will send notifications through both the Xiaomi push gateway and FCM push gateway to increase the chances of delivery to the end users. We ensure that the user will receive the given push notification only once.


Xiaomi SDK integration prerequisites

  • Ensure to upgrade to Smartech Base SDK v3.3.3 & Smartech Push SDK v3.3.2
  • Step1 : Follow this link to create Xiaomi developer account and create app
  • Step2 : You can visit the MI developer console to enable the xiaomi push and to get the Xiaomi App secret, AppId and AppKey.

Xiaomi Push handled by Smartech Push Xiaomi SDK

Step 1: Add dependency of Mi SDK

Download the Mi SDK from here and add it to the libs folder of the application module of your project.
Add the below configuration in the build.gradle of the app module.

dependencies {
    implementation fileTree(dir: 'libs', include: ['MiPush_SDK_Client_5_1_5-G_3rd.aar'])
    //your other app level dependencies

Note: Replace MiPush_SDK_Client_5_1_5-G_3rd.aarwith the actual mi push SDK version downloaded and pasted in libs folder

Step 2: Add SmartPushXiaomi SDK dependency

  1. Please add SmartPushXiaomi dependency inside the app-levelbuild.gradle file.
dependencies { 
    implementation 'com.netcore.android:smartech-push-xiaomi:3.3.0'
    //your other app level dependencies
  1. Perform Gradle Sync to build your project and incorporate the dependency additions done above.

Step 3: Register Xiaomi SDK via SmartPushXiaomi SDK

  1. Add the below-mentioned code in the onCreate() method of your Application class to initialize the Smartech Push Xiaomi SDK.
@Override public void onCreate() { 
   SmartPushXiaomi.getInstance(new WeakReference<>(this)).register(appId, appKey, region);
override fun onCreate() {
   SmartPushXiaomi.getInstance(WeakReference<>(this)).register(appId, appKey, region)


  • appId - App-Id from the Mi Dashboard.
  • appKey - App-Key from the Mi Dashboard.
  • region - The region in which the Mi data should reside. Set the region using Region enum from the Mi SDK.

Xiaomi Push Handled by the Application

If the application is handling token registration and notification via its own receiver, then the application should have to pass on the Push token and the push message received on XiaomiPushReceiver to the SmartechXiaomiPush SDK.

Follow the Xiaomi SDK integration Document to integrate the Xiaomi SDK.

Note: You are required to add Smartech Push Xiaomi SDK dependency as mentioned above in step 2 to use the below API’s

Pass the push token

Use the setXiaomiPushToken() API to pass the push token to the SmartechPushXiaomi SDK which is received on your CustomXiaomiPushReceiver onReceiveRegisterResult function.

SmartPushXiaomi.getInstance(new WeakReference<>(this)).setXiaomiPushToken(token, MiPushClient.getAppRegion(context));
SmartPushXiaomi.getInstance(WeakReference<>(this)).setXiaomiPushToken(token, MiPushClient.getAppRegion(context))


  • token - Xiaomi token which is received on your custom XiaomiPushReceiver
  • region - get region from Xiaomi SDK as mentioned above and pass it on setXiaomiPushToken function

Handle Xiaomi push message

Use the handleXiaomiNotification() API to pass the push message to the SmartechPushXiaomi SDK to handle notification which is received on your CustomXiaomiPushReceiver onReceivePassThroughMessage function.

boolean isPushFromSmartech = SmartPushXiaomi.getInstance(new WeakReference<>(this)).isNotificationFromSmartech(message.getContent());
if(isPushFromSmartech) {
   SmartPushXiaomi.getInstance(new WeakReference<>(this))

val isPushFromSmartech = SmartPushXiaomi.getInstance(WeakReference<>(this)).isNotificationFromSmartech(message.getContent())
if(isPushFromSmartech) {

UI changes for Xiaomi gateway

Instructions for enabling Xiaomi gateway :

  1. Go to the App section in settings and edit the desired Android app.
  2. Enable Xiaomi gateway integration - this will be a toggle button to enable Xiaomi gateway settings
  3. Once enabled, user needs to provide two fields compulsorily . These are text input boxes with no additional validation
    1. App secret
    2. Package name
  4. User will have to select for which type of devices, Xiaomi gateway integration needs to be enabled from SDK point of view. The dropdown options will be as follows:
    1. All devices
    2. Only Xiaomi devices
    3. Only Xiaomi devices with MIUI OS (default selection)