Integrating HMS Account Kit in B4A Platform - Huawei Developers

More articles like this, you can visit HUAWEI Developer Forum and Medium.​
To integrate HMS Account kit in B4A platform we need to follow below steps
Step 1: Follow all the steps mentioned in Basic Setup to start HMS integration on B4A Platform
Refer to https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201286424114350051&fid=0101246461018590361
Step 2: Enable Account Kit in App gallery connect
{
"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"
}
Step 3: Download Account Kit AAR Package from below link
https://github.com/Arkesh-Unity/Account-Kit-in-B4A-Platform/tree/master/Addition
Step 4: Extract and rename the classes.jar --> hwid-4.0.1.300.jar and Androidmanifest.xml -> hwid-4.0.1.300.xml
Step 5: Add hwid-4.0.1.300.jar file to libs
Step 6: get the below marked content from hwid-4.0.1.300.xml and add it to manifest in B4A IDE
Step 7: Create below marked java files
 1) Account.java file is used as communicator between B4A and java code
  2) AccountAuthWork.java file contains code for Authentication code implementation
  3) AccountWork.java file contains code for IdToken implementation
Step 8: Compile and generate B4A library
Step 9: Enable library in B4A IDE
Step 10: Add below code in B4A project to call the methods written for account kit
Refer code : https://github.com/Arkesh-Unity/Account-Kit-in-B4A-Platform

Related

Problems and Troubleshooting During Cocos Integration with AGC Services

Some problems may occur when the APM SDK is integrated into a Cocos-based app and during app release. This article summarizes some common problems and talks about how to deal with them.
1. Problem: Error message "[NDK Root] is empty, please set [NDK Root] in Preferences." is displayed when you build an Android project for the first time, indicating that the NDK is unavailable.
Cause: The Android NDK and Android SDK paths are not configured when the project is built.
Solution: Go to File > Settings... in Cocos Creator, click the Native Develop tab page, and set Android SDK Root and NDK Root.
{
"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"
}
You can obtain the required Android SDK and NDK paths from Android Studio, as shown in the following figures.
Copy and paste the preceding paths to Cocos Creator, and go back to the Build... page for further operations.
Note: In some cases, a default NDK path may not exist. You can download the NDK here in Android Studio.
2. Problem: Error message "TypeError: Cannot read property 'xxx' of undefined." is displayed.
Cause: A script with the same name exists on the computer. This problem may occur regardless of whether the scripts of the same name are in the same folder.
Solution: Ensure that each script has a unique name by renaming or deleting scripts.
3. Problem: Error message "Task:game:externalNativeBuildReleaseFeature" is displayed during compilation, but the building process is normal.
Cause: The path contains special characters or is too long.
Solution: Place the project folder in the root directory and ensure that the project file name does not contain special characters. Then delete the build folder and try again.

Super-Simple Obtaining the Summary Value of a Quick App

Such an API is not provided in Quick App Specification, but you can obtain the digest value of a file using the third-party library crypto-js.
1. Check whether the third-party library dependency file package.json exists in the quick app project directory. If not, go to NPM > Start Npm Library to start the third-party dependency library in Huawei Quick App IDE. Then, the package.json file is generated.
2. Go to NPM > Npm Install to install the dependency.
3. Switch to the TERMINAL tab page in the IDE console and access the root directory of the quick app project. Run the npm i -S crypto-js command to install the crypto-js library.
{
"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"
}
4. After the installation is complete, the crypto-js dependency is automatically added to the package.json file.
5. The sample code for calculating the digest value of a file in a quick app is as follows:
HTML:
import sha256 from 'crypto-js/sha256';
import MD5 from 'crypto-js/md5';
genSha256: function (e) {
const msg = this.testdata;
this.sha256value = sha256(msg);
},
genMD5: function () {
const msg = this.testdata;
this.md5value = MD5(msg);
},
For more details, please refer to:
development document of crypto.js: https://www.npmjs.com/package/crypto-js

What Can I Do If the agconnect-services.json File Content Cannot Be Obtained When Integrating the HMS Core SDK to a Unity-based Game?

