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 the notification delivery, CEE has now added the support of the Xiaomi Push gateway. CEE will send notifications through both Xiaomi push 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 Push Integration Steps

You need to perform a few steps to integrate Xiaomi Push in your app.

  1. Create a Xiaomi Developer account.
  2. Create an application on Xiaomi Push Console.
  3. To receive the push messages form Xiaomi, enable push from Xiaomi admin console.
  4. Download Xiaomi Push SDK.
  5. Follow Xiaomi Android SDK integration docs and integrate Xiaomi Push SDK into your project.

Setting Xiaomi Push Token/RegId

Similar to FCM, Xiaomi Push has Xiaomi Reg Id/Token which can be used to send push notifications to a device. To pass Xiaomi reg id/token to CEE SDK use below snippet.

public class MyApplication extends Application {
    public void onCreate() {
        SmartPush smartPush = SmartPush.getInstance(new WeakReference<>(this));
        MiPushClient.registerPush(this, "XIAOMI_APP_ID", "XIAOMI_APP_KEY");
        String xiaomiToken = MiPushClient.getRegId(this);

Getting Xiaomi Push RegId/Token

To retrieve the Xiaomi token set in the CEE SDK use the below code.

SmartPush.getInstance(new WeakReference<>(context)).getXiaomiPushToken();

Handle Xiaomi Push Notifications

Notifications sent via Xiaomi push are received in the custom BroadcastReceiver class which extends PushMessageReceiver of Xiaomi SDK. Make the below changes in the onReceivePassThroughMessage() of your broadcast receiver. You don't need to trigger notification delivery and open event manually if you are using the above method.

public class XiaomiPushReceiver extends PushMessageReceiver {
    public void onReceivePassThroughMessage(Context context, MiPushMessage message) {
        boolean isFromSmartech = SmartPush.getInstance(new WeakReference<>(context)).handleXiaomiNotification(message.getContent());
        if (!isFromSmartech) {
            //Handle notification from other sources.