1

HMS Core Push Service (Push Kit) is a message push platform provided by Huawei, which establishes a message push channel from the cloud to the terminal. By integrating push services, developers can push messages to client applications in real time, build good user relationships, and improve user awareness and activity.

The push service consists of two parts:

  • Message push channel from cloud to terminal: Developers can push data and messages to client applications in real time through the push service.
  • Terminal message display: Various types and styles of message display are located in the notification center, terminal desktop banner, and terminal lock screen.

For details, please refer to the following official documents:

https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/service-introduction-0000001050040060?ha_source=hms1

During the process of the application accessing the push service, the developer also reported to us some privacy security, error reporting, message delay and other issues. Here, the editor has made a summary analysis, hoping to provide developers with a reference and further improve the quality of services.

1. Privacy and security issues

The application uses Huawei push service , and the library is " com.huawei.hms:push:3.0.3.301 ". After listing on the Huawei AppGallery, it prompts: Dear developer, hello! During the review process, the system detects that your app has sensitive information about obtaining the user's software installation list, so it needs to be explained in the privacy policy. For example, the application obtains the software installation list information in the xx range through the xx method, covers the users in the xx range and uses the xx method. Serve xx functions.

Specific reference links:

https://developer.huawei.com/consumer/cn/doc/distribution/app/FAQ-faq Section 1.2, the final review result shall prevail.

"stackTrace":["android.app.ApplicationPackageManager.getInstalledPackages(ApplicationPackageManager.java:886)","com.huawei.hms.aaid.c.a.a(AaidUtils.java:91)","com.huawei.hms.aaid.c.a.b(AaidUtils.java:141)","com.huawei.hms.aaid.HmsInstanceId.getId(HmsInstanceId.java:97)","com.huawei.hms.aaid.HmsInstanceId.getToken(HmsInstanceId.java:179)"," 

Solution: SDK versions earlier than 5.1.1.301 will read the application list through the getInstalledPackages method, and the solution is to upgrade the version.

2. Precautions for desktop corner labels

1) add_num field

Support: EMUI version 8.0.0 (and above) push service application version 8.0.0 (and above)

set_num field

Support: EMUI version 9.1.0 (and above) push service application version 10.1.0 (and above)

2) Huawei desktop corner logo development

Supported platform and system version: EMUI 4.1 and above

Desktop version: 6.3.29

Supported devices: Huawei devices

3) Send message parameters, add_num parameters, integer type

Description: The applied subscript accumulates the number that is not actually displayed by the applied subscript, which is an integer greater than 0 and less than 100. For example, if an application currently has N unread messages, if add_num is set to 3, each time a message is sent, the number displayed by the app's subscript will add up to 3, which is N+3.

4) class parameter, String parameter, required parameter

Description: The full path of the application entry Activity class. Example: com.example.hmstest.MainActivity

5) set_num parameter, integer type

Description: Set the number of the corner label, an integer greater than or equal to 0 and less than 100. For example, if set_num is set to 10, no matter how many times the message is sent, the number displayed by the app banner is always 10. If set_num and add_num exist at the same time, set_num shall prevail.
(Note: When sending a message, set the number of the application subscript, "class" is required, and the "add_num" and "set_num" parameters are optional. If both "add_num" and "set_num" are set to be empty, the application subscript number is incremented by 1 by default. .)

3. Message delay problem

Some developers have reported that users are delayed for a few minutes before receiving push messages from the app. In response to this problem, since the volume of messages pushed by Huawei reaches tens of billions per day, the real-time arrival of a single message cannot be guaranteed. The official website has a relevant description: fully guarantee the delivery of messages in the notification bar, and the online arrival rate in ten minutes is as high as 99%. Thank you developers for your understanding and support!

4. Unable to receive push messages

Messages can be divided into two types: the notification bar message is displayed on the notification bar after it is received; the pass-through message is not displayed in the notification bar and the data is returned by the onMessageReceived callback method. Developers need to pay attention to first confirm the type of the message sent, and do not mistake the transparent transmission message as the notification bar message to send the false impression that the notification bar does not receive the message. Secondly, if the foreground_show field parameter is false, the data returned by the onMessageReceived callback method will not be displayed in the notification bar. After the problem is located, the solution is as follows:

1) The notification bar message cannot be received

  • Check whether the block message switch such as the app allow notification, channel notification switch, etc. is turned off.
  • Check whether the sent message is consistent with the terminal-side token, and try to re-obtain the push token to send the message.
  • You can select the push service on the AGC platform, self-analyze the message delivery status, or check whether the token is available.

2) The transparent transmission message cannot be received: confirm whether the application is alive. When the application is alive, whether it is in the foreground or background, the onMessageReceived callback method is used to return data after delivery, and the application cannot be received if it is killed.

5. Set custom ringtone

1) In the custom channel mode, the channel_id field is invalid when the data processing location of the application is China. That is to say, it is not feasible to set the ringtone through the custom channel method, and you can directly use the sound field to set it.

2) The ringtone resources must be placed in the /res/raw path of the application. The supported ringtone formats include MP3, WAV, MPEG, etc.

