diff --git a/CHANGELOG.md b/CHANGELOG.md index d20e3589..811f0f53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## XX.XX.XX +* Added a config method to disable server config in the initialization "disableSDKBehaviorSettings()". + ## 25.4.1 * Mitigated an issue that could occur while serializing events to improve stability, performance and memory usage. diff --git a/Countly.m b/Countly.m index a83db375..bfcb5d12 100644 --- a/Countly.m +++ b/Countly.m @@ -92,7 +92,10 @@ - (void)startWithConfig:(CountlyConfig *)config config = [self checkAndFixInternalLimitsConfig:config]; - [CountlyServerConfig.sharedInstance retrieveServerConfigFromStorage:config.sdkBehaviorSettings]; + if (config.disableSDKBehaviorSettings) { + [CountlyServerConfig.sharedInstance disableSDKBehaviourSettings]; + } + [CountlyServerConfig.sharedInstance retrieveServerConfigFromStorage:config.sdkBehaviorSettings]; CountlyCommon.sharedInstance.maxKeyLength = config.sdkInternalLimits.getMaxKeyLength; CountlyCommon.sharedInstance.maxValueLength = config.sdkInternalLimits.getMaxValueSize; diff --git a/CountlyConfig.h b/CountlyConfig.h index ba086d03..8af6570d 100644 --- a/CountlyConfig.h +++ b/CountlyConfig.h @@ -675,6 +675,11 @@ typedef enum : NSUInteger */ @property(nonatomic, copy) NSString *sdkBehaviorSettings; +/** + * Disable the server configuration + */ +@property(nonatomic) BOOL disableSDKBehaviorSettings; + #if (TARGET_OS_IOS) /** * Variable to access content configurations. diff --git a/CountlyServerConfig.h b/CountlyServerConfig.h index 85194109..ce9ecbfd 100644 --- a/CountlyServerConfig.h +++ b/CountlyServerConfig.h @@ -15,6 +15,7 @@ extern NSString* const kCountlySCKeySC; - (void)fetchServerConfig:(CountlyConfig *)config; - (void)retrieveServerConfigFromStorage:(NSString*) sdkBehaviorSettings; - (void)fetchServerConfigIfTimeIsUp; +- (void)disableSDKBehaviourSettings; - (BOOL)trackingEnabled; - (BOOL)networkingEnabled; diff --git a/CountlyServerConfig.m b/CountlyServerConfig.m index 0463af8e..57f622e6 100644 --- a/CountlyServerConfig.m +++ b/CountlyServerConfig.m @@ -38,6 +38,7 @@ @interface CountlyServerConfig () { @property (nonatomic) NSInteger version; @property (nonatomic) long long timestamp; @property (nonatomic) long long lastFetchTimestamp; +@property (nonatomic) BOOL serverConfigDisabled; @end @@ -108,12 +109,16 @@ - (instancetype)init _version = 0; _currentServerConfigUpdateInterval = 4; _requestTimer = nil; + _serverConfigDisabled = NO; } return self; } - (void)retrieveServerConfigFromStorage:(NSString *)sdkBehaviorSettings { + if (_serverConfigDisabled) { + return; + } NSError *error = nil; NSDictionary *serverConfigObject = [CountlyPersistency.sharedInstance retrieveServerConfig]; if (serverConfigObject.count == 0 && sdkBehaviorSettings) @@ -197,6 +202,10 @@ - (void)populateServerConfig:(NSDictionary *)serverConfig - (void)notifySdkConfigChange:(CountlyConfig *)config { + if (_serverConfigDisabled) { + return; + } + config.enableDebug = _loggingEnabled || config.enableDebug; CountlyCommon.sharedInstance.enableDebug = config.enableDebug; @@ -297,6 +306,10 @@ - (void)fetchServerConfigTimer:(NSTimer *)timer - (void)fetchServerConfigIfTimeIsUp { + if (_serverConfigDisabled) { + return; + } + if (_lastFetchTimestamp) { long long currentTime = NSDate.date.timeIntervalSince1970 * 1000; @@ -311,7 +324,11 @@ - (void)fetchServerConfigIfTimeIsUp - (void)fetchServerConfig:(CountlyConfig *)config { + if (_serverConfigDisabled) { + return; + } CLY_LOG_D(@"Fetching server configs..."); + if (CountlyDeviceInfo.sharedInstance.isDeviceIDTemporary) return; @@ -399,6 +416,10 @@ - (NSURLRequest *)serverConfigRequest CLY_LOG_D(@"serverConfigRequest URL :%@", URL); } +- (void)disableSDKBehaviourSettings { + _serverConfigDisabled = YES; +} + - (BOOL)trackingEnabled { return _trackingEnabled;