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

Introduction:

In this article, we will cover Integration of Remote Configuration in Unity Project using Official Plugin (Huawei HMS Core App Services).

Requirements:

1. Unity Editor

2. Huawei device

3. Visual Studio

Follows the steps:

Step 1. Create Unity Project.

Click unity icon.

Click NEW, select 3D, Project Name and Location.

Click CREATE, as follows.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200909182613.96819752866054274486390465437934:50511013022111:2800:7411CB0104A6DE7139BE6E8D4B51B7B3C4DA25B2E55EC79E8759CDA3D96F0525.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200909182613.96819752866054274486390465437934:50511013022111:2800:7411CB0104A6DE7139BE6E8D4B51B7B3C4DA25B2E55EC79E8759CDA3D96F0525.png[/IMG]

Step 2. Click Asset Store, search Huawei HMS Core App Services and click Import, as follows.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200930033442.10989220252298423694594955883562:50511013022111:2800:E9056C902A3A2AB134B5C5E1762C29CA895417D3D99F5FDBD2984B08285E0661.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200930033442.10989220252298423694594955883562:50511013022111:2800:E9056C902A3A2AB134B5C5E1762C29CA895417D3D99F5FDBD2984B08285E0661.png[/IMG]

Step 3. Once import is successful, verify directory in Assets > Huawei HMS Core App Services path, as follows.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200909190648.33556446754008940797573999985728:50511013022111:2800:E6E0B50EF63EA068E6BB0555F808B865A1780B664124A7A4E1276855D6196989.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200909190648.33556446754008940797573999985728:50511013022111:2800:E6E0B50EF63EA068E6BB0555F808B865A1780B664124A7A4E1276855D6196989.png[/IMG]

Step 4. Click Console and create a New Project.

Step 5. Choose Project Settings > Player and edit the required options in Publishing Settings, as follows.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200909193633.77140517757452803046760722378315:50511013024145:2800:E9BD1167918C18ABE85F3C48EBB17C17D6089A8C14D4824D49D7AF85B8D69B17.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200909193633.77140517757452803046760722378315:50511013024145:2800:E9BD1167918C18ABE85F3C48EBB17C17D6089A8C14D4824D49D7AF85B8D69B17.png[/IMG]

Step 6. Verify the files created in Step 5.

Step 7. Download agconnect-services.json and copy to Assets>Plugins>Android, as follows.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200909193849.52729613124561551678071615718070:50511013022111:2800:2F8AA24CCF85101723D5191BC1DE9B44B7E0D5F3DA3FEE61767D62AF44D13F54.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200909193849.52729613124561551678071615718070:50511013022111:2800:2F8AA24CCF85101723D5191BC1DE9B44B7E0D5F3DA3FEE61767D62AF44D13F54.png[/IMG]

Step 8. Update the Package Name.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200909194457.40612004953515603531973546931472:50511013022111:2800:FA8DC8D7F5523015B5AE7023E851C547E6B1F57A7CB277FC312E4481E38294A5.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200909194457.40612004953515603531973546931472:50511013022111:2800:FA8DC8D7F5523015B5AE7023E851C547E6B1F57A7CB277FC312E4481E38294A5.png[/IMG]

Step 9. Open LauncherTemplate.gradle and add below line

apply plugin: 'com.huawei.agconnect'

Step 10. Open "baseProjectTemplate.gradle" and add lines, as follows.

maven {url 'https://developer.huawei.com/repo/'}

classpath 'com.huawei.agconnect:agcp:1.4.1.300'

Step 11. Open "mainTemplate.gradle" and add lines like shown below

apply plugin: 'com.huawei.agconnect'

implementation 'com.huawei.agconnect:agconnect-core:1.3.1.300'
implementation 'com.huawei.agconnect:agconnect-remoteconfig:1.4.1.300'

Step 12. Open AndroidManifest file and Add Activity like shown below.

<activity android:name="com.hms.hms_analytic_activity.TestAppLinksActivity"
android:theme="@style/UnityThemeSelector">

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

