This topic describes how to integrate Mi Push. The process includes the following three steps.
Register Mi Push
To complete the registration for Mi Push, refer to the following official Mi documents:
Integrate Mi Push
Add the Push - Mi component. The method is the same as for adding the Push SDK. For more information, see Add the Push SDK.
The current built-in Mi Push SDK version is 4.0.2. For previous versions, see Release notes.
Configure the
AndroidManifest.xmlfile and replace the values ofxiaomi_appidandxiaomi_appkey. If you use component-based development, add the 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>
Test Mi Push
After you integrate Mi Push, start the application on a Mi phone and make sure the initialization method is called. For more information, see Message Push Service initialization. The Push SDK automatically retrieves and reports the Mi Push vendor token.
Push a test message after killing the application process:
If you receive the message, it means the application has successfully integrated Mi Push.
If you cannot receive the message, follow the steps below to troubleshoot the issue.
Troubleshoot issues
Verify that the
AndroidManifest.xmlconfiguration is added and that the values ofxiaomi_appidandxiaomi_appkeymatch those on the Mi Open Platform.Verify that the Mi channel is enabled in the mPaaS console and that its configuration matches the one on the Mi Open Platform. For more information, see Configure the Mi Push channel.
Check the logcat logs to troubleshoot the issue:
Select the push process and filter by
mPush.PushProxyFactory. Check for the following log entry:D/mPush.PushProxyFactory: found proxy com.mpaas.push.external.mi.CreatorIf this log entry does not exist, there may be an issue with adding the Push - Mi component. Verify that the Mi Push component is added correctly.
Select the push process and filter by
mMi. Verify that the Mi Push vendor token is obtained.If a log entry containing
register_failappears, the Mi Push registration has failed. For more information about the errorreason, see Mi Push error codes. If the reason is UNKNOWN, thexiaomi_appidorxiaomi_appkeyis usually incorrect. For more information about theresultCode, see Mi Push server-side error codes.Select the main process and filter by
report channel token. Verify that the Mi vendor token was reported successfully. Check for the following log entry:report channel token error: xxxxThis log entry indicates that reporting the vendor token failed. Verify that
base64Codehas a value in the mPaaS configuration file. Also, verify that the APK signature you uploaded when you obtained the configuration file matches the signature of the current application.