You need to complete the development of the following services for an AppGalleryKit app.
Service | Mandatory or Optional (Chinese Mainland) | Mandatory or Optional (Outside the Chinese Mainland) | Description |
Mandatory | Optional |
| |
Optional but strongly recommended | Optional | It is recommended that HUAWEI Analytics be initialized upon app launch so that you can collect and analyze app basic data. | |
Mandatory | Optional |
| |
Optional but strongly recommended | Optional but strongly recommended | It is recommended that AppGalleryKit apps integrate Auth Service to uniformly manage users signed in with multiple authentication modes, including HUAWEI IDs, WeChat accounts, email accounts, and anonymous accounts, without the hassle of building an authentication system for the apps separately. | |
Conditionally optional | Optional |
| |
Mandatory | Mandatory | Integrate this service for your AppGalleryKit app. | |
Recommended | Not supported | Integrate this service if your AppGalleryKit app needs to display product information on the app details page. This service now supports only apps released in the Chinese mainland. | |
Recommended | Recommended | It is recommended that AppGalleryKit apps integrate Crash to detect and resolve app crashes promptly. | |
Recommended | Recommended | It is recommended that AppGalleryKit apps integrate A/B Testing to compare app versions for performance metrics. |
When a user taps the app icon to start the app, initialize the app in the background so that statistics about app use can be collected and in-app bulletins can be displayed.

