Super-Simple Obtaining the Summary Value of a Quick App - Huawei Developers

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

Related

Integrating HMS Account Kit in B4A Platform

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

H5 to QuickApp CLI: Create projects using the command line

Hi everyone!
In this post I will introduce a Command Line Interface that I published to create H5 to QuickApps in a different way.
{
"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"
}
As in the above figure, my aim was to write one-line to create a quick app and then input application parameters with an interactive way.
Basically this commands can be used to create a single app:
Code:
npx [user=10925755]@onurkenis[/user]/create-quick-app # run via npx without installing
In another way, we can define properties inline and missing properties will be asked respectively, just like in the previous figure.
Code:
npx [user=10925755]@onurkenis[/user]/create-quick-app
--appName="My App"
--packageName=com.onurkenis.myApp
--url=https://github.com/onurkenis/create-quick-app
--icon=./icon.png
There is another mode to create quick apps which is batch app creation. This mode allows us to give a json file instead of app properties and we are able to create many projects at once that we added to our json file.
This is the structure of the JSON file and number of applications to add is up to us.
Code:
{
"projects": [
{
"appName": "TestApp1",
"packageName": "com.onurkenis.one",
"url": "https://github.com/onurkenis/create-quick-app",
"icon": "C:/Pictures/optional_icon.jpg"
},
{
"appName": "TestApp2",
"packageName": "com.onurkenis.two",
"url": "https://github.com/onurkenis/create-quick-app"
},
{
"appName": "TestApp3",
"packageName": "com.onurkenis.three",
"url": "https://github.com/onurkenis/create-quick-app"
}
]
}
To create multiple QuickApps with the created JSON, this commands can be triggered:
Code:
npx [user=10925755]@onurkenis[/user]/create-quick-app --fromJson=path_of_json # run via npx without installing
To get rpk file, you can do followings and check PROJECT_PATH/dist folder.
Code:
cd PROJECT_PATH
npm install
npm run release
If you want to check out my project in github or npm, here are the links.
Github: /onurkenis/create-quick-app
Npm: /@onurkenis/create-quick-app
All suggestions are welcomed.
Thanks.

Does a quick app provide the API for obtaining the digest value of a file?

Does a quick app provide the API for obtaining the digest value of a file? For example, the API for obtaining the SHA256 or MD5 value of a file.
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"
}
1. After the installation is complete, the crypto-js dependency is automatically added to the package.json file.
2. The sample code for calculating the digest value of a file in a quick app is as follows:
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);
},

How to Use LayaAir IDE to Split the Package of a Quick Game and Load Subpackages?

Question:
How to use LayaAir IDE to split the package of a quick game and load subpackages?
Guide:
Splitting the package of a Huawei quick game and loading its subpackages help reduce the traffic and time required for app download. By doing so, you can choose to load or download specific subpackages, instead of the whole package at a time.
Procedure:
1. Release a subpackage in LayaAir IDE.
To split a package, select Set the subcontract during project release, as shown in the following figure.
{
"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"
}
Then, click the plus sign (+) below. The following window is displayed. Set the subpackage name and the corresponding folder.
2. Configure subpackage information in the manifest file.
You also need to set parameters for the subpackages in the manifest.json file. The sample code is as follows:
Note: If you split a resource package manually, the values of resource should end with a slash (/). In addition, a game.js file must exist in the directory. (Skip this step if you let LayaAir IDE split the package for you.)
XML:
subpackages:[
{
"name":"subpackageName1",// Subpackage name.
"resource":"subpackagePath1"// Corresponding subpackage directory.
},
{
"name":"subpackageName2", // Subpackage name.
"resource":"subpackagePath2"// Corresponding subpackage directory.
}
]
3. Apply specific subpackages.
The sample code for using specific subpackages is as follows:
JavaScript:
var task = hbs.loadSubpackage({
subpackage:'subpackageName1',
success : function () {
console.log("loadSubpackage success" );
},
fail:function(){
console.log("loadSubpackage fail");
},
complete:function() {
console.log("loadSubpackage complete");
}
});
task.onprogress(
callback(res) {
console.log("onProgress" + JSON.stringify(res));
}
);

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