I'm trying to implement Firebase Remote Config in my iOS app. Everything works fine, but there is a problem - a remote config always fetches data from firebase server, not from cache. I have tried a lot of variants without any success. This is my code:
+ (instancetype)sharedInstance
{
static ConfigManager *_sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedInstance = [[self alloc] init];
});
return _sharedInstance;
}
-(instancetype)init
{
self = [super init];
if (self) {
self.remoteConfig = [FIRRemoteConfig remoteConfig];
[self updateRemoteConfig];
}
return self;
}
- (void)activateDebugMode
{
FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:YES];
self.remoteConfig.configSettings = remoteConfigSettings;
}
- (void)updateRemoteConfig
{
[self fetchConfigWithCompletionHandler:nil];
}
- (void)fetchConfigWithCompletionHandler: (FireBaseConfigCompletionHandler)completionHandler
{
NSTimeInterval cacheExpiration = 43200;
BOOL debug = ConfigurationValue(DebugMode);
if (debug) {
cacheExpiration = 0;
[self activateDebugMode];
}
[self.remoteConfig fetchWithExpirationDuration:cacheExpiration completionHandler:^(FIRRemoteConfigFetchStatus status, NSError * _Nullable error) {
if (status == FIRRemoteConfigFetchStatusSuccess) {
NSLog(@"Config fetched!");
[self.remoteConfig activateFetched];
// do smth
} else {
NSLog(@"Config not fetched");
NSLog(@"Error %@", error.localizedDescription);
}
}];
}
Even I use fetchWithCompletionHandler without cacheExpriration parameter, it also doesn't work. Setting remoteConfigSettings in debugMode = FALSE doesn't work either. I created a small test app with the same code and it works! The only difference us that I can see is "Enable Modules" parameter in Built Settings. What am I doing wrong? Thank you in advance!
debug
variable is actually false, etc? – Undeniable