Xiaomi Push

更新时间:
复制 MD 格式

Integrate Xiaomi Push into your mPaaS app so notifications are delivered on Xiaomi devices when the app process is killed.

  1. Register Xiaomi Push

  2. Integrate Xiaomi Push

  3. Test Xiaomi Push

Register Xiaomi Push

Before integrating, complete both steps on the Xiaomi Developer Platform:

Integrate Xiaomi Push

  1. Add the Push - Xiaomi component using the same method as for adding the Push SDK. For more information, see Add the Push SDK.

    The built-in Xiaomi Push SDK version is 4.0.2. For earlier versions, see Release notes.

  2. Configure AndroidManifest.xml with the AppID and AppKey from the Xiaomi Developer Platform. Replace xiaomi_appid and xiaomi_appkey with your actual values. For component-based development, add this file to the portal project.

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

    The leading backslash and space before each value are required. Removing them prevents Xiaomi Push from reading the credentials correctly.

Test Xiaomi Push

  1. Start the app on a Xiaomi device and confirm the initialization method is called. See Message Push Service initialization. The Push SDK automatically retrieves and reports the Xiaomi Push vendor token.

  2. Kill the app process, then send a test message:

    • If the message arrives, the integration is complete.

    • If the message does not arrive, follow the troubleshooting steps below.

Troubleshoot issues

  1. Verify that AndroidManifest.xml is configured and that the values of xiaomi_appid and xiaomi_appkey match those on the Xiaomi Open Platform.

  2. Verify that the Xiaomi channel is enabled in the mPaaS console and that its configuration matches the Xiaomi Open Platform. For more information, see Configure the Xiaomi Push channel.

  3. Check the logcat logs:

    1. Select the push process and filter by mPush.PushProxyFactory. Confirm the following log entry exists:

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

      If this entry is missing, the Push - Xiaomi component was not added correctly. Re-check the component setup.

    2. Select the push process and filter by mMi. Verify that the Xiaomi Push vendor token is obtained.

      If a log entry containing register_fail appears, Xiaomi Push registration has failed. Check the error reason in the Xiaomi Push error codes. If the reason is UNKNOWN, xiaomi_appid or xiaomi_appkey is usually incorrect. For the resultCode, see Xiaomi Push server-side error codes.

    3. Select the main process and filter by report channel token. Verify that the Xiaomi vendor token was reported successfully. If you see the following log entry, the vendor token report failed:

      report channel token error: xxxx

      Verify that base64Code has a value in the mPaaS configuration file. Also verify that the APK signature used when obtaining the configuration file matches the current app's signature.