Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Starting from version 1078, the API prefix has been changed from hbs to qg. The original prefix hbs is still supported.
API | Description |
|---|---|
Exits the current quick game. | |
Obtains the launch parameters of the quick game. | |
Listens for the event that a quick game is switched to the background. | |
Stops listening for the event that a quick game is switched to the background. | |
Listens for the event that a quick game is switched to the foreground. | |
Stops listening for the event that a quick game is switched to the foreground. |
Exits the current quick game.
Parameter | Type | Mandatory | Description |
|---|---|---|---|
success | function | No | Callback function triggered upon a successful API call. |
fail | function | No | Callback function triggered upon a failed API call. |
complete | function | No | Callback function triggered when the API call completes, regardless of success or failure. |
qg.exitApplication({
success : function () {
console.log("exitApplication success" );
},
fail:function(){
console.log("exitApplication fail");
},
complete:function() {
console.log("exitApplication complete");
}
}); Obtains the launch parameters of the quick game.
Parameter | Type | Description |
|---|---|---|
query | string | Parameters carried for launching a quick game. For details, please refer to Parameters in query. The value can be converted into a JSON object. |
referrerInfo | object | Source information. If the quick game is launched from another quick game, AppGallery, Quick Game Center, or a home screen shortcut, this parameter is returned. Otherwise, {} is returned. For details, please refer to Parameters in referrerInfo. |
The returned parameters depend on the parameters provided in the deep link. In addition to the following parameters, the custom parameters are also returned.
Parameter | Type | Description |
|---|---|---|
gameGiftId | string | Game gift package ID. |
giftUri | string | URL of the gift package page, which is the redirection URL set when you create the gift package. After the game is launched, the gift package page is displayed based on the gift package URL. |
userEntry | string | Channel platform. The options are as follows:
|
Parameter | Type | Description |
|---|---|---|
type | string | Parameter source type.
|
extraData | object | For HarmonyOS apps, HarmonyOS games, quick apps, or quick games, packageName is used to identify the package name of the caller. {
packageName:"com.huawei.appMarket"
} |
Listens for the event that a quick game is switched to the background.
Parameter | Type | Mandatory | Description |
|---|---|---|---|
callback | function | Yes | Callback function triggered when a quick game is switched to the background. |
qg.onHide(
callback() {console.log("onHide");}
); Stops listening for the event that a quick game is switched to the background.
Parameter | Type | Mandatory | Description |
|---|---|---|---|
callback | function | Yes | Callback function to be removed from the event listener. |
qg.offHide(
callback() {console.log("offHide");}
); Listens for the event that a quick game is switched to the foreground.
Parameter | Type | Description |
|---|---|---|
query(1078+) | object | Query passed when the quick game is launched. |
referrerInfo(1078+) | object | Source information. If the quick game is launched from another quick game, AppGallery, Quick Game Center, or a home screen shortcut, this parameter is returned. Otherwise, {} is returned. For details, please refer to Parameters in referrerInfo. |
Parameter | Type | Description |
|---|---|---|
type | string | Parameter source type.
|
extraData | object | For HarmonyOS apps, HarmonyOS games, quick apps, or quick games, packageName is used to identify the package name of the caller. {
packageName:"com.huawei.appMarket"
} |
var callback = function (res) {
console.log("onShow callback:\n" + JSON.stringify(res));
};
qg.onShow(callback); Stops listening for the event that a quick game is switched to the foreground.
Parameter | Type | Mandatory | Description |
|---|---|---|---|
callback | function | Yes | Callback function to be removed from the listener. NOTE The value of callback must be the same as that passed to onShow. Otherwise, the event listener cannot be canceled. |
qg.offShow(
callback() {console.log("offShow");}
);