Recently, I found that Remote Configuration of AppGallery Connect now supports the web platform, which I’ve long been waiting for. Previously, it has only been supported on Android, but now it can be applied to web apps. For details about the integration demo, visit GitHub.
Integration Steps1. Enable the service.
a) Sign in to AppGallery Connect and create a web app.
b) Enable Remote Configuration.
c) Click New parameter and set parameters.
{
"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. Integrate the SDK.
a) Run the following command:
Code:
npm install –save @agconnect/remoteconfig
3. Implement the functions.
a) Obtain the local configuration parameters.
Create a local configuration map in the Vue.
Apply the local settings.
JavaScript:
export function applyDefault(map) {
return agconnect.remoteConfig().applyDefault(map);
}
b) Call the fetch API to fetch parameter values from the cloud.
JavaScript:
export async function fetch() {
return agconnect.remoteConfig().fetch().then(() => {
return Promise.resolve();
}).catch((err) => {
return Promise.reject(err);
});
}
c) Apply the parameter values to the local host immediately or upon the next launch.
1. Applying the parameter values immediately:
Call the apply API.
JavaScript:
export function apply() {
return agconnect
.remoteConfig().apply().then((res) => {
return Promise.resolve(res);
}
).catch(error => {
return Promise.reject(error);
});
}
2. Applying the parameter values upon the next launch:
Call the applyLastFetch API to apply the last fetched parameter values.
JavaScript:
// Load configurations.
export function applyLastLoad() {
return agconnect
.remoteConfig().loadLastFetched().then(async (res) => {
if (res) {
await agconnect.remoteConfig().apply(res);
}
return Promise.resolve(res);
}
).catch(error => {
return Promise.reject(error);
});
}
d) Obtain all parameter values from the local host and cloud.
Call the getMergedAll API to obtain all parameter values.
JavaScript:
export function getMergedAll() {
return agconnect.remoteConfig().getMergedAll();
}
e) Call the clearAll API to clear all parameter values.
JavaScript:
export function clearAll() {
agconnect.remoteConfig().clearAll();
}
References:
Demo:
https://github.com/AppGalleryConnect/agc-demos/tree/main/Web/agc-romoteconfig-demo-javascript
Remote Configuration Development Guide:
https://developer.huawei.com/consum...-remoteconfig-web-getstarted-0000001056501223
Well explained, Using remote config can we change UI elements.
What is the basic use of Remote Config in web?
sujith.e said:
Well explained, Using remote config can we change UI elements.
Click to expand...
Click to collapse
yes, that is convenient for developers.
ask011 said:
What is the basic use of Remote Config in web?
Click to expand...
Click to collapse
You can flexibly modify the behavior and appearance of applications by changing cloud parameter values.
Related
This is originally from HUAWEI Developer Froum
Forum link: https://forums.developer.huawei.com/forumPortal/en/home
{
"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"
}
Introduction
Remote config is a feature that allows us to alter both the look and feel of our application without the need to publish any updates to the App Gallery. This works by allowing us to define in-app parameters that can be overridden from within the Huawei App Gallery Connect — these parameters can then be activated for either all or a defined selection of users.
This powerful feature gives us a range of new abilities when it comes to immediate updates, temporary changes or testing new features amongst users. Let’s take a dive and learn the what, why and how of Remote Config so we can learn how to use it to benefit both ourselves and our users
Use Cases
1. Releasing new functions by user percentage.
2. Display country/region-specific promotion content.
3. Personalized content recommendation based on Huawei Analytics.
4. Holiday theme adaptation.
Development Process
· Create sample application in android and configure into AGC.
· Enable Remote Configuration API.
· Download agconnect-service.json and add into app directory.
· Add remote config dependencies in the build.gradle file in app directory.
Code:
implementation 'com.huawei.agconnect:agconnect-remoteconfig:1.3.1.300'
· Open AGC select Demo project Growing->Remote Config Now enable Remote Config service
After enabling service, you will get option
· Parameter Management.
· Condition Management.
Parameter Management:
Within Remote Config we define key-value pairs which are known as parameters. These parameters are then used to define the configuration values that are to be used within our app.
· Key — The key is a String used to define the identify for the parameter
· value — The value can be of any other data type and is used to represent the value of our defined parameter.
· After saving parameter management details we can check ,you can add, modify, delete in existing parameters.
Condition Management
Conditions are a collection of rules that we can use to target specific app instances —for example based on gender we can update new changes.
The conditional value itself is also represented as a key-value pair, it’s made up of:
· condition — The condition to be satisfied for the value to be used
§ App version
§ OS version
§ Language
§ Country/Region
§ Audience, etc..
· value — The value to be used if the condition is satisfied
Let’s see code Implementation
· Create Instance for AGConnectConfig
Code:
AGConnectConfig config = AGConnectConfig.getInstance();
· Create config.xml file ,you can set default parameter values before connecting to remote config service.so that your app can run perfectly.
Code:
<?xml version="1.0" encoding="utf-8"?>
<remoteconfig>
<value key="version">1.0</value>
</remoteconfig>
· Call Api to pass default values this will effect immediately.
Code:
config.applyDefault(R.xml.remote_config);
· Fetching parameter values from Remote Configuration
Code:
config.fetch(fetchInterval).addOnSuccessListener(new OnSuccessListener<ConfigValues>() {
@Override
public void onSuccess(ConfigValues configValues) {
config.apply(configValues);
config.getMergedAll();
long remoteVersionCode = config.getValueAsLong("version");
if (currentVersionCode > remoteVersionCode) {
ShowUpdateAlert();
}
Toast.makeText(getBaseContext(), "RemoteVersionCode: "+String.valueOf(remoteVersionCode), Toast.LENGTH_LONG).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Toast.makeText(getBaseContext(), "Fetch Fail", Toast.LENGTH_LONG).show();
}
});
This is not the end. For full content, you can visit HUAWEI Developer Forum.
Use Cases
HUAWEI Analytics Kit provides a server API for you to export event data collected on devices and import the data to your BI system for unified data analysis. After the export is complete, Analytics Kit asynchronously uploads the exported data to the Object Storage Service (OBS) and then returns the export result and data storage path to your app server by sending an HTTPS POST request to call its callback API. To ensure data security, the download link will become invalid after 2 hours.
The following table describes the export states that are currently supported.
{
"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"
}
The following table lists the data filter criteria.
Getting Started
Setting the Callback API
Sign in to AppGallery Connect. Go to My projects > HUAWEI Analytics > Management > Analysis setting, and select Set Callback API to set related parameters.
1. Configure the callback API URL for receiving the data download link.
2. Configure the HTTPS certificate.
3. Click Test callback to test the function of the callback API. After the test is successful, click Submit to complete the callback API configuration.
Development Guide
Before developing a callback API, you need to prepare a public network domain name and an API that can receive POST requests. Ensure that the POST API has an HTTPS certificate.
The development procedure is as follows:
1. Develop the callback API. In the sample code, the domain name is habackup.hwcloudtest.cn, which is accessible by your server.
Code:
@RequestMapping(value = "/agc/analytics/callback", method = RequestMethod.POST)
public ResultResp callback(@RequestBody @Valid ExportDataCallbackReq req) {
ResultResp result = new ResultResp();
// Receive the callback after the export task is generated.
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("the download url: {}", req.getFilePath());
}
// Obtain the download link to continue.
result.setResultCode("0");
result.setResultMsg("success");
return result;
}
Requested object:
Code:
public class ExportDataCallbackReq implements Serializable {
private static final long serialVersionUID = -8014011591749838257L;
@JsonProperty("request_id")
private String requestId;
@JsonProperty("app_id")
private String appId;
@JsonProperty("status")
private String status;
@JsonProperty("file_path")
private String filePath;
@JsonProperty("status_time")
private String statusTime;
}
2. Go to HUAWEI Analytics > Management > Analysis setting to configure the callback API.
3. Call the public API to obtain the token
POST request:
URI: https://oauth-login.cloud.huawei.com/oauth2/v2/token
Header:
Code:
Content-Type:Application/x-www-form-urlencoded
Body:
Code:
grant_type:client_credentials
client_id:100664247
client_secret:170e4ecb457bd73fa7c977de976274a7
Response:
Code:
{
"access_token": "CV6qeoJReXe+YfDRQomDe9VW1B6fzIH1QU260T94x4RBLUSZRjTRIcY7IngF1cPIEYaPhJCjVNOxrhvAo49Ay/Ukkf+p",
"expires_in": 3600,
"token_type": "Bearer"
}
4. Start data export.
POST request:
URI: https://datacollector-drcn.dt.hicloud.com/analytics/export/raw_data_requests/v2
Header:
Code:
Authorization:Bearer CV6qeoJReXe+YfDRQomDe9VW1B6fzIH1QU260T94x4RBLUSZRjTRIcY7IngF1cPIEYaPhJCjVNOxrhvAo49Ay\/Ukkf+p (token_type + space + access_token, obtained from the token response)
x-App-id:10066424
Content-Type:Application/json
x-product-id:9105163812218569643
Body:
Code:
{
"date_range": {
"start_date": "2020-2-29",
"end_date": "2020-3-10"
},
"file_format": "csv",
"filters": []
}
Response:
Code:
{
"result_code": "0",
"result_msg": "success"
}
5. View the export status.
Go to My projects > HUAWEI Analytics > Management > Data export.
6. After the export is complete, the Analytics Kit automatically calls the callback API to obtain the export result. Obtain the download link from the file_path field. The link is effective in 6 hours.
7. View the export result. If the following information is displayed, the export is successful.
Code:
[
{
"request_id": "c0b41debe8064c54ab200d30907f40c5",
"App_id": "100664247",
"status": "EXPORTED",
"file_path": "https://nsp-ha-gdpr-drcn.obs.cn-north-2.myhuaweicloud.com/20200430_14_c0b41debe8064c54ab200d30907f40c5.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=F9WBKUUWDQODJO4FQMBF%2F20200430%2Fcn-north-2%2Fs3%2Faws4_request&X-Amz-Date=20200430T073623Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=9145e80d51e21cd295861a5a0688bbcfbf8805e071cd8b98e08b5eacf2171fdb",
"status_time": "2020-04-30 07:37:02"
}
]
For details about the fields int he exported file, please refer to Description of Fields in the Export Data File.
Map Kit has various SDKs and APIs. One of them is JavaScript API which is a solution for web applications and cross platforms.
What does Map Kit JavaScript API provide?
It provides the basic map display, map interaction, route planning, place search, geocoding, and other functions to meet requirements of most developers.
Which browsers are supported?
Currently, JavaScript APIs support the following browsers:
{
"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"
}
What are the prerequisites to use Map Kit JavaScript API?
Before using the service, you need to apply for an API key on the HUAWEI Developer website.
How to integrate basic capabilities?
First thing is to copy API Key from the developer console:
Code:
AppGallery Connect > Your App > Develop > Overview > App Information > API key
We need to provide the HUAWEI Map Kit API file. The API key must be encoded. You can encode it programatically or you can try out online tools to do it manually.
Code:
<script src="https://mapapi.cloud.huawei.com/mapjs/v1/api/js?callback=initMap&key=API KEY"></script>
Create map element in the body:
Code:
<div id="map"></div>
Initialize the map. The following sample code is to create a map with Paris as the center and a zoom level of 8:
Code:
function initMap() {
const mapOptions = {};
mapOptions.center = {lat: 48.856613, lng: 2.352222};
mapOptions.zoom = 8;
mapOptions.language='ENG';
const map = new HWMapJsSDK.HWMap(document.getElementById('map'), mapOptions);
}
Add a marker:
Code:
const mMarker = new HWMapJsSDK.HWMarker({
map,
position: {lat: 48.85, lng: 2.35},
label: 'A',
icon: {
opacity: 0.5
}
});
Show information window when clicking on marker:
Code:
const infoWindow = new HWMapJsSDK.HWInfoWindow({
map,
position: 10,
content: 'This is a InfoWindow.',
offset: [0, -40],
});
mMarker.addListener('click', () => {
infoWindow.open(mMarker);
});
Sample code is available on my GitHub page: /onurkenis/ionic-hms-map-demo
Hi,
Map kit Api will support navigation.how to show shortest path.
Overview
The Image Vision service provides you with 24 color filters, which are easy to use.
Use Cases
An app needs to beautify or retouch images.
Development Procedure
The Image Vision service renders the images you provide and returns them to your app.
1. Import the Image Vision service packages.
Code:
import com.huawei.hms.image.vision.*;
import com.huawei.hms.image.vision.bean.ImageVisionResult;
2. Construct an ImageVision instance. The instance will be used to perform related operations such as obtaining the filter effect.
Code:
// Obtain an ImageVisionImpl instance.
ImageVisionImpl imageVisionAPI = ImageVision.getInstance(this);
3 Initialize the service. To call setVisionCallBack during service initialization, your app must implement the ImageVision.VisionCallBack API with its onSuccess(int successCode) and onFailure(int errorCode) methods rewritten. If the ImageVision instance is successfully obtained, the onSuccess method is called and then the Image Vision service is initialized. If the ImageVision instance fails to be obtained, the onFailure method is called and an error code is returned. Your app is allowed to use the Image Vision service only after the successful verification. That is, the value of initCode must be 0, indicating that the initialization is successful.
Code:
imageVisionAPI.setVisionCallBack(new ImageVision.VisionCallBack() {
@Override
public void onSuccess(int successCode) {
int initCode = imageVisionAPI.init(context, authJson);
...
}
@Override
public void onFailure(int errorCode) {
...
}
});
Description of authJson parameters:
{
"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 find the preceding parameters except token in the agconnect-services.json file.
4. Construct a jsonObject object.
Description of requestJson and imageBitmap parameters:
Description of requestJson parameters:
Description of taskJson parameters:
For details, see the description of authJson parameters in step 3.
filterType mapping:
5. Obtain the rendered image.
When calling the getColorFilter() API, you need to specify the bitmap image to be rendered and select the required filter. In addition, you need to pass the authentication information. Your app can use the service only after it is successfully authenticated. On receiving the request from your app, the filter service parses the image and returns the rendered view to the app.
Note: Call the API in a subthread other than the main thread. If the image cannot be displayed during the test, it is recommended your turn off hardware acceleration.
Code:
//Obtain the rendering result from visionResult.
ImageVisionResult visionResult = imageVisionAPI.getColorFilter(requestJson,imageBitmap);
Description of visionResult parameters:
Description of responseJson parameters:
To turn off hardware acceleration, configure the AndroidManifest.xml file as follows:
Code:
<application
...
android:hardwareAccelerated="false"
...
</application>
6. Stop the Image Vision service.
If you do not need to use filters any longer, call the imageVisionAPI.stop() API to stop the Image Vision service. If the returned stopCode is 0, the service is successfully stopped.
Code:
if (null != imageVisionAPI) {
int stopCode = imageVisionAPI.stop();
}
Hi,
am facing an issue while integrated image vision API
2020-10-08 18:21:49.971 3143-3143/com.huawei.sujith.imageeditor E/ImageVisionImpl: ClassNotFoundException: Didn't find class "com.huawei.hms.image.visionkit.dynamic.FunctionCreator" on path: DexPathList[[zip file "/data/user_de/152/com.huawei.android.hsf/modules/external/huawei_module_imagevision/10003301/com.huawei.hms.image.visionkit-10003301.apk"],nativeLibraryDirectories=[/data/user_de/152/com.huawei.android.hsf/modules/external/huawei_module_imagevision/10003301/com.huawei.hms.image.visionkit-10003301.apk!/lib/arm64-v8a, /system/lib64, /hw_product/lib64, /system/product/lib64]]
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