Problem
Recently, a project team integrated the HMS Core SDK for a Unity-based game.
They integrated the HMS Core SDK in Android Studio and generated a JAR file. However, the agconnect-services.json file downloaded from AppGallery Connect could not be used in Unity.
It is found that it was not the first occurrence of this problem. The general solution is to modify the manifest file, for example, by adding the following code:
XML:
<meta-data android:name=”com.huawei.hms.client.appid” android:value=”appid=103091591" />
After this, the team successfully called related APIs of Account Kit and HUAWEI In-App Purchases. But error messages were displayed during app launches, indicating that the problem came from the integration of HUAWEI Analytics.
{
"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"
}
According to the error message, HUAWEI Analytics may use other parameters in the JSON file, which have not been added to the manifest file. They tried to add the following parameters about HUAWEI Analytics to the manifest file, but they didn’t work.
XML:
<meta-data android:name="com.huawei.hms.agcgw.url" android:value="url=connect-dre.hispace.hicloud.com" />
<meta-data android:name="com.huawei.hms.agcgw.backurl" android:value="backurl=connect-dre.dbankcloud.cn" />
<meta-data android:name="com.huawei.hms.service.analytics.collectorurl" android:value="collectorurl=datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn"/>
<meta-data android:name="com.huawei.hms.service.analytics.resourceid" android:value="resourceid=p1"/>
Troubleshooting
Finally, they contacted Unity technical support for a solution.
1. Save the JSON file obtained from AppGallery Connect to the Plugins/Android directory of Unity.
2. As Unity provides the HMS Core SDK plug-ins and a demo app, place the AfterBuildToDo script in the demo app in the Editor folder of your own project.
URL for downloading the Unity demo app:
https://github.com/Unity-Technologies/HMSSDKSample
The script is stored in Assets/HuaweiHms/src/Editor/AfterBuildToDo.cs.

How Can I Use the HUAWEI Game Service Demo Provided by Unity? - Part2

The Content of part1 is here.
Generating and Configuring a Signing Certificate Fingerprint
Use the preceding signature file to generate a signing certificate fingerprint by referring to Huawei documentation, and configure the fingerprint in HUAWEI AppGallery Connect.
https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/appgallerykit-preparation#h2-1604304489444
{
"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"
}
Packaging and Running the Demo
Step 1: Choose Android from the Platform area, and click Switch Platform.
Step 2: Click Build And Run and select the preceding signature file.
If this message is displayed, you can manually delete useProguard in the launcherTemplate.gradle file.
In this example, the following two lines are deleted.
Package and run the demo again.
Step 3: Check whether the packaged demo is normal.
Once you have packaged and run the demo, the following page is displayed.
Click Init. A message is displayed, indicating that the operation is successful.
Click Login and then login. The HUAWEI ID sign-in page is displayed, indicating that the demo is running successfully.
You can view the method of calling APIs for the demo in the following file in Unity, and call the corresponding APIs.
Note: If the sign-in page is not displayed, and the 6003 result code is returned, the signature fingerprint may be inconsistent. For details about how to fix this problem, check this post: What Can I Do When Result Code 6003 Is Returned?
Part1 of this thread: https://forum.xda-developers.com/t/...rovided-by-unity-part1.4212917/#post-84224243

What should I do when error code 60002 ("iap not activated") is reported and the payment page cannot be opened?

Problem:
I was testing in-app purchases for my app but the payment page failed to launch. The log information is as follows.
{
"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"
}
I checked the error code description in the official materials and found that it was because HUAWEI IAP wasn’t enabled. I checked the switch, and found that IAP has been enabled, but the problem persisted.
Analysis:
To resolve the problem, toggle on the IAP switch and configure IAP parameters, as shown in the following figures.
Document for enabling a service
2. If you used Android Studio to integrate the IAP SDK, download agconnect-services.json again by referring to the following figure and save the file to your app’s module directory of your project.
If you use Eclipse to integrate the SDK, check whether the appid and cpid parameters are correctly configured in the Manifest file.
Sample code:
XML:
<meta-data
android:name="com.huawei.hms.client.appid"
<!-- Replace xxx with the actual app ID, which can be obtained on the App information page. - ->
android:value="appid=xxx">
</meta-data>
<!-- Replace xxx with the actual payment ID, which can be obtained from the app's IAP information. -->
<meta-data
android:name="com.huawei.hms.client.cpid"
android:value="cpid=xxx">
</meta-data>
3. Once you have finished the preceding steps, if the problem still exists, wait for a while and try again, because there may be a one-hour delay due to cache issues.

Categories

Resources