https://firebase.google.com/docs/ios/setup
🏗 Work in progress 🏗
Firebase A/B testing is still in Beta, so does Reversi.
Firebase before Reversi
var welcomeMessage = remoteConfig[welcomeMessageConfigKey].stringValueFirebase with Reversi
var welcomeMessage = "Welcome"
welcomeMessage.addVariation(welcomeMessageConfigKey, for: String.self) { welcomeMessage, newText in
welcomeMessage = newText
}It looks more complex but the second block looks a bit more clear. You know which implementation is default and the part that relies on variation.
Reversi can support feature flags through RemoteConfig from Firebase.
func canExecute<T>(_ variation: Variation<T>) -> Bool {
// careful here, default config can kicks in if remote isn't fetch yet
// make sure of your default config to use it that way
return remoteConfig[variation.key].boolValue
}
func execute<T>(_ variation: Variation<T>, options: [String : Any]?) {
// detect Void type
if let variation = variation as? Variation<Void> {
variation.execute(with: ())
return
}
// Bool type
if let variation = variation as? Variation<Bool> {
let value = remoteConfig[variation.key].boolValue
variation.execute(with: value)
return
}
// String type
if let variation = variation as? Variation<String>,
let value = remoteConfig[variation.key].stringValue {
variation.execute(with: value)
return
}
// Int type
if let variation = variation as? Variation<Int>,
let value = remoteConfig[variation.key].numberValue?.intValue {
variation.execute(with: value)
return
}
...
}