</intent-filter>

</activity>

Step 13. Create TestAppLinksActivity.java and place it in Assets->Plugins->Android.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200923065535.88643884367307413129197962069048:50511013022111:2800:C1CFE0FB57ED55E7B03E5362D61758AFE535F19729099B9B7E47C8390072FDCC.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/002/032/901/2640091000002032901.20200923065535.88643884367307413129197962069048:50511013022111:2800:C1CFE0FB57ED55E7B03E5362D61758AFE535F19729099B9B7E47C8390072FDCC.png[/IMG]

TestAppLinksActivity.java

//package com.test.applinks;
package com.hms.hms_analytic_activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import com.unity3d.player.UnityPlayerActivity;

import android.widget.Toast;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.huawei.agconnect.remoteconfig.AGConnectConfig;
import com.huawei.agconnect.remoteconfig.ConfigValues;
import com.huawei.hmf.tasks.OnFailureListener;
import com.huawei.hmf.tasks.OnSuccessListener;
import com.unity3d.player.R;
//import com.test.remote.config.R;
import com.test.mylibrary.MyLibClass;
import com.test.mylibrary.MyContext;

//import androidx.appcompat.app.AppCompatActivity;

public class TestAppLinksActivity extends UnityPlayerActivity {

private static final String GREETING_KEY = "GREETING_KEY";
private static final String SET_BOLD_KEY = "SET_BOLD_KEY";
private static AGConnectConfig config;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Log.e("TestAppLinksActivity ", "onCreate>> @@");

config = AGConnectConfig.getInstance();

MyLibClass a = new MyLibClass(new MyContext(this));

//config.applyDefault(R.xml.remote_config);
config.applyDefault(a.getRemoteConfigFileId());

String key = config.getValueAsString(GREETING_KEY);
Boolean isBold = config.getValueAsBoolean(SET_BOLD_KEY);
Log.e("TestAppLinksActivity ", " values from remote config files-key->>"+key+"<-----isBold---->"+isBold);

}

public static void getSavedConfig() {
Log.e("TestAppLinksActivity ", " getSavedConfig >>");
config = AGConnectConfig.getInstance();

String key = config.getValueAsString(GREETING_KEY);
Boolean isBold = config.getValueAsBoolean(SET_BOLD_KEY);
Log.e("TestAppLinksActivity ", "values from saved remote config -key->>"+key+"<-----isBold---->"+isBold);

}

public static void setCallback() {
Log.e("TestAppLinksActivity ", "setCallback>> @@");

fetchAndApply();

}

private static void fetchAndApply(){
config = AGConnectConfig.getInstance();
Log.e("TestAppLinksActivity", "fetchAndApply config>>"+config);
String key = config.getValueAsString(GREETING_KEY);
Boolean isBold = config.getValueAsBoolean(SET_BOLD_KEY);
Log.e("TestAppLinksActivity", "values from remote config files-key->>"+key+"<-----isBold---->"+isBold);

Log.e("TestAppLinksActivity", "fetchAndApply>>");
config.fetch(0).addOnSuccessListener(new OnSuccessListener<ConfigValues>() {
@Override
public void onSuccess(ConfigValues configValues) {
Log.e("TestAppLinksActivity", "fetchAndApply onSuccess>>"+configValues);
// Apply Network Config to Current Config
config.apply(configValues);
//updateUI();

String key = config.getValueAsString(GREETING_KEY);
Boolean isBold = config.getValueAsBoolean(SET_BOLD_KEY);
Log.e("TestAppLinksActivity", "values from updated remote config files-key->>"+key+"<-----isBold---->"+isBold);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
//textView.setText("fetch setting failed: " + e.getMessage());
Log.e("TestAppLinksActivity", " fetchAndApply onFailure>>"+e.getMessage());
}
});
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
//handleAppLinking(intent);
}

}

Code Explanation - Please refer

https://developer.huawei.com/consumer/en/codelab/RemoteConfig/index.html#8

For full content, you can visit https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201361479871390297&fid=0101188387844930001