You can use the quick app web component to quickly package an HTML5 game into a quick game. As long as the URL of the original HTML5 game remains unchanged, the quick app does not need to be upgraded, which reduces the maintenance workload.
You can package a quick game in the Quick App IDE in just 7 steps.
1. Download the Quick App IDE from Installing the Development Tool and install it on your PC.
2. Go to File > New Project > New QuickApp Project and create a project. Choose HTML5 Game in Template.
App Name: app name, which corresponds to the name field in the manifest.json file.
Package Name: app package name, which corresponds to the package field in the manifest.json file.
{
"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"
}
Click Ok to create a quick game project.
Configure the manifest.json file.
package: quick game package name. Once the game is released, the package name cannot be changed. Otherwise, the game cannot be upgraded.
name: quick game name.
versionName: quick game version name. The value must be increased by 1 upon upgrade. For example, if the name of the source version is 1.0.0, the name of the target version must be 2.0.0.
versionCode: quick game version number. The value must be increased by 1 upon upgrade. For example, if the number of the source version is 1, the number of the target version must be 2.
icon: quick game logo used in a shortcut icon created on the home screen. Replace logo.png with the HTML5 game icon.
minPlatformVersion: minimum platform version with which an app is compatible, which functions like the Android API level. You are advised to set the platform to the latest version, for example, version 1070, to avoid incompatibility.
Code:
{
"package": "com.huawei.quickgamedemo",
"name": "QuickGameDemo",
"versionName": "1.0.0",
"versionCode": 1,
"icon": "/Common/logo.png",
"minPlatformVersion": 1070,
"features": [
{
"name": "system.prompt"
},
{
"name": "service.pay"
},
{
"name": "service.account"
}
],
"permissions": [
{
"origin": "*"
}
],
"config": {},
"router": {
"entry": "Hello",
"pages": {
"Hello": {
"component": "hello"
}
}
},
"display": {
"titleBar": false,
"fullScreen": true
}
}
Edit the .ux file for loading the HTML5 game. The project takes hello.ux as an example.
src: URL of the HTML5 game.
fullscreendirection: game orientation. Both landscape and portrait orientations are supported.
jumppolicy: URL redirection policy within the game. If ads are integrated into the game, you are advised to set this parameter to browser and set the value of multiwindow to true.
allowthirdpartycookies: indicates whether cross-domain cookies transfer is supported. The default value is false. If a web page needs to access cookies across domains, for example, in the scenario of sign-in with a third-party account, set this parameter to true.
trustedurl: Set this parameter if the launch page is different from the loading page displayed after a user has successfully signed in.
6. Go to Tools > Certificate to check whether a formal certificate has been generated. If no certificate is generated, click Create to generate one and save it to the sign > release directory of the project. Keep the file properly as it cannot be retrieved once lost.
7. Go to Build > Run Release to package a formal .rpk package, which is stored in the dist directory of the project.
Note: The .rpk file for release on AppGallery must be packaged following the preceding method.
The final directory structure of the quick game project is as follows:
Now, you have successfully packaged the HTML5 game into a quick game. If you want to integrate more functions into the game, or test and run your game, please refer to the Quick Game Development Guide (HTML5).
Related
You can use the quick app web component to quickly package an HTML5 game into a quick game. As long as the URL of the original HTML5 game remains unchanged, the quick app does not need to be upgraded, which reduces the maintenance workload.
You can package a quick game in the Quick App IDE in just 7 steps.
1. Download the Quick App IDE from Installing the Development Tool and install it on your PC.
2. Go to File > New Project > New QuickApp Project and create a project. Choose HTML5 Game in Template.
l App Name: app name, which corresponds to the name field in the manifest.json file.
l Package Name: app package name, which corresponds to the package field in the manifest.json file.
{
"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"
}
3. Click Ok to create a quick game project.
4. Configure the manifest.json file.
l package: quick game package name. Once the game is released, the package name cannot be changed. Otherwise, the game cannot be upgraded.
l name: quick game name.
l versionName: quick game version name. The value must be increased by 1 upon upgrade. For example, if the name of the source version is 1.0.0, the name of the target version must be 2.0.0.
l versionCode: quick game version number. The value must be increased by 1 upon upgrade. For example, if the number of the source version is 1, the number of the target version must be 2.
l icon: quick game logo used in a shortcut icon created on the home screen. Replace logo.png with the HTML5 game icon.
l minPlatformVersion: minimum platform version with which an app is compatible, which functions like the Android API level. You are advised to set the platform to the latest version, for example, version 1070, to avoid incompatibility.
Code:
{
"package": "com.huawei.quickgamedemo",
"name": "QuickGameDemo",
"versionName": "1.0.0",
"versionCode": 1,
"icon": "/Common/logo.png",
"minPlatformVersion": 1070,
"features": [
{
"name": "system.prompt"
},
{
"name": "service.pay"
},
{
"name": "service.account"
}
],
"permissions": [
{
"origin": "*"
}
],
"config": {},
"router": {
"entry": "Hello",
"pages": {
"Hello": {
"component": "hello"
}
}
},
"display": {
"titleBar": false,
"fullScreen": true
}
}
3. Edit the .ux file for loading the HTML5 game. The project takes hello.ux as an example.
l src: URL of the HTML5 game.
l fullscreendirection: game orientation. Both landscape and portrait orientations are supported.
l jumppolicy: URL redirection policy within the game. If ads are integrated into the game, you are advised to set this parameter to browser and set the value of multiwindow to true.
l allowthirdpartycookies: indicates whether cross-domain cookies transfer is supported. The default value is false. If a web page needs to access cookies across domains, for example, in the scenario of sign-in with a third-party account, set this parameter to true.
l trustedurl: Set this parameter if the launch page is different from the loading page displayed after a user has successfully signed in.
4. Go to Tools > Certificate to check whether a formal certificate has been generated. If no certificate is generated, click Create to generate one and save it to the sign > release directory of the project. Keep the file properly as it cannot be retrieved once lost.
5. Go to Build > Run Release to package a formal .rpk package, which is stored in the dist directory of the project.
Note: The .rpk file for release on AppGallery must be packaged following the preceding method.
The final directory structure of the quick game project is as follows:
Now, you have successfully packaged the HTML5 game into a quick game. If you want to integrate more functions into the game, or test and run your game, please refer to the Quick Game Development Guide (HTML5).
For details about Huawei developers and HMS, visit the website.
https://forums.developer.huawei.com/forumPortal/en/home?fid=0101246461018590361
You can use the quick app web component to quickly package an HTML5 game into a quick game. As long as the URL of the original HTML5 game remains unchanged, the quick app does not need to be upgraded, which reduces the maintenance workload.
You can package a quick game in the Quick App IDE in just 7 steps.
1. Download the Quick App IDE from Installing the Development Tool and install it on your PC.
2. Go to File > New Project > New QuickApp Project and create a project. Choose HTML5 Game in Template.
*App Name: app name, which corresponds to the name field in the manifest.json file.
Package Name: app package name, which corresponds to the package field in the manifest.json file.
{
"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"
}
3. Click Ok to create a quick game project.
4. Configure the manifest.json file.
package: quick game package name. Once the game is released, the package name cannot be changed. Otherwise, the game cannot be upgraded.
name: quick game name.
versionName: quick game version name. The value must be increased by 1 upon upgrade. For example, if the name of the source version is 1.0.0, the name of the target version must be 2.0.0.
versionCode: quick game version number. The value must be increased by 1 upon upgrade. For example, if the number of the source version is 1, the number of the target version must be 2.
icon: quick game logo used in a shortcut icon created on the home screen. Replace logo.png with the HTML5 game icon.
minPlatformVersion: minimum platform version with which an app is compatible, which functions like the Android API level. You are advised to set the platform to the latest version, for example, version 1070, to avoid incompatibility.
HTML:
{
"package": "com.huawei.quickgamedemo",
"name": "QuickGameDemo",
"versionName": "1.0.0",
"versionCode": 1,
"icon": "/Common/logo.png",
"minPlatformVersion": 1070,
"features": [
{
"name": "system.prompt"
},
{
"name": "service.pay"
},
{
"name": "service.account"
}
],
"permissions": [
{
"origin": "*"
}
],
"config": {},
"router": {
"entry": "Hello",
"pages": {
"Hello": {
"component": "hello"
}
}
},
"display": {
"titleBar": false,
"fullScreen": true
}
}
3. Edit the*.ux file for loading the HTML5 game. The project takes hello.ux as an example.
src: URL of the HTML5 game.
fullscreendirection: game orientation. Both landscape and portrait orientations are supported.
jumppolicy: URL redirection policy within the game. If ads are integrated into the game, you are advised to set this parameter to browser and set the value of multiwindow to true.
allowthirdpartycookies: indicates whether cross-domain cookies transfer is supported. The default value is false. If a web page needs to access cookies across domains, for example, in the scenario of sign-in with a third-party account, set this parameter to true.
trustedurl: Set this parameter if the launch page is different from the loading page displayed after a user has successfully signed in.
4. Go to Tools > Certificate to check whether a formal certificate has been generated. If no certificate is generated, click Create to generate one and save it to the sign > release directory of the project. Keep the file properly as it cannot be retrieved once lost.
5. Go to Build > Run Release to package a formal*.rpk package, which is stored in the dist directory of the project.
Note: The*.rpk file for release on AppGallery must be packaged following the preceding method.
The final directory structure of the quick game project is as follows:
Now, you have successfully packaged the HTML5 game into a quick game. If you want to integrate more functions into the game, or test and run your game, please refer to the Quick Game Development Guide (HTML5).
After the quick app web component is used to pack an HTML5 app into a quick app, the original web page does not provide the function of returning to the home page. In an HTML5 quick app, users want to have an entry for returning to the home page when browsing any HTML5 page.
To implement this requirement, perform the following steps:
1. Define the loadUrl variable under data in the page script. This variable is used to store the URL of the HTML5 web page. In this demo, the Huawei official website is used as the home page entry.
HTML:
export default {
props: ['websrc'],
data: {
title: "",
// TODO Replace the link to the H5 app
loadUrl: "http://www.huawei.com/en",
allowThirdPartyCookies: true,
//Attribute supportzoom, indicates whether the H5 page can be zoomed with gestures.
supportZoom: true,
wideViewport: true,
overViewModeLoad: true,
},
}
2. Modify template code.
Bind the src attribute of web in template to the variable loadUrl defined in step 1.
Listen to the pagestart event of the web component, that is, onpagestart in the code.
Add the entry layout of returning to the home page, which needs product design. This demo uses an image as an example.
The sample code is as follows. Pay attention to the text in red to see the modification points.
HTML:
<template>
<div class="doc-page">
<image src="/Common/main.png" onclick="goMain"></image>
<web class="web-page" src="{{loadUrl}}" trustedurl="{{list}}" onpagestart="onPageStart" onpagefinish="onPageFinish"
onmessage="onMessage" ontitlereceive="onTitleReceive" onerror="onError" id="web" supportzoom="{{supportZoom}}"
wideviewport="{{wideViewport}}}" overviewmodeinload="{{overViewModeLoad}}" useragent="{{userAgent}}"
Precautions:
The event callback methods goMain and onPageStart in the preceding code must be defined in the script.
The value of src in the image component must be replaced with the actual image path in the project.
3. Modify the code in the script. The following code needs to be modified:
In the callback method onPageStart of the web component, assign the value of url (indicating the URL of the current page) to loadUrl.
HTML:
onPageStart(e) {
console.info('pagestart: ' + e.url)
this.loadUrl=e.url;
},
l In the goMain method, assign the home page URL to loadUrl.
HTML:
goMain: function () {
console.log("goMain :");
this.loadUrl = "https://www.huawei.com/en";
},
Then, you can click HUAWEI on the screen to go to the Huawei official website.
{
"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. Environment
SDK Version:agconnect-storage:1.3.0.300
Platform:Cocos Creator
Device:HUAWEI P40 Pro
AppGallery Connect:
https://developer.huawei.com/consumer/en/service/josp/agc/index.html
2. Enabling and Configuring Cloud Functions in AppGallery Connect
Note: Currently, Cloud Functions is still under beta state. To use the service, you need to send an email for application. For details, check:
https://developer.huawei.com/consum...allery-connect-Guides/agc-cloudfunction-apply
1. Create an app first and add it to a project, or select an app from the project list on the My projects page in AppGallery Connect.
Under the project, go to Build > Cloud Functions, and click Enable now.
2. Create a function based on the description in the following codelab.
https://developer.huawei.com/consumer/en/codelab/CloudFunctions/index.html#4
3. Create an HTTP trigger and save the suffix of the value of Trigger URL in the Details area as the trigger identifier of future client requests.
{
"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"
}
3. Integrating the Cloud Functions SDK in Cocos Creator
1. Integrate the SDK.
Official documentation:
https://docs.cocos.com/creator/manual/en/cocos-service/agc-applinking.html
1. On the Service panel of Cocos Creator, find Cloud Functions. Currently, the Cloud Functions SDK supports only the Android platform.
2. Before integrating a service, you need to associate the service with an app. Click Association. In the dialog box that is displayed, click Create. The Cocos console is displayed.
3. On the Cocos console, create a game.
4. Go back to Cocos Creator and create, refresh, or select an association.
5. Return to the Cloud Functions page, and enable the service.
2. Download the JSON file.
1. Go to Project settings in AppGallery Connect and download the latest agconnect-services.json file.
2. Save the downloaded agconnect-services.json file to the settings directory in your Cocos project.
4. Configuring the UI Layout
Configure buttons for triggering a cloud function, obtaining the timeout interval, and setting the timeout interval separately.
5. Cloud Functions Development
1. Initialize Cloud Functions in the start block.
Code:
start () {
this._func = huawei.agc.func.funcService;
},
2. Call Cloud Functions with input parameters.
Code:
callWithParam:function() {
this._func.wrap("testcodelab-$latest").call((err, data) => {
if (err !== null) {
console.log("Cloud Function", `error: ${JSON.stringify(err)}`);
}
console.log("Cloud Function", `result: ${JSON.stringify(data)}`);
}, {
year: "2020",
}
);
},
3. Call Cloud Functions without input parameters.
JavaScript:
callWithoutParam:function() {
this._func.wrap("testcodelab-$latest").call((err, data) => {
if (err !== null) {
console.log("Cloud Function", `error: ${JSON.stringify(err)}`);
}
console.log("Cloud Function", `result: ${JSON.stringify(data)}`);
});
},
4. Obtain and set the timeout interval of a function.
JavaScript:
setTime:function() {
this._func.wrap("testcodelab-$latest").setTimeout(100,3);
console.log("Cloud Function", `setTime: ` + 100);
},
getTime:function() {
let currTime = this._func.wrap("testcodelab-$latest").getTimeout();
console.log("Cloud Function", `currTime: ` + currTime);
},
6. Packaging and Testing
In Cocos Creator, go to Project > Build…, package an Android app, and install it to your device. To verify the functions, click the buttons from top to bottom.
If the following information is displayed in JavaScript logs, the integration is successful.
7. Summary
Cloud Functions allows you to keep all functions and related code on the cloud side. You only need to call the wrap.call method to trigger the functions, which reduces the code amount and package size of your APK package.
For more details, please check:
Cloud Functions development guide:
https://developer.huawei.com/consum...connect-Guides/agc-cloudfunction-introduction
Cocos documentation:
https://docs.cocos.com/creator/manual/en/cocos-service/agc-cloudfunc.html
The Huawei AppGallery Connect Crash service is a free to use crash analytics service which is supported on a wide range of platforms and frameworks.
Today lets take a look at how we can use in in a Xamarin, a hybrid framework and specifically set it up to work on iOS devices. This guide will start with a blank application but of course you can just as easily follow along and integrate into a pre-existing application!
Preparing the Xamarin Environment and Configuring Your ProjectYou need to install Visual Studio for MAC first, and then select Mobile development with .NET in Visual Studio to install the Xamarin environment.
{
"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"
}
Create a project in AppGallery Connect and enable HUAWEI Analytics.
Right-click your project and choose Manage NuGet Packages.
Find the Huawei.Agconnect.iOS.Crash package and install it.
Find the Huawei.Agconnect.iOS.AgconnectCore package, select the 1.2.0.300 version, and install it.
Add the plist file from your AppGallery Project to the project directory.
Set Build Action to BundleResource.
Developing Your AppStart by Configure the layout of your app for the testing of the crash service, in this example we will create three buttons to trigger different tests.
Double-click main.storyboard to launch Xcode, and create the MakeCrash, CatchException, and CustomReport buttons
In the MainActivity.cs file, call AGConnectCrash.Instance.TestIt to trigger a crash, call AGConnectCrash.Instance.SetUserId to set a custom user ID, call AGConnectCrash.Instance.SetCustomKey to set the key and value for a custom key-value pair, call AGConnectCrash.Instance.Log to set the log level, and call AGConnectCrash.Instance.RecordException to record a non-fatal exception.
This could look something like:
Code:
using System;
using UIKit;
using Huawei.Agconnect.Crash;
using Foundation;
namespace crashios0512
{
public partial class ViewController : UIViewController
{
public ViewController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// You can configure additional functions as required.
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Delete the cached data or images that are no longer used.
}
partial void MakeCrash(UIKit.UIButton sender)
{
AGCCrash.GetSharedInstance().TestIt();
}
partial void CatchException(UIKit.UIButton sender)
{
AGCCrash.GetSharedInstance().RecordError(new Foundation.NSError());
}
partial void CustomReport(UIKit.UIButton sender)
{
AGCCrash.GetSharedInstance().SetUserId("testuser");
AGCCrash.GetSharedInstance().Log("default info level");
AGCCrash.GetSharedInstance().SetCustomValue(new NSString("test"), "this is string value");
AGCCrash.GetSharedInstance().LogWithLevel(AGCCrashLogLevel.Warning, "this is warning log level");
AGCCrash.GetSharedInstance().SetCustomValue(new NSNumber(123), "this is number");
}
}
}
View Crash ReportTap MakeCrash, CatchException, and CustomReport in sequence, and check the report in AppGallery Connect.
View the crash statistics.
Check the exceptions
Diagnose the causes of exceptions.
Check the custom key-value pairs.
View the custom log levels
View custom user IDs.
For details, please refer to:
Crash for iOS
Codelab of Crash for iOS
Will it works on offline?
will its benefit for us or not? Epoxy Flooring Atlanta