我是 Android 和 Firebase 的新手。 是否可以在 Firebase Remote Config 的参数键内声明一个数组?
我想为某些特定型号/移动设备提供一些促销 Activity 。因此,如果我可以声明一系列型号(即三星 J5、小米 Note2 等),我可以轻松地在这些型号上启用促销。 请帮助我。
最佳答案
Remote Config 最近添加了通过将键值列表保存为 JSON 格式来保存键值列表的选项。
示例用法:
1.Json存储在Remote Configs中:
[
{
"lesson": "1",
"versionCode": 2
},
{
"lesson": "2",
"versionCode": 4
},
{
"lesson": "3",
"versionCode": 1
}
]
2.Kotlin模型
数据类 Lesson(val lesson: Int, val versionCode: Int)
3.获取json
String object = FirebaseRemoteConfig.getInstance().getString("test_json");
Gson gson = new GsonBuilder().create();
List<Lesson> lessons = gson.fromJson(object, new TypeToken<List<Lesson>>(){}.getType());
关于android - 我可以向 Firebase 远程配置声明一个数组吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42201937/