Integrate Xiaomi Push into your mPaaS app so notifications are delivered on Xiaomi devices when the app process is killed.
Register Xiaomi Push
Before integrating, complete both steps on the Xiaomi Developer Platform:
Integrate Xiaomi Push
-
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.
-
Configure
AndroidManifest.xmlwith the AppID and AppKey from the Xiaomi Developer Platform. Replacexiaomi_appidandxiaomi_appkeywith 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
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.
-
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
Verify that
AndroidManifest.xmlis configured and that the values ofxiaomi_appidandxiaomi_appkeymatch those on the Xiaomi Open Platform.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.
-
Check the logcat logs:
-
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.CreatorIf this entry is missing, the Push - Xiaomi component was not added correctly. Re-check the component setup.
-
Select the push process and filter by
mMi. Verify that the Xiaomi Push vendor token is obtained.If a log entry containing
register_failappears, Xiaomi Push registration has failed. Check the errorreasonin the Xiaomi Push error codes. If the reason is UNKNOWN,xiaomi_appidorxiaomi_appkeyis usually incorrect. For theresultCode, see Xiaomi Push server-side error codes. -
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: xxxxVerify that
base64Codehas 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.
-