3) The format of the sound field parameter is: /raw/shake.

4) Before using the sound field, you need to create a channel, and it will be invalid after the channel is created. You can uninstall and reinstall the app, clear the data, and then test again.

6. Notification bright screen

1) Make sure the screen-on-screen switch is turned on, Settings->Notification Center->More notification settings->Notification screen-on prompt.

2) Make sure that the notification center lock screen notification master switch is turned on, go to Settings -> Notification Center -> Lock screen notifications.

3) Make sure the app notification channel switch is turned on, Settings->Notification Center->Your App->Select Channel->Lock Screen Notifications.

7. Detecting problems with implicit PendingIntent

At present, this problem has been fully resolved in version 6.3.0.302, please refer to the updated documentation for developers:
https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-app-version-0000001074227861?ha_source=hms1

8. The push interface returns 503

Error code 503 refers to flow control restrictions. The current default is 6000qps. It is recommended that the number of tokens sent each time does not exceed 100. You can call 60 each time and 100 times per second. For details, refer to the following link: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/faq-0000001050042183#section196822541234?ha_source=hms1

9. OnNewToke does not call back when getting token

1) Check whether there are multiple "services" inheriting the HmsMessageService class, and only one class inheriting HmsMessageService.

2) Check whether the test device is EMUI10 and above, if so, it will not call back, but directly return the token in the getToken method.

3) Whether to override the onNewToken(String token, Bundle bundle) method, the Push SDK version is lower than 5.0.4.302, please override the onNewToken(String token) method. You can override the onTokenError method to see if there is an error message returned.

4) If it is EMUI10 and above, and automatic token acquisition is configured, you need to check whether the configuration is correct, refer to the document (automatic initialization): https://developer.huawei.com/consumer/cn/doc/development/HMSCore -Guides/android-client-dev-0000001050042041#section13546121751811?ha_source=hms1

5) Check the manifest file, whether to register your own "service", which inherits the HmsMessageService class and is used to receive Token. Reference document (configuration manifest.xml file): https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-cfg-manifest-0000001050042037

6) Check whether the push switch is turned on: log in to the AppGallery Connect website,

  • a. Development-Overview-Gear icon on the right-API Management-Open the Push service.
  • b. Development - Growth Service - Push Service - Click Activation, and modify the service status to Activated.
  • In the above two cases, if the modification is just completed, it will take 15 minutes to take effect.

10. Error code: 907135000

在Service调用推送初始化:
public static void startPushService(Context c) {
    context = c;
    hwApi = new HuaweiApiClient.Builder(context)
            .addApi(HuaweiPush.PUSH_API)
            .addConnectionCallbacks(pushHw)
            .addOnConnectionFailedListener(pushHw).build();
    hwApi.connect();
}
连接有错误:@Override
public void onConnectionFailed(ConnectionResult result) {
    PluginLog.i(TAG, "onConnectionFailed, ErrorCode: " + result.getErrorCode() );
}
输出:PushHw: onConnectionFailed, ErrorCode: 907135000

Troubleshooting steps for error code 907135000:

1) Please check whether the app_id and package_name parameters in the "agconnect-services.json" file are consistent with those on the device side.

2) Please check whether the certificate signature is configured in the "build.gradle" file.

3) It may be caused by HMS Core (APK) cache, please uninstall and re-update HMS Core (APK), then disconnect the network and connect again, and then open the app.

4) It is recommended to use Huawei terminal to test first, Huawei push will rely on HMS Core (APK), and this application will be pre-installed on Huawei mobile phones, but not on non-Huawei mobile phones.

5) About the signature certificate: The signature file of your application must match the SHA256 fingerprint certificate generated with your signature file, and the place where the signature file is configured in the project must be consistent with the above two signature files.

6) Check the location of the pickup file, which should be in the project-level app directory.

7) Add the following configuration in the line under the file header apply plugin: 'com.android.application'.

apply plugin: 'com.huawei.agconnect' (whether apply plugin is added to the app module build file?)

8) Manually add the value of appid to the manifest to verify whether it is a configuration problem. for example:

<meta-data
android:name=“com.huawei.hms.client.appid”
android:value=“102729671” />

9) It may be a configuration confusion problem, please refer to: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-config-obfuscation-scripts-0000001050176973

For more details of HMS Core push service, please refer to:
https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/service-introduction-0000001050040060?ha_source=hms1

Huawei Developer Alliance official website
Get development guidance document
To participate in developer discussions, please go to Reddit community
download the demo and sample code, please go to Github
For integration issues please go to Stack Overflow

Learn more >>

Visit Huawei Developer Alliance official website
Get development guidance document
Huawei Mobile Services open source warehouse address: GitHub , Gitee

us and know the latest technical information of HMS Core for the first time~


HarmonyOS_SDK
596 声望11.7k 粉丝

HarmonyOS SDK通过将HarmonyOS系统级能力对外开放,支撑开发者高效打造更纯净、更智能、更精致、更易用的鸿蒙原生应用,和开发者共同成长。