The user taps the app icon on the mobile device to start the app.
The app executes its startup program and loads the required resources. The startup program is created by the developer.
In the startup program, the app calls JosApps.getJosAppsClient method to obtain the JosAppsClient instance.
HMS SDK returns the current JosAppsClient instance of the app.
The app calls JosAppsClient.init to initialize the app.
If an in-app bulletin has been configured on AppGallery Connect, HMS SDK displays the bulletin page to the user.
This scenario is mandatory in Mainland China and optional in other countries and regions.
It is recommended that the app be initialized upon app startup, rather than during user operations such as sign-in and payment.
If your app provides a privacy agreement for users, it should call the init API after the user has accepted the privacy agreement.
The key steps for achieving this function are as follows:
Call JosApps.getJosAppsClient to initialize the JosAppsClient object and JosAppsClient.init to initialize the app.
When the app is initialized upon startup, signInHuaweiId in getJosAppsClient can be null.
- private void init() {
- JosAppsClient appsClient = JosApps.getJosAppsClient(this, null);
- appsClient.init();
- Log.i(TAG, "init success");
- }
No result will display after init is called, and no action is required from your app.
HUAWEI Analytics predefines a large number of analytics models to help you clearly understand user behavior and gain in-depth insights into users, products, and content. As such, you can carry out data-driven operations and make strategic decisions about app marketing and product optimization.
AppGalleryKit requires that the HUAWEI Analytics service be initialized after an app is started, in order to collect automatically collected events. Automatically collection events are classified into the following types:
System events: These events are triggered when an app is started for the first time and when an app updates. They are automatically collected by HUAWEI Analytics Kit after the HUAWEI Analytics service is initialized. For details about system events, please refer to System Events.
Activity-based screen events: These events are triggered during activity startup and exit. They are automatically collected by HUAWEI Analytics Kit after the HUAWEI Analytics service is initialized. For details about activity-based screen events, please refer to Activity-based Screen Events.
For details about the automatically collected events, see Automatically Collected Event.
Restrictions on Different Terminal Platforms.
In principle, HUAWEI Analytics is supported on all Android devices on which the HMS Core(APK) is installed.
For non-Huawei Android devices (such as Xiaomi, VIVO, OPPO, Samsung, Coolpad, and ZTE), the HMS Core(APK) must be installed. Some mobile phone brands may delete Huawei processes, leading to data report exceptions.
HUAWEI Analytics is not supported on iOS devices.
As a data processor, HUAWEI Analytics does not proactively collect the personal data of users. The developer needs to determine which personal data should be collected based on the applicable laws and regulations, and protect users' privileges regarding their personal data.
Initialize HUAWEI Analytics Kit when the app is started.
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- //Enable the SDK log.
- HiAnalyticsTools.enableLog();
- HiAnalyticsInstance instance = HiAnalytics.getInstance(this);
- }
After being initialized, HUAWEI Analytics Kit automatically collects system events and activity-based screen events. You can conduct basic data analysis by using relevant HUAWEI Analytics functions. For details, please refer to Huawei Analytics User Guide.
If you wish to use more advanced event analysis functions such as defining and reporting present events and custom events, please refer to Huawei Analytics Development Guide。
For details about how to upgrade an app, please refer to Updating the App.
If your app needs to support user sign-in using third-party accounts (such as HUAWEI IDs, WeChat accounts, QQ numbers, and Facebook accounts), email addresses, mobile numbers, and anonymous accounts, you may need to build a user authentication system on your server to centrally manage all these sign-in functions, which costs much in system building and O&M.
That's when Auth Service of AppGallery Connect comes into the picture. With the service, you do not need to purchase any extra server or build an authentication system by yourself. You only need to call Auth Service APIs on your app client to implement functions such as user registration and sign-in. This will greatly shorten the development period and reduce development costs.
Auth Service does not depend on HUAWEI Account Kit. It supports multiple authentication modes, including HUAWEI ID, WeChat, Tencent QQ, Facebook, Weibo, Google, Twitter, email address, mobile number, and anonymous account. You can use it to manage user sign-ins uniformly for apps to be distributed to any app store. In addition, Auth Service is not limited to Huawei devices. It can also run on non-Huawei devices and iOS devices.
You are advised to integrate Auth Service before integrating HUAWEI Account Kit for AppGalleryKit apps. For details, please refer to Auth Service Development Guide.
You need to integrate the HUAWEI ID service to your AppGalleryKit app. For details, please refer to HUAWEI Account Kit Development Guide.
You need to integrate the HUAWEI IAP service to your AppGalleryKit app. For details, please refer to HUAWEI IAP Development Guide.
You can create a product in the Product Management System (PMS) of AppGallery Connect, package the product for marketing, and display the product publicity image, product name, and product description on their app details screen in AppGallery.
The function is available only for apps released in the Chinese mainland.
Out-of-app purchase for PMS-managed products supports the following payment modes:
DeepLink: When a user taps to purchase a product in AppGallery, the user will be redirected to your app and be instructed to complete payment and delivery in your app.
- Redemption code: You can configure redemption codes in advance in HUAWEI AppGallery Connect. After a user uses a redemption code to purchase a product in AppGallery, Huawei server instructs your server to complete the product delivery.
- HMS Core: When a user taps to purchase a product in AppGallery, Huawei HMS Core initiates a payment request. After the payment is complete, Huawei server instructs your server to complete the product delivery.
To implement the DeepLink mode, you simply need to set DeepLink when you Configure product Marketing Information. When a user taps to purchase your product, the user will be redirected to the address specified by DeepLink. The subsequent payment and delivery process is the same as that of in-app purchase. For details, please refer to HUAWEI IAP Development Guide.
In redemption code payment mode, you only need to configure redemption codes by referring to Virtual Product and your delivery address when Managing Product Marketing. No extra coding is required.
To use HMS Core to initiate payment, you need to develop the direct purchase and missed order query functions. This section describes how to develop these functions.
You have configured product marketing information by referring to Configuring Product Marketing Information.

