[Huawei Developers] Freemind R:
More information like this, you can visit HUAWEI Developer Forum​

Original link: https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201332997357290022&fid=0101187876626530001

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093416.96097202013570832313359740168985:50510903025430:2800:B19FAFF8CE9B6B835CFF8DB09CC6B3FD3F1459F51BDB36C7031932E337597DA3.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093416.96097202013570832313359740168985:50510903025430:2800:B19FAFF8CE9B6B835CFF8DB09CC6B3FD3F1459F51BDB36C7031932E337597DA3.png[/IMG]​

Hello everyone. In this article, I would like to talk about Remote Configuration — A/B Testing. What are they and where are they used? I want to start with these.

Remote Configuration

With the service, you can make changes in the behavior and appearance of your application without any updates. This process is managed by determining various parameters on the Console.

Use Cases:

Displaying the Language by Country/Region

Displaying Different Content to Different Users

Adapting the App Theme by Time

Releasing New Functions

Configurations

Go to Growing> Remote Configuration. Click Enable now to enable Remote Configuration.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093547.50295612080012770308370302100345:50510903025430:2800:9A5AEBF1711FA69F3A6FCBA528D822ECD1B697EF1D2927F4AEBFE8A0EA3854EE.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093547.50295612080012770308370302100345:50510903025430:2800:9A5AEBF1711FA69F3A6FCBA528D822ECD1B697EF1D2927F4AEBFE8A0EA3854EE.png[/IMG]

Add the Remote Configuration dependencies in the build.gradle file in the app directory.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093547.50295612080012770308370302100345:50510903025430:2800:9A5AEBF1711FA69F3A6FCBA528D822ECD1B697EF1D2927F4AEBFE8A0EA3854EE.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093547.50295612080012770308370302100345:50510903025430:2800:9A5AEBF1711FA69F3A6FCBA528D822ECD1B697EF1D2927F4AEBFE8A0EA3854EE.png[/IMG]

implementation 'com.huawei.agconnect:agconnect-remoteconfig:1.4.0.300'

Development

I have prepared a demo app to explain this service better. I’ll talk about it step by step.

First, I set the parameter using the Parameter Management tab in the Remote Config tab.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093632.42005642193165596456041988253161:50510903025430:2800:0E774D267A155635CEAB40B592989E09C798371ABA66E93EB1223E71CB161A73.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093632.42005642193165596456041988253161:50510903025430:2800:0E774D267A155635CEAB40B592989E09C798371ABA66E93EB1223E71CB161A73.png[/IMG]

Then I determined the condition in the Condition Management tab and defined it in the parameter tab.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093654.90804170251642216857974989054545:50510903025430:2800:97DBF58E25156CF1CF2C793597723BC4A4DF3AE5F8351A74E0C5D26C71EE2A7F.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093654.90804170251642216857974989054545:50510903025430:2800:97DBF58E25156CF1CF2C793597723BC4A4DF3AE5F8351A74E0C5D26C71EE2A7F.png[/IMG]

After the integration process on AGC is completed, you can start writing code on the application. In the code part, you must first specify the parameter you defined in AGC. You can do this by using the “Map” object or “XML”. I used XML.

override fun onCreate(savedInstanceState: Bundle?)
{
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
/*
- Using a Map object
val mapDefault = mapOf("language" to "other",
"key2" to "val2",
"key3" to "val3",
"key4" to "val4")
- Using an XML resource file
<?xml version="1.0" encoding="utf-8"?>
<remoteconfig>
<value key="language">other</value>
</remoteconfig>
*/
val agConnectConfig = AGConnectConfig.getInstance()
agConnectConfig.applyDefault(R.xml.remote_config)
remoteButton = findViewById(R.id.remote)
remoteButton?.setOnClickListener {
agConnectConfig.fetch(0).addOnSuccessListener {
agConnectConfig.apply(it)
val languageResponse = agConnectConfig.getValueAsString("language")
Toast.makeText(this, languageResponse, Toast.LENGTH_LONG).show()
if (languageResponse == "en"){
showUpdateAlert("Language is English")
}
else if(languageResponse == "other"){
showUpdateAlert("Language is not English")
}
}.addOnFailureListener {
// fail fetching from remote config
it.printStackTrace()
}
}
}

