This topic describes how to integrate HONOR Push into your app using mPaaS, including registering the push service, adding the SDK dependency, and verifying the connection.
Integrate HONOR Push into your app using mPaaS in three steps:
Register HONOR Push
Log in to the HONOR Developer portal, create an account, and enable the push service. For details, see Enable the push function.
Integrate HONOR Push
-
Add the Push > HONOR component the same way you add a push SDK. For details, see Add a push SDK.
NoteThe Push > HONOR component contains only the adaptation code, not the HONOR Push SDK itself. Add the HONOR Push SDK dependency separately as described in the following steps.
Prepare your development environment to meet the HONOR Push integration requirements. For details, see Prepare the development environment.
Add the configuration file. Download the
mcs-services.jsonfile from the HONOR Developer Service Platform. For details, see Add an application configuration file.Configure the Maven repository address for the SDK. For details, see Configure the Maven repository address of the SDK.
-
Add the dependency to the app-level
build.gradlefile:dependencies { // Add the following configuration implementation 'com.hiHONOR.mcs:push:7.0.61.302' }For more details on dependency configuration, see Add dependencies.
For SDK version history, see Version information.
mPaaS currently bundles version 7.0.61.302. You can upgrade to a later version — the manufacturer SDK is generally backward compatible.
-
If your build uses obfuscation, add the required obfuscation configuration:
Add the obfuscation configuration for all integration methods.
For the AAR integration method, also add an obfuscation rule.
Test HONOR Push
HONOR devices running Magic OS versions below 8.0 continue to use the Huawei push adaptation layer.
Launch the app on an HONOR device and confirm that the initialization method is called (see Quick Start). The push SDK then retrieves the HONOR Push token and reports it.
-
Kill the app process and push a test message:
If the message arrives, the app is successfully connected to HONOR Push.
If the message does not arrive, troubleshoot using the steps below.
Troubleshooting
Verify that the HONOR configuration parameters match the HONOR push backend: confirm that
AndroidManifest.xmlcontains the required configuration entries and thatcom.hiHONOR.push.app_idmatches the value in the HONOR push backend.Confirm that the
mcs-services.jsonfile exists and is placed in the correct directory.Confirm that the HONOR channel is enabled in the mPaaS console. For details, see Configure the HONOR channel.
-
Check the logcat logs:
-
In the push process, filter by
mPush.PushProxyFactoryand verify that the following log appears:D/mPush.PushProxyFactory: found proxy com.mpaas.push.external.HONOR.Creator In the main process, filter by
mHONORand check whether a token was obtained. If the log showsget token failed, the token request failed. See Error codes for resolution steps.-
In the main process, filter by
report channel tokenand check whether the HONOR manufacturer token was reported successfully. If the following log appears, the token report failed:report channel token error: xxxxCheck whether the
base64Codein step 3 to add the configuration file to the project has a value, and that the APK signature used when obtaining the configuration file matches the current app's signature.If the Push > HONOR component is missing, the HONOR component may have failed to initialize. Verify that the component was added correctly.
-
Other issues
What models and system versions are supported?
HONOR's manufacturer push channel supports HONOR devices running Magic OS 8.0 and above. Devices running Magic OS below 8.0 use Huawei's manufacturer push channel instead.