Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I declare an array to Firebase Remote config?

Tags:

I am a novice to Android and Firebase. Is it possible to declare an array inside the the Parameter key of Firebase Remote Config? enter image description here

I want to provide some promotions to some specific models/mobile devices. So if I could declare an array of models(i,e, Samsung J5, Xiaomi Note2 etc) I could easily enable promotions on those models. Please help me.

like image 1000
Munir Hoque Avatar asked Feb 13 '17 10:02

Munir Hoque


People also ask

What is firebase remote config used for?

Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update. When using Remote Config, you create in-app default values that control the behavior and appearance of your app.

Is firebase remote config realtime?

Hey Mobile Developers, today, I want to open an exciting topic from my perspective, and this is a realtime remote configuration for our mobile apps. In the following article I will explain to you: What does remote config mean and for what cases you can use it?

What file should be used for your remote config template?

When using this feature, we recommend configuring default values for all parameters in the Firebase console. Use XML , PLIST , or JSON as the format value, depending on which file format you want to download.


1 Answers

The Remote Config has recently added the option to save a key-value list by saving it to a JSON format.

enter image description here

Sample usage:

1.Json stored in Remote Configs:

 [       {         "lesson": "1",         "versionCode": 2       },       {         "lesson": "2",         "versionCode": 4       },       {         "lesson": "3",         "versionCode": 1       }  ] 

2.Kotlin model

data class Lesson(val lesson: Int, val versionCode: Int)

3.Retrieve json

String object = FirebaseRemoteConfig.getInstance().getString("test_json"); Gson gson = new GsonBuilder().create(); List<Lesson> lessons = gson.fromJson(object, new TypeToken<List<Lesson>>(){}.getType()); 
like image 109
android_dev Avatar answered Oct 21 '22 07:10

android_dev