More information like this, you can visit HUAWEI Developer Forum
Intro
In this article I would like to address the HMS topic in Unity Engine. Unity is widely used in the world of video game development. With the help of the plugin developed by EvilMindDevs the integration of the HMS sdk is easier. Although the documentation of the plugin is quite explicit in this tutorial i want to review the implementation within a game. The game is very simple, A car which we must control by swiping to right or left. When losing, a menu where we can login to our HMS account with the help of the plugin. Without further introduction let's go to the article.
Steps
1. Download the code from the repository
2. Create our application in AGC
3. Creating Keystore whitin Unity
4. Obtaining the SHA256 number
5. Finishing the configuration in AGC
6. Let's download the plugin
7. Setting up json Services
8. Adding data of our App to the Plugin
9. Adding the Account Manager prefab to the scene
10.Adding a button to the "End of Game" Canvas
11. Adding neccesary objects
12. Creating an AuthPara class to manage Authentication
1.-Download the repository code
https://github.com/ADX2099/Unity-HMSAUTH
2.- Create our application in AGC
To implement the plugin we must create an App on our console
{
"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 on My apps
Choose New app and fill App data, this time we must select Game in App Category. Once the App is created, what we will do is go to the develop tab and place the name of our package. Choose the one that suits you best, within this tab is where we will find the necessary data to implement the plugin.
3.-Creating the Keystore in Unity
Now we have to open Unity and start to configure the project, to achieve this we must go to File -> Build Settings -> Player Settings
Within Player Settings we must look for the Publishing Settings tab and open the KeystoreManager
Create our keystore in the desired place
Fill the fields for our key
Done! We have generated our Key locate it in your Explorer
4.-Obtaining the number of SHA256
To obtain the SHA256 by console we must follow the following link
https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides-V5/signing-fingerprint-0000001050071709-V5
Remember that it is also recommended that you adjust your java PATH in the Windows environment variables if your computer has this system.
5.-Finishing setup in AGC
Once we have obtained our fingerprint, place it in the corresponding section in AGC
6.- Let's download the plugin
Our AGC App has been configured now we must download the Unity plugin. Let's go to the next link and download the ZIP.
https://github.com/EvilMindDevs/hms-unity-plugin
Once the plugin is downloaded, locate it in your File Explorer, because now we must import it into Unity. go to Assets-> Import Package->CustomPackage
Once the plugin is imported we will have the following folder structure
7.-Setting the json Services
Let's download the JSON Services of our App from AGC
Open the agconnect file and replace the information downloaded from your agconnect-services.json
8.-Adding data of our App to the Plugin we have to go to the Huawei menu -> App Gallery
As said in the beggining this information will be found in your App properties on AGC
We have to set up our parameters in the following fields.
9.- Adding the Account Manager prefab to the scene.
As mentioned in the documentation we must drag the desired prefab to our scene in Unity in this case we will use Account Manager so we add it to the root of our scene
10.- Add a button to the End of Game Canvas
For this example of how to use Account HMS service We will add a UI button within the canvas that is displayed at the end of the game, the purpose of this menu will be to display the authentication to Huawei.
11.-Add necessary objects in the inspector
12.-Creating an Auth class to manage the login.
Within the game scripts I have created a class called AuthLogin where we will add the following code. This code will be necessary to call the AccountManager object. Don't forget to add it to the Button object too. As shown in the image above.
Code:
using HmsPlugin;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AuthLogin : MonoBehaviour
{
public Button btnLogin;
public AccountManager myAccountManager;
// Start is called before the first frame update
void Start()
{
myAccountManager = GameObject.Find("AccountManager").GetComponent<AccountManager>();
Button btn = btnLogin.GetComponent<Button>();
btn.onClick.AddListener(TaskOnClick);
}
public void TaskOnClick()
{
if (myAccountManager)
{
myAccountManager.SignIn();
}
else
{
myAccountManager = GameObject.Find("AccountManager").GetComponent<AccountManager>();
}
}
// Update is called once per frame
void Update()
{
}
Documentation mentions that you execute the login method to start with the authentication but reviewing the class the only methods we have are Sign In and SignOut
Conclusion
With this little exercise we have learned how to implement the HMS plugin and start using HMS in Unity, I hope it helps you, the plugin also has the following Kits.
Related
This is originally from HUAWEI Developer Forum
Forum link: https://forums.developer.huawei.com/forumPortal/en/home
Introduction
HUAWEI Wallet Kit providing users to claim passes of merchants, like loyalty cards, gift cards, coupons, boarding passes, event tickets, and transit passes. It provides easy-to-access digital passes on an integrated platform. It enables user save their cards into mobile phones for convenient. The interaction between apps and users via location based notifications.
Integration Process.
The Wallet Kit integration process consists following steps
1. Generating Public and Private Keys
2. Adding Pass type on the AGC
3. Running the Server Demo code
4. Running the Client Demo code
5. View card adding status
Step-1: Check Below Link to generate keys & App Configuration in AGC:
LINK: https://forums.developer.huawei.com...d=0201242460338530108&fid=0101187876626530001
· Let’s see how to apply new wallet.
{
"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"
}
· Now will see how to create Flight ticket.
· Service type consists 3 types
1. Card
2. Coupon
3. Ticket
· Service item will change based on service type
· Service name should be Unique
· Service Id should be unique it will start will always hwpass
· Public key we need to get it from RSAUtils
· Click next button and save details. The service application procedure is now complete. After applying for the service, you can view, edit, and delete it on the HUAWEI Wallet Kit service application page
Step-2: Server Side Integration:
Download server demo code check below link.
Link: https://developer.huawei.com/consumer/en/doc/development/HMS-Examples/wallet-sample-code
1. Download maven dependency.
2. Configure your project into IntelliJ IDEA
3. Download required dependencies and import
4. Sync your project
5. Open release.config.properties and replace appId & secret Key
6. Compile project using terminal mvn clean compile
7. After completion of compilation automatically Target folder will generate
Follow below steps
Copy hmspass folder in the config directory, paste into the target/classes directory.
You can run the source code, you can run mainly java files in the Test folder.
Check below steps and modify accordingly.
· The file ends with ModelTest provides the examples of adding, modifying and pass models.
· The file name ends with InstanceTest provides the examples of adding, modifying and pass instances.
Step-3: Generate Pass Model:
· Open FlightModel.json file
· PassTypeIdentifier is unique which you mentioned service Id in AGC both needs to match
· You have to modify passTypeIdentifier and passStyleIdentifier when we add card types on the AGC PassStyleIdentifier field is unique.
· After completion of modify execute createFlightModel()
· Open the HwFlightModelTest file and Run CreateFlightModel() method
Code:
Test
public void createFlightModel() {
System.out.println("createFlightModel begin");
// Read an example flight model from a JSON file.
String objectJson = CommonUtil.readWalletObject("FlightModel.json");
HwWalletObject hwWalletObject = JSONObject.parseObject(objectJson, HwWalletObject.class);
String modelId = hwWalletObject.getPassStyleIdentifier();
System.out.println("modelId is: " + modelId);
String instanceId = hwWalletObject.getSerialNumber();
// Set parameters of the flight model you want to create. Flight instances belong to this model share these
// parameters.
WalletBuildService walletBuildService = new WalletBuildServiceImpl();
HwWalletObject requestData = walletBuildService.createHwWalletObject(objectJson, instanceId, modelId);
// Validate the parameters.
boolean validateModel = HwWalletObjectUtil.validateWalletModel(requestData);
if (validateModel) {
// Post the new flight model to the wallet server.
String urlParameter = "flight/model";
HwWalletObject flightModel = walletBuildService.postHwWalletObjectToWalletServer(urlParameter, requestData);
System.out.println("createFlightModel JSON is: " + CommonUtil.toJson(flightModel));
System.out.println("createFlightModel end");
}
}
This is not all. For full content, you can visit https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201254289105300220&fid=0101187876626530001
This is a great solution for wallet and loyalty apps that want to stay away from GMS.
More information like this, you can visit HUAWEI Developer Forum
Let’s say that you need to create an in-app product on Huawei AppGallery Connect. To do this, you sign in to AppGallery Connect, browse to your application, go to In-App Purchase, specify product information, and release the product. However, in reality, an application never have one but ten or twenty in-app products instead. In other words, you have to repeat the boring procedure mentioned above ten or twenty times! Don’t panic yet. This article will show you how to automate such mundane work using Product Management Service API.
The Product Management Service (PMS) API is a part of AppGallery Connect API, a HUAWEI’s alternative to Google Play Developer API. It provides RESTful APIs that can be used to create and update in-app product and promotion information. Utilizing this API, the automation tool (in Java) provided in this article will help you manage in-app product fast and precisely. Let’s examine how this tool works and its features.
Creating an API client
Accessing PMS API, as well as any other Connect APIs, requires authorization from the AppGallery Connect server in advance using either of the following modes:
API client mode: In this mode, an API client is used to authenticate and get access to AppGallery Connect APIs
OAuth client mode: In this mode, access to AppGallery Connect APIs is authorized by Huawei developer accounts. This mode is appropriate for developing a third-party IDE or development tool that needs to be connected to AppGallery Connect. This mode will not be discussed in this article
The tool I created utilized API client mode to call the AppGallery Connect API. Therefore, to be able to use the tool, you need an API client. The procedure of creating an API client is as follows:
Sign in AppGallery Connect and select Users and Permissions
Go to API Key > Connect API from the navigation tree on the left and click Create.
Set Name to a customized client name, set Roles to the corresponding role, and click Confirm. For details about roles and permissions, please refer to Roles and Permissions
After the client is successfully created, record the values of Client ID and Key in the client information list. You will need these values to run the tool later.
How to use the automation tool?
The automation tool is a Maven project, developed in Eclipse IDE. You will need to download and install Eclispe IDE for Java Developers (https://www.eclipse.org/downloads/packages/release/2020-06/r/eclipse-ide-java-developers) if you haven’t already. Then, download the tool from the github repos (https://github.com/buiquanghuy23103/PMS-demo). Once you had the tool and the IDE, let’s run it by following the instructions below:
Open Eclipse IDE. Go to File > Import > Maven > Existing Maven Projects. Then click Next.
Browse to the directory of the sample project
Select pom.xml in the Projects box and click Finish.
Open Package Explorer (Window > Show View > Package Explorer) and navigate to src > test > PmsApiDemo.java. In this file, provide Client ID, Client Key and App ID
To run the tool, from the app bar of Eclipse IDE, go to Run > Run
Creating a product
You can create new in-app products in few seconds with PMS. Go to projectDirectory > src > test > CreateProducts.java to specify product information, and then call CreateProducts.createNewProducts() in PmsApiDemo.java. Please note that product information has to follow the rules in ProductImportInfo. Otherwise, the tool will throw an exception.
Code:
public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
String token = GetToken.getToken(domain, clientId, clientSecret);
CreateProducts.createNewProducts(domain, clientId, token, appId);
}
Get product information
You can easily view information of any in-app products in AppGallery Connect through PMS. All you need to do is calling GetIapProductInfo.getProductInfoDetail() in PmsApiDemo.java.
Code:
public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
String token = GetToken.getToken(domain, clientId, clientSecret);
GetIapProductInfo.getProductInfoDetail(domain, clientId, token, appId, productNo);
}
The response will be in JSON format as follow:
{
"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"
}
Update product information
You can also update product information in the AppGallery through PMS. Go to UpdateProduct. generateUpdateRequest() to update your product information, and then call UpdateProduct.update() in PmsApiDemo.java.
Code:
public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
String token = GetToken.getToken(domain, clientId, clientSecret);
UpdateProduct.update(domain, clientId, token, appId, productNo);
}
Apart from these endpoints I integrate, you can also check out the other features of the PMS API here:
https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agcapi-pms-api-manage_product_promotion
Cocos Creator has supported HMS Core and HUAWEI AppGallery Connect, through which you can quickly release your games with one click, reducing such complex operations as the SDK integration and app upload during development. In this way, you can build high-quality and innovative apps to improve game experience.
Based on this guide, you can learn how to send messages by Push Kit in Cocos step by step.
Procedure Overview
1. Create a game on the Cocos website, and create the game project in Cocos Creator.
2. Create an app and configure the app information in AppGallery Connect, configure Cocos SDKHub and the building flow, and add the HUAWEI_HMS (Push) plugin and select HUAWEI AppGallery Connect from SDKHub Configuration.
3. Perform coding to obtain a token and build an APK.
4. Test the function of sending notification messages and data messages.
Procedure Details
Step 1: Create a game on the Cocos website, and create the game project in Cocos Creator.
1. Visit https://passport.cocos.com/auth/signup, and sign in with a Cocos developer account. (If you have no account, register one.) Then create a game.
{
"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"
}
2. Visit http://www.cocos2d-x.org/products#creator, and download and install Cocos Creator.
3. Start Cocos Creator, choose Project, and click New. In the window that is displayed, configure project information, and click Save. The project creation is completed.
If the following error occurs during creation, download Editor.
In Cocos Creator, choose Editor, select version 2.4.2 on the right, and click Download.
Step 2: Create an app and configure the app information in AppGallery Connect, configure Cocos SDKHub and the building flow, and add the HUAWEI_HMS (Push) plugin and select HUAWEI AppGallery Connect from SDKHub Configuration.
1. Create an app and configure the app information in AppGallery Connect by referring to the guide in https://developer.huawei.com/consum...re-Guides/android-config-agc-0000001050170137.
The key steps include:
Generating a signing certificate fingerprint
Configuring the signing certificate fingerprint
Setting a data storage location
Enabling required services
Downloading the agconnect-services.json file
After the app information configuration, perform configuration in Cocos Creator.
2. Choose Panel > Service.
3. Select your project.
Select Cocos SDKHub on the page that is displayed.
4. Click Plugin Manage.
5. Select Push and click OK. The page shown in the preceding figure is displayed.
6. Move the cursor to Not Configured in Params. The editing icon is displayed. Click it.
7. Select a required JSON file, and click OK.
8. Choose Project > Build.
The Build panel is displayed on the right.
9. Set SDKHub Configuration to HUAWEI AppGallery Connect, and click Build.
If the following error occurs during building, install NDK.
After the installation, click Compile. The progress status becomes completed.
Step 3: Perform coding to obtain a token and build an APK.
The following figure shows the project structure.
In Cocos Creator, select js-sdkhub.js file from Assets at the lower left corner.
1. Compile the following code in the js-sdkhub.js file:
Code:
var onPushResult = function (code, msg) {
console.log("on push result action.");
console.log("code: " + code);
console.log("msg: " + msg);
}
var init = function () {
let _global = global || window;
_global.sdkhub = _global.sdkhub || {};
sdkhub.getPushPlugin = () => null;
if (typeof SDKHub === 'undefined')
return;
sdkhub.getPushPlugin = () => SDKHub.AgentManager.getInstance().getPushPlugin();
sdkhub.getPushPlugin().startPush();
sdkhub.getPushPlugin().setListener(onPushResult, this);
}
init();
2. Click Build and then Compile to generate an APK, and install the APK to your device for testing.
The following error will occur during app running if you do not configure a correct certificate fingerprint.
Obtain the device token based on tag jswrapper|HUB_LOG in the logs.
Step 4: Test the function of sending notification messages and data messages.
1. Sign in to AppGallery Connect and select Push Kit by referring to the guide in https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/msg-sending-0000001050042119.
a. Configure notification message information.
The testing result is as follows.
b. Configure data message information.
The testing result is as follows.
Congratulations! Your game can send messages by Push Kit in Cocos.
For more details, please refer to the following documents.
HMS Core overview: https://developer.huawei.com/consumer/en/hms
HMS Core sample code on GitHub: https://github.com/HMS-Core
HMS Core Stack Overflow: https://stackoverflow.com/questions/tagged/huawei-mobile-services?tab=Newest
Introduction:
In this article, we will cover the Integration of IAP kit in Cocos Project using Official Plugin (Huawei HMS Core App Services).
Requirements:
1. Cocos Creator
Make sure to configure NDK Root and Android SDK Root in Cocos Creator under File>Settings>Select Native Develop.
2. Huawei device
3. Visual Studio Code
Follow the steps.
Step 1. Create Cocos project.
· Click on CocosDashboard, click New.
{
"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"
}
· Select empty Name and then click Create and Open.
Step 2: Enable Cocos SDKHub
Choose Panel > Service in the menu bar to open the Service panel. After setting Cocos AppID, select Cocos SDKHub to enter the Cocos SDKHub service panel.
Click the Enable button on the upper right to activate the Cocos SDKHub service, as shown below.
Click on IAP option to enable IAP, as shown below.
Step 3: Create an app in Huawei AppGallery Connect.
1. Configure IAP in Huawei AGC Console and place agconnect-services.json file in game project under setting folder.
2. Choose Project settings > Manage APIs, and enable In-App Purchases.
· Configure IAP products in AGC Console.
Step 4: Open Cocos creator.
1. Right-click on the assets folder and select Scene under File and name it. This file will contain all information inside your scene.
2. Right-click on the assets folder and select JavaScript under File and name it. This file will contain functions to perform some operation.
Step 5: Open the IapScript file and add a function to call the equivalent method of createPurchaseIntent() of java in Cocos and save the file. Use the below code.
Code:
payForProduct() {
var params = {
Product_Id: "product_id", // Product ID. Each product must have a unique ID
EXT: "Cocos Consumables Product 1", //Information stored on the merchant side, which is passed by the app when the payment API is called
};
sdkhub.getFeePlugin().feeForProduct(params);
},
Add below code inside onLoad() function. Call to the above function will give a callback to onFeeResult method that we need to define in the IapScript file.
Code:
onLoad(){
sdkhub.getFeePlugin().setListener(this.onFeeResult, this);
},
Step 6: Drag a Button from the Node Library panel to canvas and increase the Click Events to 1.
Step 7: Drag the script file to the Node tree.
Step 8: Select the button and drag the script file from the Node tree to cc.Node under Properties and select function which needs to be called from the script file.
Step 9: Once the product is purchased, they need to be consumed after that consumable product is successfully delivered.
When sdkhub.getFeePlugin().feeForProduct(params) is called gives a callback to onFeeResult.
Code:
onFeeResult: function (code, msg) {
if (code == 30104) {
console.log("Product consumed - "+ msg) // product consumed successfully
}
var params = JSON.parse(msg);
switch (code) {
// Process the "consumeOwnedPurchase" method logic, pay succeed
case sdkhub.FeeResultCode.kFeeSucceed:
sdkhub.getFeePlugin().callFuncWithParam("consumeOwnedPurchase", params.inAppPurchaseData); // consume Owned product Purchase
break;
}
},
Step 10: Click on Build under the Project tab to generate APK file. Build project, and then click Compile. Once code compile is done, click Play to run APK on connected phone.
Make sure to keep the same package name as kept in the Huawei AppGallery Connect project.
Conclusion:
In-app purchases are one of the main sources of revenue for game apps and is a very important feature that aggregates global mainstream payment methods, covering more than 178 countries and regions. In-app purchase provides a product management system (PMS) for managing the prices and languages of products in apps (including gaming apps) in multiple locations.
References:
https://docs.cocos.com/creator/manual/en/cocos-service/sdkhub-plugins/sdkhub-hms.html
https://developer.huawei.com/consumer/en/hms/huawei-iap/
Can the public payment key be exposed on the app?
Recently, it is found that some services of AppGallery Connect start to support cross-platform frameworks, including Flutter. Let's have a try on Remote Configuration.
Integration Procedure
1. Install the Flutter environment.
a) Download the Flutter SDK package from https://flutter.dev/docs/get-started/install/windows.
{
"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"
}
Decompress the package to any directory, for example, D:\Flutter.
b) Add Flutter to environment variables. Here, the path is D:\Flutter\flutter_windows_1.22.2-stable\flutter\bin.
c) In Android Studio, go to File > Settings > Plugins, download the Flutter and Dart plug-ins, and restart Android Studio for the plug-ins to take effect.
2. Create a project and enable Remote Configuration.
a) Create an Android project in AppGallery Connect and enable Remote Configuration.
b) Add the following configuration items to Remote Configuration.
c) In Android Studio, go to File > New > New Flutter Project… and create a Flutter project.
d) Go to Project settings > General information in AppGallery Connect. In the App information area, download the agconnect-services.json file.
e) Place the agconnect-services.json file in the directory shown in the following figure.
f) Configure the Maven repository and Remote Configuration plug-in in the app-level build.gradle file.
g) Open the build.gradle file in the android/app directory of the Flutter project and add the build dependencies and AppGallery Connect plug-in address.
3. Integrate the Remote Configuration SDK.
Add the SDK dependency of Remote Configuration to the pubspec.yaml file.
Click Pub get to synchronize the data.
4. Test basic functions.
Here I implement a simple demo app to demonstrate several of the most important functions.
In the UI design, the Mode 1:Fetch And Activate Immediately, Mode 2:Fetch And Activate Next Time, and Clear Data buttons are provided to implement the following functions:
1. Obtain data from the cloud. This operation takes effect this time.
Tap Mode 1:Fetch And Activate Immediately to call fetch and then applyLastFetched to obtain the data fetched this time. The operation will take effect immediately. Therefore, we call the getMergedAll API to apply all the settings to the device. Then, we can obtain the data from the cloud on the device. The following figure shows the tap effect.
2. Obtain the cloud data and make the setting obtained last time take effect.
The API for delaying the setting to take effect shares the same implementation logic as that for making the setting take effect immediately, and they differ in the execution sequence.
Tap Mode 2:Fetch And Activate Next Time to call apply and getMergedAll to apply the last fetch result, and then call fetch to obtain the latest setting for next use.
3. Clear the data.
To clear data, tap Clear Data to call the clearAll API.
4. Set local configuration items.
You can create a Map parameter in the*.dart file and call the applyDefault API to apply the local settings.
HTML:
Map defaults = {
'mLong': 1000,
'mString': 'hello world',
'mDouble': 3.14,
'mBoolean': true
};
AGCRemotConfig.instance.applyDefaults(defaults);
5. Package your app.
Similar to Android, you only need to run your project in Android Studio.
Precautions
Different from setting local configuration items on the Android platform, Flutter cannot use XML files to store local configuration items.
For more details, check:
Flutter official guide: https://flutter.dev/docs/get-started/install/windows
To view more about how to integrate Remote Configuration into an Android project, visit https://developer.huawei.com/consum...-connect-Guides/agc-remoteconfig-introduction.
Demo of Remote Configuration(Flutter):https://developer.huawei.com/consum...oteconfig-flutter-samplecode-0000001056579535
Is there any usage restriction?
riteshchanchal said:
Is there any usage restriction?
Click to expand...
Click to collapse
there are some restriction as follows. For more restriction, please focus on the official document
A single project can have a maximum of 2000 parameters and 500 conditions. The total length of all parameter strings cannot exceed 800 KB.
The interface invoking frequency cannot exceed 20 times per hour.