Skip to content

Commit

Permalink
Merge pull request #314 from Countly/turtledreams-patch-1
Browse files Browse the repository at this point in the history
Update CountlyRemoteConfigInternal.m
  • Loading branch information
turtledreams authored Jul 1, 2024
2 parents 0a0283e + e5139bd commit a0fc424
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions CountlyRemoteConfigInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ - (id)remoteConfigValueForKey:(NSString *)key

- (void)clearCachedRemoteConfig
{
CLY_LOG_D(@"'clearCachedRemoteConfig' will cache or erase all remote config values.");
if (!self.isRCValueCachingEnabled)
{
[self clearAll];
Expand All @@ -178,6 +179,7 @@ - (void)clearCachedRemoteConfig

-(void)clearAll
{
CLY_LOG_D(@"'clearAll' will erase all remote config values.");
self.cachedRemoteConfig = NSMutableDictionary.new;
[CountlyPersistency.sharedInstance storeRemoteConfig:self.cachedRemoteConfig];
}
Expand Down Expand Up @@ -420,6 +422,7 @@ - (NSDictionary *) createRCMeta:(NSDictionary *) remoteConfig

- (void)updateMetaStateToCache
{
CLY_LOG_D(@"'updateMetaStateToCache' will cache all remote config values.");
[self.cachedRemoteConfig enumerateKeysAndObjectsUsingBlock:^(NSString * key, CountlyRCData * countlyRCMeta, BOOL * stop)
{
countlyRCMeta.isCurrentUsersData = NO;
Expand Down Expand Up @@ -605,16 +608,12 @@ - (void)testingEnrollIntoVariantInternal:(NSString *)key variantName:(NSString *

NSURLRequest* request = [self enrollInVarianRequestForKey:key variantName:variantName];
NSURLSessionTask* task = [NSURLSession.sharedSession dataTaskWithRequest:request completionHandler:^(NSData* data, NSURLResponse* response, NSError* error)
{
{
NSDictionary* variants = nil;

[self clearCachedRemoteConfig];
if (!error)
{
variants = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
}

if (!error)
{
if (((NSHTTPURLResponse*)response).statusCode != 200)
{
NSMutableDictionary* userInfo = variants.mutableCopy;
Expand All @@ -635,17 +634,10 @@ - (void)testingEnrollIntoVariantInternal:(NSString *)key variantName:(NSString *
return;
}

[self clearCachedRemoteConfig];
[self downloadRemoteConfigAutomatically];

CLY_LOG_D(@"Enroll RC Variant Request <%p> successfully completed.", request);

[self updateRemoteConfigForKeys:nil omitKeys:nil completionHandler:^(NSError *updateRCError) {
dispatch_async(dispatch_get_main_queue(), ^
{
completionHandler(CLYResponseSuccess, nil);
});
}];
[self downloadRemoteConfigAutomatically];

}];

Expand Down

0 comments on commit a0fc424

Please sign in to comment.