How to use FirebaseRemoteConfig with Codable protocol? #14365
-
| Hello ! Now I tried to import  Any idea how to do this ? Thanks | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
| I've explained this in this video: https://www.youtube.com/shorts/NhKQBpedL-o Here's the code struct ShadowConfiguration: Codable {
  var colorValue: String
  var offsetX: CGFloat
  var offsetY: CGFloat
  var radius: CGFloat
  var color: Color { Color(hex: colorValue) }
}
struct FavouriteNumberView: View {
  @StateObject var viewModel = ViewModel()
  let rc = RemoteConfig.remoteConfig()
  @RemoteConfigProperty(key: "cardShadow",
                        fallback: .default)
  var cardShadow: ShadowConfiguration
  var body: some View {
    VStack {
      Text("What's your favourite number?")
      // ...
    }
    .clipShape(RoundedRectangle(cornerRadius: 16))
    .shadow(color: cardShadow.color,
            radius: cardShadow.radius,
            x: cardShadow.offsetX,
            y: cardShadow.offsetY)
    .onAppear {
      rc.addOnConfigUpdateListener { _, _ in
        rc.activate()
      }
    }
  }
} | 
Beta Was this translation helpful? Give feedback.
@FlorinDMass - I've updated our docs accordingly: https://firebase.google.com/docs/remote-config/get-started?platform=ios