All Products
Search
Document Center

Mobile Platform as a Service:Integrate MiPush

Last Updated:Jul 20, 2023

This guide mainly introduces the process of integrating MiPush. The process falls into three steps:

  1. Register MiPush

  2. Integrate MiPush

  3. Test MiPush

Register MiPush

Complete MiPush registration with reference to the following official Xiaomi documents:

Integrate MiPush

  1. Add Push - Xiaomi component in the IDE plugin. The steps are roughly the same as adding MPS SDK, see Add SDK. Currently, the built-in MiPush SDK is V4.0.2. You can see Release notes to learn the historical versions.

  2. Configure AndroidManifest.xml, and replace the values of xiaomi_appid and xiaomi_appkey. If you integrate the MiPush SDK through Portal & Bundle projects, please configure the AndroidManifest.xml in the Portal project.

     <permission
         android:name="${applicationId}.permission.MIPUSH_RECEIVE"
         android:protectionLevel="signature"/>
     <uses-permission android:name="${applicationId}.permission.MIPUSH_RECEIVE"/>
     <application>
    
         <!-- Keep the slash (\) and space in the value -->
         <meta-data
             android:name="xiaomi_appid"
             android:value="\ 2xxxxxxxxxxxxxxx" />
         <!-- Keep the slash (\) and space in the value -->
         <meta-data
             android:name="xiaomi_appkey"
             android:value="\ 5xxxxxxxxxxxxxxx" />
    
     </application>

Test MiPush

  1. After integrating MiPush, you can start the app on your Xiaomi phone, and the MPS SDK will automatically get the MiPush token and report it. Before you start the app, make sure that you have called the initialization method, see Message push initialization.

  2. Push test messages when the app process is killed:

    • If you can still receive the messages, it means that the app has successfully integrated MiPush.

    • If you cannot receive the messages, you can follow the steps below for troubleshooting.

Troubleshooting

  1. Check if AndroidManifest.xml has been configured, and the values of xiaomi_appid and xiaomi_appkey in the file are consistent with that on Mi Developer Platform.

  2. Check if MiPush is enabled in the mPaaS console (see Configure Xiaomi push channel), and the relevant configurations are consistent with that on Mi Developer Platform.

  3. View the logs in Logcat to troubleshoot:

    1. Select the push process, filter mPush.PushProxyFactory, and check if the following log exists:

      D/mPush.PushProxyFactory: found proxy com.mpaas.push.external.mi.Creator

      If not, it means that there may be a problem with the Push - Xiaomi component. Check if the component has been correctly added.

    2. Select the push, filter mMi, and check if the MiPush channel token has been obtained.

      If the following log (register_fail) appears, it means the MiPush registration failed. See MiPush error codes for the failure reason (reason). If the value of reason is UNKNOWN, it is generally due to incorrect xiaomi_appid or xiaomi_appkey. To learn about the result codes (resultCode), see MiPush server error codes.

    3. Select the main process, filter report channel token, check if the MiPush channel token has been successfully reported. If the following log appears:

      report channel token error: xxxx

      It means the channel token reporting failed, you need to check if the base64Code in the mPaaS configuration file has a value, and check if the apk signature that you uploaded when obtaining the configuration file is consistent with the app.