This article describes the integration process of HONOR Push, which includes the following three steps.
Register HONOR Push
login HONOR development official website, registered account and open push service. For more information, see Enable the push function.
Integrate HONOR Push
Add the Push> HONOR component in the same way as you add the push SDK. For more information, see Add a push SDK.
NoteThe Push> HONOR component contains only the adaptation code and does not contain the HONOR Push SDK. You can add the HONOR Push SDK dependency separately as follows.
Prepare the development environment. The development environment must be compatible with the integration environment of HONOR Push. For more information, see Prepare the development environment.
Add a configuration file. Download the
mcs-services.json
configuration file from the HONOR Developer Service Platform. For more information, see Add an application configuration file.configure the repository address of the sdk. For more information, see Configure the Maven repository address of the SDK.
Add dependency configurations. In the application-level
build.gradle
file, add the following compilation dependencies to the dependencies field:dependencies { // Add the following configuration implementation 'com.hiHONOR.mcs:push:7.0.61.302' }
For more information, see Add dependencies.
For more information about how to update the version, see Version information.
The current version of mPaaS is 7.0.61.302. If you want to use a later version, you can modify it as required. Generally, the manufacture SDK will backward compatible it.
To use obfuscation, add the relevant obfuscation configuration:
You must add the Obfuscation Script for all access methods.
If you use the AAR access method, you must add a confusion rule.
Test HONOR Push
Please note that the following (excluding 8.0) versions of HONOR Magic OS 8.0 will continue to use the Huawei push adaptation layer.
After you enable HONOR Push, you can start the application on the HONOR mobile phone and make sure that the initialization method is called. For more information, see Quick start. Then, the push SDK obtains the token of the HONOR Push provider and reports the token.
You can push a test message when the application process is killed:
If you still receive messages, your application is successfully connected to HONOR Push.
If you cannot receive the message, troubleshoot the issue as follows.
Troubleshoot issues
Check whether the HONOR configuration and parameters are consistent with the HONOR push background, whether the relevant configuration is added in the
AndroidManifest.xml
, and whether thecom.hiHONOR.push.app_id
is consistent with the HONOR push background.Check whether the
mcs-services.json
file exists and whether the storage location is correct.Check whether the HONOR channel is enabled in the mPaaS console. For more information, see Configure the HONOR channel.
View the logcat logs for troubleshooting:
Select the push process, filter the
mPush.PushProxyFactory
, and check whether the following logs exist:D/mPush.PushProxyFactory: found proxy com.mpaas.push.external.HONOR.Creator
Select the main process, filter mHONOR, and check whether the token is obtained. If a log
get token failed
appears, the token fails to be obtained. For error codes, see Error codes.Select the main process, filter the
report channel token
, and check whether the reporting HONOR manufacturer token is successful. If the following log appears:report channel token error: xxxx
This indicates that the manufacture token fails to be reported. Please check whether the
base64Code
in step 3 to add the configuration file to the project has a value and whether the apk signature uploaded when obtaining the configuration file is consistent with the current application.If the Push> HONOR component is not available, an error may occur when you add the HONOR component. Check whether the HONOR component is added.
Others
What models and system versions are supported?
At present, HONOR's manufacturer push channel supports HONOR mobile phones with Magic OS version 8.0 and above. Versions below Magic OS version 8.0 (excluding 8.0) continue to use Huawei's manufacturer push channel.