Reputation: 221
I have created an AB Test on Firebase(not Published yet) and added token of a test device. But the value is not coming for the provided key.
As AB testing is in Beta, so is it a bug on Firebase side that it doesn't work on test devices?
let remoteConfig = RemoteConfig.remoteConfig()
remoteConfig.fetch(withExpirationDuration: 0) { status, _ in
if status == RemoteConfigFetchStatus.success {
remoteConfig.activateFetched()
let ab_test_value = remoteConfig.configValue(forKey: "ab_test_key").stringValue
print(ab_test_value)
}}
The ab_test_value is coming as empty.
Upvotes: 1
Views: 827
Reputation: 100503
Try this may your variable is deallocated when response come
var remoteConfig:FIRRemoteConfig?
///
var expirationDuration = 43200;
// If in developer mode cacheExpiration is set to 0 so each fetch will retrieve values from
// the server.
if (remoteConfig?.configSettings.isDeveloperModeEnabled)!
{
expirationDuration = 0;
}
self.remoteConfig?.fetch(withExpirationDuration: TimeInterval(expirationDuration))
{
(status, error) -> Void in
if status == .success
{
print("Config fetched!")
self.remoteConfig?.activateFetched()
}
else
{
print("Config not fetched")
print("Error \(error!.localizedDescription)")
// return
}
self.displayWelcome()
}
}
Upvotes: 2