All Products
Search
Document Center

Access MiPush

Last Updated: Jul 07, 2021

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

  1. Register MiPush
  2. Access MiPush
  3. Test MiPush

Register MiPush

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

Access 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 access the MiPush SDK through Portal & Bundle projects, please configure the AndroidManifest.xml in the Portal project.

       
    1. <permission
    2. android:name="${applicationId}.permission.MIPUSH_RECEIVE"
    3. android:protectionLevel="signature"/>
    4. <uses-permission android:name="${applicationId}.permission.MIPUSH_RECEIVE"/>
    5. <application>
    6. <!-- Keep the slash (\) and space in the value -->
    7. <meta-data
    8. android:name="xiaomi_appid"
    9. android:value="\ 2xxxxxxxxxxxxxxx" />
    10. <!-- Keep the slash (\) and space in the value -->
    11. <meta-data
    12. android:name="xiaomi_appkey"
    13. android:value="\ 5xxxxxxxxxxxxxxx" />
    14. </application>

Test MiPush

  1. After accessing 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 accessed 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 MiPush), 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:

           
      1. 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: token

      It means the MiPush registration failed. See MiPush error codes for the failure reason. If the error code is UNKNOWN, it is generally due to incorrect xiaomi_appid or xiaomi_appkey.

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

           
      1. 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.

  4. If the above steps do not resolve the issue, you can submit a ticket or contact the mPaaS support staff.