How to apply minor and major(force) update with Huawei Remote Configuration?

Damla Yagmur
Huawei Developers
Published in
5 min readOct 1, 2021

Introduction

Hello everyone,

In this article, I will talk about check updates with Huawei Remote Configuration.

Remote Configuration: We can use remote configuration for different purposes. For example, you can change appearance and behavior of the app without updating. And other usage of remote configuration is checking for updates.

To use Huawei Remote Configuration, firstly you must finish HMS Core integration part. You can use the document in the link to easily integrate HMS Core.

Configurations

On the AGC Console, you can find Remote Configuration in Grow part. Click Enable now button to enable Remote Configuration.

Note: After enabling, check and update your json file. If you do not use the latest version of the json file, you will get an error.

Add the Remote Configuration dependency in the build.gradle file in your app’s module directory.

Development

Let’s develop an app step by step.

We have a two scenario for updates. These are minor and major update. For minor updates, user can cancel the version update but for major updates, user cannot cancel app update. In major updates, users have to update app.

  • Minor Update

-First let’s start to develop minor update scenario. We need to create remote configuration parameters on console. Click New parameter button.

-Enter the parameter name and default value as seen in the below screenshot. If you want to explain this parameter briefly to remember, you can add description. After adding necessary information, click the save button at the top right.

-After the parameter adding and saving processes are completed, you need to release these parameters in order to use them through the app. You can create and release multiple parameters at the same time, you do not need to release all of them one by one. Please do not forget the release step, otherwise you cannot use these parameters.

-For checking app update, we need to get current app version and compare this value with remote configuration parameters.

-After that we have to check app needs minor or major update. In this demo, we can check this updates in Splash Screen. We use comparison values ​​here as an example, you can adjust these values ​​according to your app.

-Then we show a minor or major update with redirecting to Main Activity according to the values ​​obtained as a result of the check.

-You can also change data type of intent.putExtra and intent.getStringExtra
according to your own requirements.

-After that we initialize remote config.

-Now it remains to take the remote configuration parameters, compare them with the current app version and open the necessary dialogs.

*appVersion variable using the getAppVersion method that we just saw, this variable represents the current app version.

*After completing the remote configuration fetch operations, time to get the values ​​of the parameters we created.

*The thing you need to pay attention to here is that you use the getValueAsString part without changing the name of the parameter you created in the console as it is.

*Then we open a dialog according to the update scenario according to the comparison you made.

*Remote configuration has some restrictions. You can find restrictions document in the end of the article, References part. You may get some error codes according to these restrictions. If remoteConfig fetch is not successful, you can inform the user.

Note: When I developed this app, I got error ‘fetch throttled, try again later.’ The reason for this error is API calls restrictions. If a user makes more than 20 API calls, user has to wait for a 1 hour to renew API call restriction.

-Now let’s design a dialog for minor update. The user can ignore this update. so we should add cancel or ok button as well. This is my basic design, you can design according to your app. Please pay attention ok and update buttons because the user can exit the dialog without updating.

Redirecting to AppGallery

-If the users want to update the application, they click the update button and redirect to AppGallery app page.

-In this code, I used Huawei Browser package name because my app is not release on AppGallery. I wanted to see redirecting to AppGallery. If your app is released, you can get the package name as in the comment line and redirect it to your own app page. Make sure that the link in the catch section also belongs to the same app.

Minor Update Output

  • Major Update

Actually, all the steps we do here will still be the same with minor update except dialog design.

Again, we get parameters from the console and compare it with the current version.

The most important part for us here is the dialog part. The user cannot ignore the application update. That’s why major update also called a force update.

Major Update Output

Tips & Tricks

  1. Please use latest json file after enabling Remote Configuration.
  2. Do not forget to release parameters.
  3. Please check the restrictions document to avoid errors due to restrictions.

Conclusion

In this article, I explained 2 type of update with Huawei Remote Configuration. I hope you will like it. Thank you for reading. If you have any questions, you can leave a comment or ask via Huawei Developer Forum.

References

--

--