Xiaomi MiPush integration

📘

Available upon request

Please contact your Customer Success Manager for access and the Leanplum team will enable it for you.

Note that MiPush integration requires using Leanplum Android SDK version 5.6.2 and above.

MiPush Console

Create a Xiaomi developer account from the Xiaomi Console Website.

Once you have registered, you need to create an application from the Mi Dev Console and enable it for push notifications from the Push Operation Console.

1583

SDK Integration

You can now proceed with the steps to integrate leanplum-mipush library into your Android application:

  1. Add a library dependency:
implementation "com.leanplum:leanplum-mipush:5.6.2"

📘

All Leanplum dependencies used (leanplum-core, leanplum-fcm, leanplum-push...) must be set on the same version. We release all of the packages at the same time, so the correct version will always be available.

We migrated our packages from jCenter to Maven Central. Ensure you have included mavenCentral() in your repositories in build.gradle file, if you have not already.

  1. Add the following permissions to your android manifest file and replace YOUR_PACKAGE_NAME with your package name:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<permission
  android:name="YOUR_PACKAGE_NAME.permission.MIPUSH_RECEIVE"
  android:protectionLevel="signature" />
<uses-permission android:name="YOUR_PACKAGE_NAME.permission.MIPUSH_RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />

📘

These permissions are requested by the MiPush library. This is explained in section 2.1 from their documentation.
The other manifest configuration is implemented by the leanplum-mipush library.

  1. Setup your application to use MiPush.
    Before Leanplum.start call, call LeanplumMiPushHandler.setApplication where first argument is Xiaomi App ID and second is Xiaomi App Key. The keys are available in the MiPush Console for the app created in the MiPush Console steps.
LeanplumMiPushHandler.setApplication("APP_ID", "APP_KEY");
1043
  1. Add your Xiaomi App Secret to Leanplum. In the Leanplum dashboard, go to App Settings, click Keys & Settings. Go to the Push Notifications tab and enter/paste your key into the Xiaomi App Secret field.
992
  1. You've already completed all integration steps. Now in order to send a message through the MiPush service select "Use MiPush" in Advanced Options when setting up a Push Notification campaign. When this option is selected push notifications targeted to users on Xiaomi devices will be automatically sent through Xiaomi proprietary push service MiPush, while all the rest of the devices will be targeted via FCM.