HMS Remote Config | Unity

Kayahan Başkeser
Huawei Developers
Published in
3 min readDec 10, 2020

--

Hi everyone,

In this article, I will mention how to use HMS Remote Config on Unity.

You can reach the plugins with the link below.

First of all, we should create a unity project and import plugin into our unity project. If you do not have enough information about HMS Unity plugin integration, I recommend you to read this article. HMS Unity Plugin Integration

If you do not have enough information about HMS Remote Config, please read this document.

After integration HMS Unity Plugin, you can see demo scene for Remote Config and check .

You can see some methods of remote config on demo scene. This scene was created to inform. These are main methods of Remote Config.

To see all methods, please check RemoteConfigManager.cs file

All methods of Remote Config are located in RemoteConfigManager.cs file. And i recommend that call the methods you want to use in your application via this class.

Lets start,

Initialize the RemoteConfigManager with name remoteConfigManager.

First of all, you need to create an instance with the getInstance() method. And you will call remote config methods through this instance.

To add default values, there are 2 different way to set default configs. With XML file and with Dictionary<string, object>.

First way is with XML file. For this you need to use ApplyDefault(string xmlPath) method.

And this xml must be in resources folder. For example i created “xml ”folder in resources and put the xml file here.

And the path that you give must take the resources folder as root.

And xml file structure must be like left side.

Second way is with dictionary. For this way, you need to create a C# Dictionary<string, object> variable and add your config variables.

We use Fetch() method to pull the values from cloud. If you don`t know to add parameter in cloud, please check here

To get the results of the fetch method, you must specify the action methods.

And if the fetch method is successful, Apply(ConfigValues) method is used to save the values you get from the cloud.

The default interval for calling the fetch() method is 12 hours. You can call the Fetch(long intervalSeconds) method to customize the fetch interval.

To get the value of a key, you should call the following methods.

To get all values obtained in remote config, you should call GetMergedAll() method.

To get ConfigValues object returned by the last fetch method, you should call LoadLastFetched() method. And you can you can get the value of a key.

To find the source of a value, you should call getSource(String Key) method. And you must give a key value as string. And this method returns a string value. (STATIC, DEFAULT, REMOTE)

To clear all cached data which fetched from Remote Configuration and default values ​, you should call clearAll() method.

To receive data unlimited times from the cloud, you can set Developer Mode.

I hope this article was useful.

References

--

--