Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Add RemoteConfig Decoder and Encoder #6883

Closed
lorenzofiamingo opened this issue Nov 2, 2020 · 4 comments · Fixed by #9084
Closed

FR: Add RemoteConfig Decoder and Encoder #6883

lorenzofiamingo opened this issue Nov 2, 2020 · 4 comments · Fixed by #9084

Comments

@lorenzofiamingo
Copy link
Contributor

Feature proposal

  • Firebase Component: RemoteConfig
struct Configuration: Codable {
        
    var signinMethods: [String]
}

Decoder

Would be great to have a Decoder like Firestore.Decoder to do something like this:

let remoteConfig = RemoteConfig.remoteConfig()
let decoder = RemoteConfig.Decoder()
let configuration = try! decoder.decode(Configuration.self, from: remoteConfig)

RemoteConfig.Decoder should be able to decode 'RemoteConfigValue' as well:

let remoteConfigValue = RemoteConfig.remoteConfig().configValue(forKey: "authentication")
let decoder = RemoteConfig.Decoder()
let configuration = try! decoder.decode(Configuration.self, from: remoteConfigValue)

Encoder

Would be great to have also an Encoder to set defaults:

let remoteConfig = RemoteConfig.remoteConfig()
let configuration = Configuration(signiInMethods: ["email"])
let encoder = RemoteConfig.Encoder()
let defaults = try! encoder.encode(configuration)
remoteConfig.setDefaults(defaults)

or better, like for Firestore ref.setValue(from: Encodable)

let remoteConfig = RemoteConfig.remoteConfig()
let configuration = Configuration(signiInMethods: ["email"])
try! remoteConfig.setDefaults(from: configuration)
@paulb777
Copy link
Member

@paulb777
Copy link
Member

#9084 now has an initial implementation of the 2nd(RCValue JSON decoding) and 3rd(setDefaults from Encodable) requests.

I'm not sure about the first one. It seems that RC does not have any APIs to get the full configuration, but I'm not sure why that is. So I'm not sure that we should add only a Codable version to do that.

I suppose a workaround is for an app to do everything via a single JSON entry?

@karenyz or anyone else: Any thoughts/guidance on the above questions?

@paulb777
Copy link
Member

I talked with the RC team and it turns out that Android already has an API that returns the full config as a dictionary. See https://firebase.google.com/docs/reference/android/com/google/firebase/remoteconfig/FirebaseRemoteConfig#getAll%28%29

So it looks like we should implement a getAll for Apple and then we can implement the third Codable API requested here on top of it.

@paulb777
Copy link
Member

paulb777 commented Jan 4, 2022

After more thought, a getAll API wouldn't be too useful for Objective C without type safety so I did a direct Swift decoder implementation. Details in #9084 which now has implementations for all three of the requests.

@paulb777 paulb777 added this to the 8.12.0 - M111 milestone Jan 14, 2022
@firebase firebase locked and limited conversation to collaborators Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants