Error When Web Components Send a Message to an HTML5 Page - Huawei Developers

What Happened?​When Web Components send a message to an HTML5 page, the following JS error is reported:
02–14 09:22:56.329 E/jsLog (18834): [H5]Uncaught TypeError: system.onmessage is not a function
Why Did It Happen?
If the system.onmessage function defined in an HTML5 page involves a large amount of logic, the function may reference external JavaScript libraries, for example, jQuery. In this case, if Web Componets trigger this.$element(‘webElementId’).postMessage({message:’xxx’}) in the function for handling onpagefinish events, referenced JavaScript libraries may fail to load fully. As a result, the error “system.onmessage is not a function” is reported.
How to Resolve the Problem?
Ensure that the system.onmessage function in the HTML5 page only contains the necessary logic, that is, receiving data transmitted from a quick app page. You can leave other logic, for example, handling onload events, to lifecyle functions of the HTML5 page for processing.
Note that data from the quick app is not received once the onload event is triggered. In this case, the HTML5 page needs to listen to data receiving in polling mode. To achieve this, refer to the following sample code.
{
"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"
}
The following code is not recommended.
Suggestions and Summary​You should understand the mechanism for sending messages between a quick app and an HTML5 page. Then use the polling mode to solve the asynchronous data transmission problem.

Related

A Case Study of Resolving 403 Error During PMS API Call

Recently, a developer needed to access HUAWEI AppGallery Connect API and create a product through the PMS API (server API). However, when Postman was used for basic service interconnection tests, the error message "403 client token authorization fail" was displayed.
{
"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"
}
They checked the error code description and found that the error was caused by an authentication failure.
1. To solve the problem, they first confirmed that the client ID used for applying for the token had sufficient permission.
2. The official document suggested that the project associated with the API client be selected as N/A. They created an API client and associated it with a project. An app ID in this project was 100xxx591. However, the app ID in the Postman service request was 101xxx531, which might have caused the authentication failure.
3. To verify the assumption, they created an API client and selected N/A (indicating that all projects are supported) and used the client to request a token. The process then went well.
To draw a conclusion, If Huawei's 403 authentication failure occurs, you can verify the permission first, and then check the associated projects.
Reference:
For details about the PMS API, please refer to:
https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/agcapi-addproduct
For more details, you can go to:
Official website
Development Documentation page, to find the documents you need
Reddit to join our developer discussion
GitHub to download demos and sample codes
Stack Overflow to solve any integration problems

Resolving HTTP 502 Error During Leaderboard API Calls

Symptom:
When the getRankingIntent API is called, which is related to leaderboards, the following error message is displayed.
{
"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"
}
Log Information
The following error information is displayed in the Android Studio Logcat logs:
HTML:
2020-10-22 11:14:17.831 27218-3850/com.huawei.gameassistant W/HwGameAssistant-10.6.0.301-RequestHelper: client.assistant.gs.leaderboard.scores reponse fail code:502, msg:Bad Gateway
2020-10-22 11:14:17.831 27218-3850/com.huawei.gameassistant E/HwGameAssistant-10.6.0.301-GameRankingScoreListViewModel: getHttpStatusCode is : 502
Troubleshooting
The test result shows that the game sign-in function is normal. Therefore, the problem is not caused by a network error. After studying relevant documents, we checked the following items:
1. First, we ensured that the package name and app ID belong to the same game.
2. Then, we checked whether leaderboards have been created for the game in HUAWEI AppGallery Connect. It was found that leaderboards have been added for another game. We attempted to resolve the problem. However, testing shows that the problem still persists.
3. Finally, it was found that the account we used for testing is not on the list of test accounts in AppGallery Connect. After adding it to the list and clearing HMS Core (APK) cache on the phone, the problem is solved.
Summary:
If you find that the leaderboard function is abnormal, ensure that:
The app ID and the package name belong to the same game.
Your game has its leaderboard data created in AppGallery Connect.
Your test account has been added in AppGallery Connect.
For more details, check:
Adding a Leaderboard:
https://developer.huawei.com/consumer/en/doc/distribution/app/agc-add_leaderboard
Managing Tester Accounts:
https://developer.huawei.com/consumer/en/doc/distribution/app/agc-tester_account_mgt