After writing the code, you can test the Remote Configuration by making changes on the device according to the parameter.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093731.45370397721460359058328017617327:50510903025430:2800:4CC08A0C4D79AAC248FC38642F85BF94725DBB4288B103E13952F185ED3EFBF0.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093731.45370397721460359058328017617327:50510903025430:2800:4CC08A0C4D79AAC248FC38642F85BF94725DBB4288B103E13952F185ED3EFBF0.png[/IMG]

A/B Testing

You can use the service to create one or more A/B tests engaging different user groups to compare your variants of app UI design, copywriting, product functions, or marketing activities for performance metrics and find the best one that meets user requirements.

Use Cases:

App UI Design Testing

App Copywriting Testing

App Function Testing

Configurations

Go to Growing > A/B Testing. Click Enable now in the upper right corner.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093158.30093470386690755126791224427427:50510903025430:2800:2DC84C4E49F07128B8D2CA7144571634CA271D2BEC409213EA25C3707E25177E.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093158.30093470386690755126791224427427:50510903025430:2800:2DC84C4E49F07128B8D2CA7144571634CA271D2BEC409213EA25C3707E25177E.png[/IMG]

After the service is enabled, the page shown in the following figure is displayed.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093850.67693408169717039205079801697646:50510903025430:2800:5D378AA8165EEB01A584DD0A3DDFC3AE565D8E12F1FA7CE8337F087DB5A4E93F.jpg"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820093850.67693408169717039205079801697646:50510903025430:2800:5D378AA8165EEB01A584DD0A3DDFC3AE565D8E12F1FA7CE8337F087DB5A4E93F.jpg[/IMG]

Notifications Experiment:

When you want to send notifications to existing users, you can use the A/B Testing to find out which user is affected by what type of notification.

Remote Configuration Experiment:

You can use A/B Testing to determine specific behaviors for specific user groups in your application or if you want to learn how it affects users before updating your application.

Development

I used the Remote Configuration Experiment. I’ll try to explain the steps here.

Firstly, you need to access Analytics Kit to obtain the target experiment users and experiment data, and generate experiment reports.

Enable Analytics Kit

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094256.72949422743868359894016886477578:50510903025430:2800:C99A93DEF85AC0AF97AF7588A1262829C4504141D36D187D14DA94189AFC1F34.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094256.72949422743868359894016886477578:50510903025430:2800:C99A93DEF85AC0AF97AF7588A1262829C4504141D36D187D14DA94189AFC1F34.png[/IMG]

Add the following code to the build.gradle file in the app directory

implementation 'com.huawei.hms:hianalytics:4.0.2.300'

Create User Attributes in this way to use the User Attributes condition.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094407.87612262401134580140140714465365:50510903025430:2800:5ACDE7779E8437D52D4AF77978DB3BF8D399F224129B4A094310C75A86A42BC7.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094407.87612262401134580140140714465365:50510903025430:2800:5ACDE7779E8437D52D4AF77978DB3BF8D399F224129B4A094310C75A86A42BC7.png[/IMG]

Create a condition on the Remote Configuration tab.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094448.95807215103936458119022144990945:50510903025430:2800:24DE1E1C01EDD405EEE6166FE1B8EC516DD1A31214762D018FD53BD9A9BD313A.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094448.95807215103936458119022144990945:50510903025430:2800:24DE1E1C01EDD405EEE6166FE1B8EC516DD1A31214762D018FD53BD9A9BD313A.png[/IMG]

