Integrating Remote Configuration into Your HarmonyOS App

Doğan Burak Ziyanak
Huawei Developers
Published in
3 min readApr 26, 2022
Remote Configuration

Background

Imagine that you want to add a new feature to your app, but you are not certain how it will affect user experience and usage. You want to be able to test it before moving forward with a full release. This is where Remote Configuration helps you, by allowing you to flexibly change the behavior and UI for your app without releasing a new app version, ensuring you can flexibly respond to user needs. The service provides SDKs for multiple platforms, including Android, iOS, Harmony OS, and web. This post will illustrate how to integrate the HarmonyOS SDK of Remote Configuration.

Preparations

  • Configuring the Signature: Install DevEco Studio and the HarmonyOS SDK. Once installed, create a Java project in DevEco Studio.

You can follow steps explained in developer portal if it is first time you need to install DevEco studio IDE.

https://developer.harmonyos.com/en/docs/documentation/doc-guides/software_install-0000001053582415

Choose ability template
  • Configuring the Signature: In DevEco Studio, go to File > Project Structure > Project > Signing Configs. On the Debug tab page, select Automatically generate signing. Then click OK. The signature will be automatically generated after you sign in to AppGallery Connect.
Signing config configuration
  • Enabling remote configuration and setting required parameter values in Remote Configuration
Remote config setting

Integrating the Remote Configuration SDK

  • Currently, the maven repository address is automatically configured when you create a HarmonyOS app. Just simply add the AppGallery Connect plugin to the project-level build.gradle file.
classpath 'com.huawei.agconnect:agcp-harmony:1.1.0.200'
  • Apply the plugin in the app-level build.gradle file.
apply plugin: 'com.huawei.agconnect'
  • Then add the service dependency.
implementation 'com.huawei.agconnect:agconnect-remoteconfig-harmony:1.1.0.200'

implementation "com.huawei.agconnect:agconnect-tasks-harmony:1.1.0.200"

Developing Functions

  • Set the default parameter values: Create an XML file for saving in-app default parameter values in key-value pairs, under resources > profile.
config.xml file
remote config value

Call applyDefault to apply the in-app default parameter values.

  • Call fetch to fetch the updated parameter values from Remote Configuration.

Results

After the app is launched, the in-app default parameter values are displayed.

Default parameter displayed

After the fetch button is tapped, the parameter values fetched from Remote Configuration are displayed instead.

Remote config param displayed

Conclusion

In this article, we saw how easy is to integrate the Remote Configuration with your HarmonyOS apps.

For more detailed background about HarmonyOS technology, you can visit and read our articles on the forum. See you next!

--

--