Xiaomi Intergration

Xiaomi integration guide in your app

For integration with xiaomi please register these below permission in your app manifest. These are the permission which are required by xiaomi sdk to work.

<!--Xiaomi Starts - Sdk Needs this-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />

<permission
            android:name="app.suprsend.android.permission.MIPUSH_RECEIVE"
            android:protectionLevel="signature" />

<uses-permission android:name="app.suprsend.android.permission.MIPUSH_RECEIVE" />
<!--Xiaomi Ends-->

Also below android components needs to be registered in your android app manifest.

<!--Xiaomi Starts-->
<!--Suprsend Receiver Starts-->
<receiver
          android:name="app.suprsend.xiaomi.SSXiaomiReceiver"
          android:exported="true">
  <intent-filter>
    <action android:name="com.xiaomi.mipush.RECEIVE_MESSAGE" />
  </intent-filter>
  <intent-filter>
    <action android:name="com.xiaomi.mipush.MESSAGE_ARRIVED" />
  </intent-filter>
  <intent-filter>
    <action android:name="com.xiaomi.mipush.ERROR" />
  </intent-filter>
</receiver>
<!--Suprsend Receiver Ends-->

<service
         android:name="com.xiaomi.push.service.XMJobService"
         android:enabled="true"
         android:exported="false"
         android:permission="android.permission.BIND_JOB_SERVICE"
         android:process=":pushservice" />

<service
         android:name="com.xiaomi.push.service.XMPushService"
         android:enabled="true"
         android:process=":pushservice" />

<service
         android:name="com.xiaomi.mipush.sdk.PushMessageHandler"
         android:enabled="true"
         android:exported="true" />
<service
         android:name="com.xiaomi.mipush.sdk.MessageHandleService"
         android:enabled="true" />

<receiver
          android:name="com.xiaomi.push.service.receivers.NetworkStatusReceiver"
          android:exported="true">
  <intent-filter>
    <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />

    <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</receiver>

<receiver
          android:name="com.xiaomi.push.service.receivers.PingReceiver"
          android:exported="false"
          android:process=":pushservice">
  <intent-filter>
    <action android:name="com.xiaomi.push.PING_TIMER" />
  </intent-filter>
</receiver>

<!--Xiaomi Ends-->

You can register with xiaomi push service by iniatilizing the suprsend sdk instance with below api. For that you will need app id & app key generated from xiaomi dashboad.
Please follow step 1 & 2 to generate app id & key.

class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()
        SSApi.initXiaomi(context = this, appId = "XIAOMI_APP_ID", apiKey = "XIAOMI_APP_KEY")
    }
}