Xiaomi Gateway Integration

Chinese smartphones have occupied a large part smartphone market. To achieve longer battery support Chinese smartphones impose 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

Step1: Add dependency of Mi SDK

Download the Mi SDK from here and 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.aar to the actual mi push SDK version downloaded and pasted in libs folder

Step2: Adding SmartPushXiaomi SDK dependency

  1. Please add SmartPushXiaomi dependency inside the app-level build.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 noted above.

Step3: 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(appKey, appId, region);
override fun onCreate() {
   SmartPushXiaomi.getInstance(WeakReference<>(this)).register(appKey, appId, region)


  • appKey - App-Id from the Mi Dashboard.
  • appId - 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 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: Required to add Smartech Push Xiaomi SDK dependency as mentioned above in step2 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 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

We need single-select dropdown where user will select for which devices Xiaomi gateway integration needs to be enabled from SDK point of view. The dropdown options will be as follows:

a. All devices

b. Only Xiaomi devices

c. Only Xiaomi devices with MIUI OS