HMS Core In-App Purchases can be easily integrated into apps to provide a high quality in-app payment experience for users. However, some developers may find that the payment screen of In-App Purchases cannot be opened normally. In this article, I will explain possible causes for this and provide solutions.
Scenario 1: In-App Purchases has been enabled on the Manage APIs page in AppGallery Connect, and the created product has taken effect. However, error code 60002 is recorded in logs.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Cause analysis
The payment public key is required for verifying the SHA256WithRSA signature of the In-App Purchases result. However, the developer has not configured a payment public key.
Solution
Check the following items:
(1) In-App Purchases has been enabled on the Manage APIs page. (The setting takes around half an hour to take effect.)
You can visit the official website to see how to enable the service.
(2) The public key switch is toggled on, and the public key is used correctly.
(3) The corresponding product category has been configured on PMS in AppGallery Connect, and has been activated successfully.
Scenario 2: Error 60051 is reported when the developer opens the subscription editing page in the member center.
According to the official website, error code 60051 indicates that a non-consumable product or subscription cannot be purchased repeatedly.
Cause analysis
After a subscription is completed, there is a refresh action when going back to the member center. An error will be reported if the subscription button is tapped again before the refresh occurs. The product can only be successfully subscribed to if the subscription button is tapped after the refresh. This is because if the refresh action is not triggered in time, cached data of the previous subscription will still exist. If another product is subscribed to immediately after a product is subscribed to, the ID of the previously subscribed product will be passed to the system instead of the newest product. As a result, an error is reported and the subscription editing page cannot be displayed due to product ID mismatch.
Solution:
Modify the timing for triggering the refresh action to prevent product subscription from occurring before the refresh.
Scenario 3: Error code 60003 is reported when a Huawei phone is used for payment debugging, but the product ID is correctly configured on PMS.
Cause analysis
Generally, error code 60003 indicates that the product information configured on PMS is incorrect. You can sign in to AppGallery Connect, click the desired app, go to Operate > Product Management > Products, and check that the corresponding product exists and mandatory information (such as the name, ID, price, type, and status of the product) is configured correctly.
In addition, you can check whether the product ID is correctly configured in the client code and consistent with that in AppGallery Connect. In particular, check that the field passed to the client code is correct.
Check whether the service region of the HUAWEI ID signed in on the Huawei phone supports In-App Purchases. To do this, call the Task<IsEnvReadyResult> isEnvReady() method.
Solution
After troubleshooting, the developer finds that the error is reported because the product ID passed to the client code is inconsistent with that in AppGallery Connect. After correcting the product ID in the client code, the issue is resolved.
Scenario 4: The payment screen is opened successfully when the checkout start API is called for the first time. However, after the payment is canceled, the payment screen fails to open when the API is called again.
Cause analysis
After a consumable product is purchased, the product can be purchased again only after the purchased product is consumed. Otherwise, error codes such as 60051 will be reported.
Solution
Redeliver the consumable product.
You need to trigger the redelivery process when:
The app launches.
Result code -1 (OrderStatusCode.ORDER_STATE_FAILED) is returned for a purchase request.
Result code 60051 (OrderStatusCode.ORDER_PRODUCT_OWNED) is returned for a purchase request.
Result code 1 (OrderStatusCode.ORDER_STATE_DEFAULT_CODE) is returned for a purchase request.
If the refund callback URL configured in the In-App Purchases configuration page is incorrect, reconfigure it correctly. You can click here for details.
In addition to the payment screen opening failure problem, another common problem is how to determine whether the sandbox environment is entered.
Scenario 5: A sandbox account is used for testing but no sandbox environment popup is displayed. How to check whether a sandbox environment is entered?
Cause analysis
Generally, a popup similar to the following will be displayed when the sandbox environment is entered.
The two mandatory conditions of the sandbox environment are met but still no sandbox environment popup is displayed. Does this mean that the sandbox environment is not entered?
The screenshot below shows relevant logs for the isSandboxActivated method.
According to the logs, the two mandatory conditions of the sandbox environment are met, which are:
The currently signed in HUAWEI ID is a sandbox account.
The version code is greater than that of the online version on AppGallery. (The APK has not been released to AppGallery. Therefore, the version code returned by AppGallery is 0.)
Theoretically, the sandbox environment has been entered. Are there other methods to check whether the sandbox environment is entered?
Solution
Check whether the sandbox environment is entered successfully using the following methods:
a) Check the returned purchase data, as shown in the screenshot below.
If the Huawei order ID specified in payOrderId begins with SandBox, the order is generated in the sandbox environment.
b) Check the payment report.
Check whether the payment report contains this order. If not, the order is generated in the sandbox environment. (Note: Data on the payment report is not updated in real time. If the order is placed on the current day, the developer can check the payment report on the next day to ensure accuracy.)
c) Clear the HMS Core (APK) cache.
You can try to clear the HMS Core (APK) cache. The system determines whether to display the sandbox environment popup based on relevant fields, which may not be updated in time due to the cache. You can go to Settings > Apps & services > Apps > HMS Core on the device to clear the cache.
References
In-App Purchases official website
In-App Purchases development guide
Related
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Earlier in my articles, we learn how to integrate Huawei Ads Kit in our application using Test Slot ID provided to us for testing purpose. Today we will see how to create one and monetize our app.
Let’s make some money
There are two types of developer account we will see at the time we sign up in Huawei Developer Website:
1) Individual Developer Account
2) Enterprise Developer Account
In order to create Ads Slot Id we must need to have an Enterprise Developer Account. For Individual Developer Account, there is no rights to create Ads Slot Id.
Essential Requirement
Create Enterprise Account
a) First we need to sign up in Huawei Developer Website.
b) After creating Huawei Developer Id, we will be provided with two option i.e. Individual or Enterprise Developer Account.
c) Select Enterprise Developer Account.
d) Provide all the necessary information in the form as shown below:
e) We can use either the DUNS number or Business license for identity verification for enterprise developers. It will 1 to 3 business days for verification.
Become a Merchant
We need to be a merchant in order to use HMS Ads Kit. Also after making your account as merchant, it will take 1 or 2 business days for verification.
Steps:
a) Login to Huawei Developer website.
b) Go to console.
c) Under Settings you will find Merchant Service as shown below:
d) Provide our bank details information here as shown below:
e) Provide our tax related information here as shown below:
f) Finally click submit to save the record for verification.
Huawei Ads Publisher Service Agreement
After the preceding steps are complete, use one of the following entries to sign in to Huawei Ads Publisher Service for further operations.
Steps:
Go to HUAWEI Developers > Console, and click Publisher service in App services. If no Publisher service card is displayed upon the first sign-in, click DIY in the upper right corner to add the Publisher service card. Read the HUAWEI Ads Publisher Service Agreement that is then displayed. If you agree, select by checking this box I confirm that I have read and agree to be bound by HUAWEI Ads Publisher Service Agreement. The agreement takes effect immediately. If you have signed the service agreement, you can view the signing record in My account and Download the agreement.
Steps To Create Ads Slot Id
Add an App
In order to create Ads Slot Id, we need to create first an app. This app will help us to connect Huawei Ads.
Steps:
a) Sign In to Huawei Account and select Publisher Service as shown below:
b) After selecting Publisher Service, we need to go to My apps and select Add app as shown below:
c) Select the app name from the drop down which we have already created in AGC. When we select the app from the drop down it will automatically fill up the rest. After that click Submit as shown below:
d) Finally it will look like this:
Add a unit / slot Id
Now we will add a unit or slot Id. Currently, HUAWEI Ads supports the banner, native, rewarded, interstitial, and splash ads. You can add units for the ad formats based on the app running status.
Steps:
a) On HUAWEI Ads Publisher Console, click My Apps, and click Add ad unit in the Operation column of an app as shown below:
b) We have to choose an ads format as shown below:
c) After selecting any ads format, fill in the unit information, including the name and media type, and complete advanced settings as required.
Banner Ads:
Splash Ads:
Reward Ads:
Native Ads:
Interstitial Ads:
eCPM: We can set the minimum eCPM for an ad unit. If the bid of an ad is lower than the minimum eCPM you set, the ad is not displayed. However, a too high minimum eCPM may lower the ad fill rate.
Frequency control: To ensure the experience of users, we can use this setting to control the number of ad impressions. The time unit ofFrequency controlcan be minute, hour, or day. If we select minute, the time cannot exceed 60 minutes. If we select hour, the time cannot exceed 24 hours. If we select day, the time cannot exceed 30 days.
For example, you setFrequency controltoUp to 1 impression for every user per 1 hour. In this way, when a user uses our app, the user can view up to one ad in the ad unit within one hour after the ad is displayed.
d) Click Save
e) Finally we will get the Ads Slot ID as show below:
How to use it?
Follow these articles to know how to use these Ads Slot IDs:
1) Reward Ads: https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201221846399980002&fid=0101187876626530001
2) Banner Ads:https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201230166492630050&fid=0101187876626530001
3) Splash Ads:https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201224203738280005&fid=0101187876626530001
4) Native Ads:https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201246549267010138&fid=0101187876626530001
5) Interstitial Ads:https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201246769882920150&fid=0101187876626530001
Conversion tracking can help you evaluate how effective your advertisements are, by analyzing whether user ad taps are converted into actions (such as browsing, registration, and purchase) that have tangible value to your business. It can also help you compare different channels and ad types, ensuring that you optimize ad placement, and improve the corresponding Return on Investment (ROI).
Here demonstrates how can we combine Dynamic Tag Manager (DTM) with HUAWEI Ads to provide next-level conversion tracking for ad landing pages.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
1. Creating a Conversion on HUAWEI Ads
Sign in to HUAWEI Ads, select Toolbox > Lead tracking, and click Add to create a conversion. Landing URL, Conversion goal, and DTM Conversion Name are all mandatory fields on the page that is displayed.
Notes:
l Landing URL: Enter the landing page URL to be tracked, which must be the same as that for your promotional task.
l Conversion goal: Select only one of the following conversion goals: Conversion and lifecycle, Form, Consulting, Other leads, Landing page performance, Game, Finance, and Social interaction.
l DTM Conversion Name: Enter a name related to the conversion tracking.
After entering the relevant information, click Submit to generate a conversion ID (saved for future use). Then click Using the Huawei Trace Code Manager to go to the DTM portal.
2. Configuring Tracking Tags Through DTM
If this is your first time using DTM, you can complete all necessary preparations by following the instructions in the Development Guide. After doing so, you'll be able to configure the tracking tags via DTM.
Click Create configuration, set the Configuration name and URL, and click OK. The JavaScript code will be generated. Copy the code and embed it to all web pages to be promoted (embedding is one-off and remains valid).
* Screenshots are from the test app.
Before managing related configurations, make sure that you know how to use DTM. Here is an example to help familiarize you with the operations. Let's assume that you want to track the number of user taps on the shopping cart button. You'll need to configure the conversion tracking for HUAWEI Ads into DTM. The trigger condition for the tracking is that the user taps the shopping cart button to go to the payment page. In this case, the following configurations should be implemented:
l Trigger condition: The user taps the shopping cart button, which triggers the tag to send the conversion tracking information.
l Tag: Use the built-in HUAWEI Ads conversion tracking tag and enter the conversion ID. When the trigger condition is met, the tag will be triggered to send the conversion information to HUAWEI Ads.
The detailed operations are as follows:
(1) Managing variables
l Click Variable > Configure preset variable on the DTM portal. Then select Page element > Element Text. For more information, please refer to Variable Management.
(2) Managing conditions
Click Condition > Create on the DTM portal. In the dialog box displayed, set Type to All elements, Trigger to Some clicks, Variable to Element Text, Operator to Equals, and Value to shopping cart. For more information, please refer to Condition Management.
(3) Managing tags
Configure the destination to which data is sent, after configuring the conditions for sending data. You can set HUAWEI Ads as the destination.
Click Tag > Create on the DTM portal. In the dialog box displayed, set Extension to HUAWEI Ads, Tracking ID to the above-created conversion ID, and Trigger condition to Clickshoppingcart, so that you can track the number of shopping cart button taps. For more information, please refer to Tag Management.
Conversion tracking is ready to go as soon as you have released a new configuration version. When a user taps the shopping cart button, an event will be reported to HUAWEI Ads, on which you can view the conversion data.
The evaluation of the ad conversion effects includes but is not limited to checking whether users place orders or make purchases. All expected high-value user behaviors, such as account registrations and message consulting, can be regarded as preparations for conversion. You can also add trigger conditions when configuring tags on DTM to suit your needs.
In addition, if the data provided by HUAWEI Ads does not end up helping you optimize your ad placement, after an extended period of time with an ad, you can choose to add required conditions directly via the tag management page on the DTM portal to ensure that you have a steady stream of new conversion data. This method provides for unmatched flexibility, and spares you from the need to repeatedly add event tracking. With the ability to add tracking events and related parameters via visual event tracking, you'll enjoy access to a true wealth of data.
The above is a brief overview for how DTM can help you track conversion data for landing pages. The service endows your app with powerful ad conversion tracking function, without even requiring the use of hardcoded packages.
To learn more about DTM, please visit:
l HUAWEI Developers
l Development Documentation
l Reddit to join the developer discussion
l GitHub to download the demo and sample code
l Stack Overflow to resolve integration-related issues
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Ads are everywhere and we can't escape them. They're on road billboards, shops, buses and buildings. If a world filled with ads sounds daunting and you want to hide indoors, just beware that ads will even jump out at you from your TV, computer, or phone.
It's likely that ads will be around with us for forever. Ads are often seen as annoying, but they can in fact be very helpful. If you are looking for a job, want to go somewhere fun, or are not sure what special thing you can get for your other half's birthday, ads may in fact provide some inspiration to you.
Nowadays, ads are transforming in appearance and purpose. Ads are becoming more intuitive as they are able to target specific audiences. For example, ads about quick fashion will target young adults, while some ads are typically pushed to males. This is an advanced advertising mechanism for brands, media, and users, where all can benefit. Someone gets traffic, someone makes money, and someone gets what they needed. Under ideal conditions, ads, under control and without harmful information spread, mean a lot for us.
As an app developer, I have been trying for a long time to request ads in my app to monetize the traffic and increase revenue. Recently, I encountered some obstacles with the ad traffic monetization data of my own app, and I have been searching for tools to obtain data and analyze ad performance. Collecting such data and then deciding how to analyze ad performance was no easy task, and this was complicated by the many tools and plugins needed to do so. I have used some of the tools found in the industry, but their performance rarely satisfied me.
But I eventually came across a very useful tool, the Publisher Service Reporting API of Ads Kit provided by HMS Core. The traffic monetization service helps me display various ad formats, such as banners, native ads, and rewarded ads, to my users. Routine data tracking is crucial for me to boost revenue. What's more, the Reporting API is key to obtaining ad monetization data, including ad requests, returned ads, impression rate, and click-through rate. I can analyze ad performance based on this data and adjust my monetization strategies accordingly.
But how did I acquire traffic monetization data? Here I'll tell you how I did it.
Implementation Procedure1. Obtain the client ID and key.
Before obtaining the monetization data, prepare an OAuth 2.0 client ID and key, which are needed for generating the access token passed for calling the Reporting API.
Note that the client ID and key are not those in App information (shown in the following red box) in AppGallery Connect, instead, the client ID and key of the server app created under HMS API services > Credentials on HUAWEI Developers.
a. Register as a developer and complete identity verification.
b. Sign in to the console, choose HMS API Services > Credentials, and create a project. If you already have a project, directly select it.
Click the drop-down arrow at the top, click New project, fill in the project name and alias, and click OK.
Select the project you created and click OK.
c. Choose OAuth 2.0 client ID.
If an OAuth 2.0 client ID and key already exist in your project, you can check whether the product type is server app by clicking Edit in the Operation column of the project. If so, skip step d.
If your product is not a server app, you should create an OAuth 2.0 client ID.
d. Select Server app from Product type, set Product name, App type, and Default language, and click Create. In the Note dialog box that displays Client ID and Key, click Confirm.
e. Go to HMS API services > My APIs, ensure that the project is the one you created, and click Add API from library.
f. Click Publisher Service Reporting API under App Services.
g. On the page displayed, click Enable to enable the API. Then you can call the API.
If you disable it and then enable it again, the setting does not take effect in real time due to page cache, for example. The setting will take about 6 to 10 minutes to take effect. If you have waited for longer time, try again.
2. Call the Publisher Service Reporting API.
a. Obtain an access token.
Call this API:
POST https://oauth-login.cloud.huawei.com/oauth2/v3/token
Request example:
Code:
POST /oauth2/v3/token HTTP/1.1
Host: oauth-login.cloud.huawei.com
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&
client_id=<Client ID>&
client_secret=<Client secret>
Screenshot:
Note that again: the client ID and key are those of the server app but not those of the mobile app created.
b. Call the Reporting API.
POST https://ads.cloud.huawei.com/openapi/monetization/reports/v1/publisher
If you are in Russia, call this API:
POST https://ads-drru.cloud.huawei.ru/openapi/monetization/reports/v1/publisher
Request example:
Code:
POST /openapi/monetization/reports/v1/publisher HTTP/1.1
Content-Type: application/json
Authorization: Bearer ***
Accept: application/json
Content-Length: 233
{
"start_date": "2022-06-01",
"end_date": "2022-06-28",
"filtering": {
"currency": "CNY"
},
"time_granularity": "STAT_TIME_GRANULARITY_DAILY",
"page": 1,
"page_size": 10
}
Screenshot:
As shown in the preceding figure, the data is successfully returned. For more request parameters and response parameters, click here.
In addition, I can customize data display formats to suit my specific app scenarios.
Some Problems You May EncounterWhy was message "access forbidden" returned during the API calling?
Some Problems You May EncounterWhy was message "access forbidden" returned during the API calling?
Possible causes:
You have not enabled the Reporting API.
You have not been authorized to call this API, or your permission has not taken effect yet.
The client ID and key used for obtaining the access token are not those of your server app.
My solutions:
1. Click Add API from library under My APIs and enable the Reporting API.
2. If you disabled and enabled the API again, you may need to wait for 6-10 minutes before the setting takes effect.
3. Check whether your client ID and key belong to a server app when you obtain the access token. To find out it, check the app type on the Credentials page. If it is not a server app, create one and use its client ID and key to request an access token.
ConclusionIf you also think obtaining ad monetization data and dealing with ad issues are annoying as me, you can try this tool to help you in daily work to obtain data and help you in subsequent operations. Hope that my procedure and experience can help more guys and you can also find out more useful methods.
HMS Core Health Kit provides app developers with access to atomic data. By calling its APIs, your app will be able to read and write users' health and activity data, after obtaining users' consent.
However, before your app is officially released, that is, in the development and test phases, a maximum of 100 users may use your app. This limit can be removed by applying for verification from Health Kit. Here I have listed some problems you may encounter during the application, as well as their solutions. I hope you find them helpful.
How long will it take for my application to be reviewed?Answer: The review takes about 15 workdays, and you will be notified of the result via SMS and email. If your application is rejected, modify your materials according to the feedback, and then submit your application again. The second review will take another 15 workdays. Please make sure you submit the correct materials for the review, to avoid any delays.
I have passed verification, but I can only query the data of a limited number of users. Why?Answer: Due to data caching, the approved scopes will take some time to take effect. Please wait for 24 hours after you have been verified, and then try again. Make sure that you reserve enough time for the approved scopes to take effect, so that your app can be released as scheduled.
If the problem persists, refer to this Error Code.
The proof that I submitted during the application was rejected. Why?Answer: When submitting an application for verification, fill in the App Release Checklist, and make sure that the proof you provide meets the criteria specified in the checklist.
Let's look at some common reasons why some forms of proof may be rejected.
App introduction video
Make sure that the video starts when your app is opened, so that Huawei can check whether the app name matches the one provided in the application.
Make sure that the video demonstrates how to perform basic operations, like granting the app authorizations, and accessing user data.
Make sure that the video demonstrates the privacy policy, in which the developer name must be identical to the one provided in the application.
Video demonstrating the user authorization
Make sure that the app name and app icon on the authorization screen are consistent with those provided in the application.
Make sure that the read/write scopes displayed on the authorization screen are consistent with those provided in the application. Please do not apply for scopes you are not going to use in your app.
If you are developing a mobile app, make sure that the authorization screen is properly displayed, that is, the parameter display is set to touch. For details, please refer to Authentication.
Video integrity
Make sure that the video for each check item covers all of the content specified in the checklist's acceptance criteria. A common reason for rejection is that the video does not accurately cover the end-to-end operation process. For example, for check item 3.2 Canceling authorization, the video should begin by showing how the app can access user data properly before authorization is canceled, and then proceed to canceling the authorization. If your video only depicts how authorization is canceled, your application will be rejected.
Data accuracy
Make sure that you provide screenshots showing the data consistency between your app and the Huawei Health app, for each data type. If there is no screenshot provided for a certain data type, this data type will be considered not in use in your app, and will not be approved.
Data timeliness (for REST access only)
If your app accesses Health Kit via REST, make sure that your app allows users to flexibly synchronize data manually, and demonstrate this in the video. Data that is manually synchronized to your app should be consistent with the latest data in the Huawei Health app.
If your app uses the data subscription function of Health Kit, your app should obtain the latest data from Huawei Health in real time, and this process also needs to be shown in the video.
Other documents
Provide other documents as required, for example, countries/regions where your app is to be released, list of scopes (including scopes in the application and the already approved ones), and more.
These are only some of the most common problems that you may encounter during the verification stage. You can check the App Release Checklist after selecting the Health Kit card on HUAWEI Developers for more information.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
What should I do if my application was rejected because the logo used was not acceptable?Answer: Check the HUAWEI Health Guideline and ensure your app complies with these guidelines when using the Huawei Health logo.
Please stay tuned for the latest HUAWEI Developers news and download the latest resources.
As an individual developer, can I apply for formal scopes?Answer: Individual developers cannot apply for formal scopes by applying for verification. A maximum of 100 users can be invited to use your app. This can only be removed by applying for a new HUAWEI ID, registering as an enterprise developer, and then applying for the Health Kit service.
Please note that advanced user data (such as heart rate, sleep, blood pressure, blood glucose, and SpO2 data) is not open to individual developers. To access advanced user data, create a HUAWEI ID and register as an enterprise developer before applying for access to Health Kit.
ReferencesHMS Core Health Kit
Developer Guide
FAQs About Accessing Health Kit
HUAWEI In-App Purchases (IAP) implements convenient in-app purchasing via either the service's SDK or its server.
Features and integration details of IAP are well illustrated in its official documents. I've used the service extensively for my apps and kept track of its issues (both from myself and other developers). Following on from my previous article that looked at the sandbox testing issue, this article will present FAQs related to other IAP aspects.
Question 1: The callback request of IAP is empty, containing no valid user information. Why?
Question details:
I integrated my app with HMS Core SDK 6.4.0.301 and IAP SDK 4.0. Users paid for a yearly subscription in the app, but the backend of my app didn't automatically deliver the subscription to users. I went to the order report in AppGallery Connect to redeliver the subscription to users, but the callback result was invalid.
To troubleshoot this issue, I used the test API. In the printed callback request of IAP, I discovered that the request body was an empty string that contained no valid user information. So I checked the official IAP document, which says that an app using IAP SDK 4.0 will not receive the payment success callback, so I'm not sure whether it is normal that my app received an empty callback.
Also, the subscription callback API of the IAP server would return 200 even upon an exception. The reason, I assume, was that the IAP server believed that my app had delivered the subscription to users. In this case, can product redelivery be triggered after the app is restarted?
Answer:
The official FAQs section for IAP illustrates what will happen after the redelivery button in the AppGallery Connect order report is clicked.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Normally, there will be no callback upon payment success. However, a callback containing an empty request body is actually not an issue, which can be ignored.
The redelivery process of the IAP SDK applies only to consumables, which needs to be triggered in the app integrated with the SDK in some specified scenarios, such as app startup. When an exception occurs during the process, an error code (like -1, 60051, or 1) will be returned, which you need to deal with according to the error description. More details can be found here.
As for subscriptions, notifications of key events are used. Click here for more details.
In no scenario would the IAP server send 200 upon an exception to your app server because the IAP server believes that your app has delivered the subscription to users. If you are not sure why your app server receives 200, you can submit a ticket online with the order number corresponding to the subscription in question for the technical support of IAP to look into.
Question 2: I submitted settlement sheets in September 2022, and the sheets have been stuck in the In payment state since then. However, the corresponding earnings have not been sent to my bank account. Why?
Answer:
The official Settlement document says that after a settlement sheet is submitted, the sheet will enter the In payment state. To receive the earnings, you may need to issue an invoice, according to where your app is released.
Specifically speaking, you are not required to issue an invoice if your products are distributed in countries or regions outside the Chinese mainland, and you have signed an online agreement with Huawei. According to Exhibit C of the HUAWEI Developers Merchant Service Agreement, Huawei will perform self-billing. To view and download invoices issued by Huawei, sign in to the console of HUAWEI Developers and go to My accounts > Credited. Find your settlement sheet and click Invoice.
If your app is released in the Chinese mainland, issue an invoice according to the official instructions.
Multiple settlements can be combined for invoicing in a single application. Such settlement sheets must have the same contract, service type, currency, signing entity, and prepayment term. It's also worth noting that the invoice amount must be the same as the amount sum of the combined settlement sheets.
For details about how to perform invoicing and other settlement-related instructions, go to the Self-service Settlement Guide.
Question 3: The official IAP document noted that it would gradually end support for the old domain names of AppGallery sites, TLS of earlier versions, and cipher suites. Are there any detailed instructions on how to replace the old domain names, TLS versions, or cipher suites with new ones?
Question details:
To ensure higher security and reliability for apps, IAP has changed its support for the domain names of AppGallery sites, TLS versions, and cipher suites. Specifically speaking, from April 2023, IAP will no longer support TLS earlier than 1.2 version or cipher suites that are not specified. The support for old domain names of AppGallery sites will be canceled in the near future.
Answer:
There is no guide document illustrating how to replace the old TLS versions or cipher suites, but the official IAP demo can serve as a reference.
The sample code of the API for verifying the purchase token of the order service is used as an example here, to show how to replace the old domain name. For example, for an app released to AppGallery in the China site, replace
https://orders-at-dre.iap.dbankcloud.com
with
https://orders-drcn.iap.cloud.huawei.com.cn
, which is the domain name of this site.
Click here for more information.
Question 4: I noticed that there is an expirationDate field in the subscription purchase data of users, which is returned by IAP. Is the time indicated by this field the same as the time when IAP bills the user account for renewing a subscription near the end of the current billing cycle?
Question details:
A user purchased a yearly subscription on December 5, 2021, and IAP returned the expirationDate string, which is a timestamp. On December 4, 2022, IAP automatically billed the user account for subscription renewal. However, the time indicated by the timestamp is December 8, 2022. My question is: Will IAP bill a user in advance for subscription renewal? If not, does this mean that the expirationDate time is not the same as the time of billing for subscription renewal? Which field should I refer to if I need to know the billing time for subscription renewal?
Answer:
In short, the time indicated by the expirationDate field is not the same as the billing time for subscription renewal.
Below is the official description of the expirationDate field in the InAppPurchaseData class.
In other words, this field indicates the time when a subscription expires.
According to the billing rule of IAP for a subscription, IAP tries to bill a user 24 hours before a subscription renewal. Therefore, it is normal that IAP billed the user account on December 4, 2022, which is within 24 hours before the current billing cycle ended (December 5, 2022). If billing fails, IAP will repeatedly attempt to bill the user within a specific duration. Once the maximum number of failed attempts has been reached, IAP will cease billing.
On top of this, the IAP server does not return the billing time for subscription renewal or provide any accurate billing time. Instead, the server provides the subscription renewal time that may be slightly earlier than the billing time.
If you find the difference between the subscription renewal time and the time indicated by expirationDate is too big, you can submit a ticket online with the subscription order number or subscription ID for troubleshooting.
References
Home page of HUAWEI IAP
Development Guide of HUAWEI IAP