Receiving a delivery notification:
1. After the direct purchase is successful, Huawei server calls the Delivery Notification API to instruct the developer's server to deliver the product to the user.
Request
- POST {Third-party app server url} HTTP/1.1
- Content Type : application/json ; charset=UTF-8
- {
- "data": {
- "developerId": "234234234",
- "appId": "1231333",
- "orderId": "sdfsfff32324324234234",
- "productNo": "product344",
- "openId": "openId13123",
- "count": 1,
- "ts": 12312313123131123
- },
- "sign": "string"
- }
2. Obtain the public key for verifying the order information. For details, please refer to Obtaining the Public Key for Signature Verification.
3. After receiving the delivery notification, verify the sign field in the delivery notification by referring to the Signature Verification Example and return the processing result to Huawei server according to the queried order data.
Response
- {
- "error": {
- "errorCode": 0,
- "errorMsg": "string"
- }
- }
- or
- {
- "data": {
- "result": 0
- }
- }
4. Deliver the product based on the product ID and user information.
Proactive notification of delivery success
1. Create an API client for accessing Huawei server APIs. For details, please refer to Creating an API Client.
You need to create the API client only once to call desired APIs.
2. Call the Obtaining a token to obtain the access token used for API client authentication.
3. After the delivery is successful, call the Delivery Success Notification API to send a notification to Huawei server with the access token. Then Huawei server updates the order status as instructed.
Request
- {
- "orderId": "string",
- "productNo": "string",
- "openId": "string",
- "status": 0
- "ts": 12312313123131123
- }
Response
- {
- "error": {
- "errorCode": 0,
- "errorMsg": "string"
- }
- }
- or
- {
- "data": {
- "result": 0
- }
- }
If the delivery notification fails for a direct purchase, order missing occurs. In this case, Huawei server marks the order as not delivered. When an app is started, it needs to check whether the current HUAWEI ID has missed orders. If so, the app instructs the developer's server to deliver involved products. After the developer's server successfully delivers products, the developer's server notifies Huawei server of the delivery success. Huawei server then changes the order status to delivered.

1. Call the JosApps.getProductClient method to initialize the ProductClient instance when your app is started.
- ProductClient productClient = JosApps.getProductClient(this);
2. Call the ProductClient.getMissProductOrder method to query missed orders.
This step is optional and only intends to detect whether a HUAWEI ID has signed in to the current device. Data query with specific data usage purposes will be performed in Step 4.
For a device signed in with a HUAWEI ID, the HMS SDK queries missed order data. If no HUAWEI ID has signed in to the current device, no data will be returned.
- productClient.getMissProductOrder(this)
- .addOnSuccessListener(new OnSuccessListener<ProductOrderList>() {
- @Override
- public void onSuccess(ProductOrderList productOrderInfos) {
- if (productOrderInfos == null) {
- LogUtil.i("QueryDPSMissProductList", "not have miss product");
- return;
- }
- StringBuffer stringBuffer = new StringBuffer();
- for (ProductOrderInfo productOrderInfo : productOrderInfos) {
- stringBuffer
- .append("TradeId:").append(productOrderInfo.getTradeId()).append("\r\n")
- .append("ProductNo:").append(productOrderInfo.getProductNo()).append("\r\n")
- .append("OrderId:").append(productOrderInfo.getOrderId()).append("\r\n")
- .append("Sign:").append(productOrderInfo.getSign()).append("\r\n")
- .append("--------------\r\n:");
- }
- LogUtil.i("QueryDPSMissProductList", stringBuffer.toString());
- }
- }).addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(Exception e) {
- if (e instanceof ApiException) {
- ApiException apiException = (ApiException) e;
- LogUtil.i("QueryDPSMissProductList", "getMissProductOrder failed:" + apiException.getStatusCode());
- }
- }
- });
3. Instruct the user to authorize access to your app using his/her HUAWEI ID.
To improve user experience, it is recommended that you associate users' HUAWEI IDs with your own account system so that users can view orders placed using both HUAWEI IDs and accounts in your system.
4. Call the ProductClient.getMissProductOrder method again to query missed orders.
5. Call the ProductOrderInfo.getSign method to obtain the signature from order information and verify the signatureby the Public Key in the Obtaining the Public Key for Signature Verification . For details how to verify the signature, please refer to Verifying the Signature for Missed Orders.
6. After the signature is verified, instruct the developer's server to deliver involved products to the user. The developer's server sends a delivery success notification to Huawei server. For details, please refer to Delivery Success Notification.
The Crash service of AppGallery Connect is a lightweight service that can be quickly integrated into your app without coding to implement crash analysis, so you can learn about your app's crash details through the crash report provided by this service in real time. For details, please refer to Crash Development Guide.
A/B Testing is used for making comparisons. For example, you can create multiple implementation solutions to achieve a specific objective, let some users use solution A and some others use solution B, and then select a proper solution based on user feedback to improve the decision-making efficiency and reduce the decision risks. For details, please refer to A/B Testing Operation Guide.