Skip to content

Commit

Permalink
enable realtime updates for remote config on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ry-itto committed Sep 12, 2023
1 parent f5e04b0 commit 013cf81
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions app-ios/Modules/Sources/RemoteConfig/RemoteConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@ import FirebaseRemoteConfig
import shared

public class RemoteConfigApiImpl: RemoteConfigApi {
public init() {}
private let remoteConfig = RemoteConfig.remoteConfig()

public init() {
remoteConfig.addOnConfigUpdateListener { [weak remoteConfig] configUpdate, error in
guard let configUpdate, error == nil else {
print("Error listening for config updates: \(error)")
return
}

print("Updated keys: \(configUpdate.updatedKeys)")

remoteConfig?.activate()
}
}

public func getBoolean(key: String) async throws -> KotlinBoolean {
.init(
bool: RemoteConfig.remoteConfig().configValue(forKey: key).boolValue
bool: remoteConfig.configValue(forKey: key).boolValue
)
}
public func getString(key: String) async throws -> String {
return RemoteConfig.remoteConfig().configValue(forKey: key).stringValue ?? ""
return remoteConfig.configValue(forKey: key).stringValue ?? ""
}
}

0 comments on commit 013cf81

Please sign in to comment.