Resolving HTTP 502 Error During Leaderboard API Calls

Symptom:
When the getRankingIntent API is called, which is related to leaderboards, the following error message is displayed.
{
"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"
}
Log Information
The following error information is displayed in the Android Studio Logcat logs:
2020-10-22 11:14:17.831 27218-3850/com.huawei.gameassistant W/HwGameAssistant-10.6.0.301-RequestHelper: client.assistant.gs.leaderboard.scores reponse fail code:502, msg:Bad Gateway
2020-10-22 11:14:17.831 27218-3850/com.huawei.gameassistant E/HwGameAssistant-10.6.0.301-GameRankingScoreListViewModel: getHttpStatusCode is : 502
Troubleshooting
The test result shows that the game sign-in function is normal. Therefore, the problem is not caused by a network error. After studying relevant documents, we checked the following items:
1. First, we ensured that the package name and app ID belong to the same game.
2. Then, we checked whether leaderboards have been created for the game in HUAWEI AppGallery Connect. It was found that leaderboards have been added for another game. We attempted to resolve the problem. However, testing shows that the problem still persists.
3. Finally, it was found that the account we used for testing is not on the list of test accounts in AppGallery Connect. After adding it to the list and clearing HMS Core (APK) cache on the phone, the problem is solved.
Summary:
If you find that the leaderboard function is abnormal, ensure that:
The app ID and the package name belong to the same game.
Your game has its leaderboard data created in AppGallery Connect.
Your test account has been added in AppGallery Connect.
For more details, check:
Adding a Leaderboard:
https://developer.huawei.com/consumer/en/doc/distribution/app/agc-add_leaderboard
Managing Tester Accounts:
https://developer.huawei.com/consumer/en/doc/distribution/app/agc-tester_account_mgt

Why Doesn’t My Game’s Trial Play Function Take Effect?

Symptom​I have integrated the trial play function provided by the HMS Core Game Service SDK 5.0.1.302 into my game and completed the following as instructed by the official documentation:
Applying to enable the forcible identity verification function.
Adding code snippet for implementing trial play to my game code.
However, when my game was launched and the identity verification pop-up was displayed, the trial play option was not available, which means that the function did not take effect.
Analysis​It was the first time I integrated the HMS Core SDK, so I contacted Huawei technical support. I was informed of some of the prerequisites for enabling the trial play function:
1. The integrated Game Service SDK version must be 5.0.1 or later.
2. The forcible identity verification has been enabled.
3. Code relating to the trial play function has been added.
4. The default authorization parameter of the game must be DEFAULT_AUTH_REQUEST_PARAM_GAME.
We have met the first three, but not the last one.
{
"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"
}
Solution​Finally, I modified my code by referring to the documentation, and it worked! Hope this post can offer you some help!
Am not sure but check the code for suttle errors
Tennaric said:
Am not sure but check the code for suttle errors
Click to expand...
Click to collapse
this is just a sample code. you can refer to this site to confirm the correct usage. you can even download the sample code in github.

Release an app for AppGallery in China region

In order to publish an application for China we need to get a Software Copyright Certificate https://forums.developer.huawei.com/forumPortal/en/topic/0203480680985250017
So basically we need to register our application.
Registration site https://ccopyright.com.cn/
First, we need to apply for developer authorization https://register.ccopyright.com.cn/real.html#/realApplyPeople
I am stuck on it, so I have not yet reached the registration of the application.
The site itself is in Chinese, so I use Google Translate for its pages. There is http://www.ccopyright.com/en/, but there is nothing you can find to submit any applications, just a little information in English, limited version.
We can apply for developer authorization using our foreign passport.
But in the registration form there are two items for which we need to upload images (photos) of our documents.
The first item requires two images (the second image is some kind of translation of the document, well, usually foreign passport already have both native language and English version on the same page, so I don't really understand what second image should be, so I just duplicated the photo of my foreign passport twice).
The second item also requires image (third one), I added a photo of my country's national passport)
{
"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"
}
But it didn't work:
The first image was apparently correct (foreign passport), I need to understand what is needed for the second image (some translation, maybe into Chinese) and the third image (second item)
Has anyone tried to register there?

Categories

Resources