Use Conditions to create your parameter.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094515.77360727881894257231450840852791:50510903025430:2800:E090D6870BFCE5F4CC3485EAF20942FDB0A6BA087881DAF44AFCE2B031E63649.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094515.77360727881894257231450840852791:50510903025430:2800:E090D6870BFCE5F4CC3485EAF20942FDB0A6BA087881DAF44AFCE2B031E63649.png[/IMG]

Then you will see a four-step screen when you press the Create Remote Configuration Experiment button on the A/B Testing tab.

Set the basic information of the test.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094554.21022573288705594954889340929106:50510903025430:2800:5FE8659FCA3B66D33A36763B1A5335E03257678E69F824676091A00546BE3A6F.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094554.21022573288705594954889340929106:50510903025430:2800:5FE8659FCA3B66D33A36763B1A5335E03257678E69F824676091A00546BE3A6F.png[/IMG]

Specify the conditions for finding the target users in this step.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094648.79788046165049075046734101228915:50510903025430:2800:BEE524DFF18F4F6D78B2B079D9DB4379A88E0B25C5F319A02E54FFBADEB3B90E.jpg"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094648.79788046165049075046734101228915:50510903025430:2800:BEE524DFF18F4F6D78B2B079D9DB4379A88E0B25C5F319A02E54FFBADEB3B90E.jpg[/IMG]

In this step, select your Remote Configuration parameter.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094720.57239863513060426658010591318197:50510903025430:2800:7D0143FC32AC38B10193AF9F604011DA4B41EC7767008DFB72DD9D5E2A90C70B.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094720.57239863513060426658010591318197:50510903025430:2800:7D0143FC32AC38B10193AF9F604011DA4B41EC7767008DFB72DD9D5E2A90C70B.png[/IMG]

You can select the indicators you want to see as a result of the test. A maximum of 5 options can be selected.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094814.87468580955118293125926351839375:50510903025430:2800:82AEFECC2273B2CB16548123DC6320096959116C7F4A711B5E1A49F83FE57C80.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094814.87468580955118293125926351839375:50510903025430:2800:82AEFECC2273B2CB16548123DC6320096959116C7F4A711B5E1A49F83FE57C80.png[/IMG]

After these steps, you can start writing your code based on the conditions in your application.

override fun onCreate(savedInstanceState: Bundle?)
{
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
/*
- Using a Map object
val mapDefault = mapOf("ABTest" to "c",
"key2" to "val2",
"key3" to "val3",
"key4" to "val4")
- Using an XML resource file
<?xml version="1.0" encoding="utf-8"?>
<remoteconfig>
<value key="ABTest">c</value>
</remoteconfig>
*/
val agConnectConfig = AGConnectConfig.getInstance()
agConnectConfig.applyDefault(R.xml.remote_config)
remoteButton = findViewById(R.id.remote)
remoteButton?.setOnClickListener {
agConnectConfig.fetch(0).addOnSuccessListener {
agConnectConfig.apply(it)
val abTestResponse = agConnectConfig.getValueAsString("ABTest")
if (abTestResponse == "a"){
showUpdateAlert("abTestResponse = A ")
}
else if(abTestResponse == "b"){
showUpdateAlert("abTestResponse = B ")
}
}.addOnFailureListener {
// fail fetching from remote config
it.printStackTrace()
}
}
}

Finally, you need to start your test on the A/B Testing screen. Sufficient data must be collected to obtain the test result.

I’d like to add the screenshots I took while I was doing the test.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094904.07911366552007725329958192919773:50510903025430:2800:2B0DE9BE5D4556C499E939B66FAF09956DA303A277235024E88EFA167913501D.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/889/177/5190090000024889177.20200820094904.07911366552007725329958192919773:50510903025430:2800:2B0DE9BE5D4556C499E939B66FAF09956DA303A277235024E88EFA167913501D.png[/IMG]

Conclusion

By using these two services, you can diversify your application according to your users, thus increasing the interaction. Moreover, without updating the application.

I hope this article was useful.

References

Remote Configuration

A/B Testing