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

标签 android firebase firebase-remote-config

我是 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/

相关文章:

android - 适用于 Android 的简单 TCP 监听器线程..我的连接不上

firebase - 为什么 Google Analytics Firebase 从不显示自定义事件的参数?

firebase - 不同的值取决于 Firebase 远程配置中的操作系统版本

android - Firebase 远程配置获取失败,出现 FirebaseRemoteConfigClientException

java - 如何使用 Jackson 将 json 列表反序列化为 java 对象

Android View setActive、setSelected 和 RecyclerView 状态

firebase - 从 Firebase 控制台检索注册的 token

javascript - FirebaseError - 消息传递/serviceworker 注册失败

android - 如何使用 A/B 测试根据城市为指定用户启用 Android 应用程序中的特定功能

android - 在没有可用连接的情况下尝试更新 Google Drive 上的文件时会发生什么?