我可以向Firebase远程配置声明一个数组吗? [英] Can I declare an array to Firebase Remote config?

查看:64
本文介绍了我可以向Firebase远程配置声明一个数组吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android和Firebase的新手.是否可以在Firebase Remote Config的Parameter键中声明一个数组?

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

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

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.

推荐答案

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

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

样品用量:

1.Json存储在远程配置中:

1.Json stored in Remote Configs:

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

2.Kotlin模型

2.Kotlin model

数据类Lesson(val课程: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());

这篇关于我可以向Firebase远程配置声明一个数组吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