Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export all firebase remote config keys and values?

I want to migrate from existing firebase project to a new firebase project Issue is that I have a lot of remote config keys and values in my existing project Now I want to export all remote config keys and values then import to the new firebase project rather than writing everything over again in new project.

Is there any easy way to do it?.

like image 286
Sreedhu Madhu Avatar asked Oct 13 '17 06:10

Sreedhu Madhu


People also ask

How do I get data from Firebase remote config?

Getting started Run the sample on an Android device or emulator. Change one or more parameter values in the Firebase Console (the value of welcome_message , welcome_message_caps , or both). Tap Fetch Remote Config in the app to fetch new parameter values and see the resulting change in the app.

Is remote config free Firebase?

Firebase Remote Config is part of the Firebase platform and is available for free on both iOS and Android.


2 Answers

You cannot do it from the Firebase console, but you can write a simple script which uses the Remote Config REST API - https://firebase.google.com/docs/remote-config/use-config-rest

So essentially you can download remote config from one project and then upload that into the new project - programmatically.

Cheers!

like image 168
Mayank Jain Avatar answered Sep 20 '22 02:09

Mayank Jain


You can get the remote config keys and values as follows (Swift 4.2):

let remoteConfig = RemoteConfig.remoteConfig()
let ns = NamespaceGoogleMobilePlatform // Oddly evaluates to: "configns:firebase" including spelling mistake

let remoteKeys = remoteConfig.allKeys(from: .remote, namespace: ns)
let remoteDict = Dictionary(uniqueKeysWithValues: remoteKeys.map { ($0, remoteConfig[$0].stringValue) })

let defaultKeys = remoteConfig.allKeys(from: .default, namespace: ns)
let defaultDict = Dictionary(uniqueKeysWithValues: defaultKeys.map { ($0, remoteConfig[$0].stringValue) })

let staticKeys = remoteConfig.allKeys(from: .static, namespace: ns)
let staticDict = Dictionary(uniqueKeysWithValues: staticKeys.map { ($0, remoteConfig[$0].stringValue) })

In my brief searching, I couldn't get the flattened remoteConfig keys and values (i.e. what gets returned when using the subscript: remoteConfig[key]). I'm guessing you'd just need to overlay the remote values over the default values?

like image 24
Scott Wood Avatar answered Sep 18 '22 02:09

Scott Wood