gpt4 book ai didi

android - 我可以向 Firebase 远程配置声明一个数组吗?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:55:42 25 4
gpt4 key购买 nike

我是 Android 和 Firebase 的新手。是否可以在 Firebase Remote Config 的参数键内声明一个数组? enter image description here

我想为某些特定型号/移动设备提供一些促销 Activity 。因此,如果我可以声明一系列型号(即三星 J5、小米 Note2 等),我可以轻松地在这些型号上启用促销。请帮助我。

最佳答案

Remote Config 最近添加了通过将键值列表保存为 JSON 格式来保存键值列表的选项。

enter image description here

示例用法:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com