Skip to content

Commit

Permalink
feat: add content zone timer interval
Browse files Browse the repository at this point in the history
  • Loading branch information
arifBurakDemiray committed Dec 9, 2024
1 parent a19d604 commit 5579d17
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Countly.m
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ - (void)startWithConfig:(CountlyConfig *)config
if(config.content.getGlobalContentCallback) {
CountlyContentBuilderInternal.sharedInstance.contentCallback = config.content.getGlobalContentCallback;
}
if(config.content.getZoneTimerInterval){
CountlyContentBuilderInternal.sharedInstance.zoneTimerInterval = config.content.getZoneTimerInterval;
}
#endif

[CountlyPerformanceMonitoring.sharedInstance startWithConfig:config.apm];
Expand Down
2 changes: 1 addition & 1 deletion CountlyContentBuilderInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface CountlyContentBuilderInternal: NSObject
#if (TARGET_OS_IOS)
@property (nonatomic, strong) NSArray<NSString *> *currentTags;
@property (nonatomic, assign) NSTimeInterval requestInterval;
@property (nonatomic, assign) NSTimeInterval zoneTimerInterval;
@property (nonatomic) ContentCallback contentCallback;

+ (instancetype)sharedInstance;
Expand Down
4 changes: 2 additions & 2 deletions CountlyContentBuilderInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ - (instancetype)init
{
if (self = [super init])
{
self.requestInterval = 30.0;
self.zoneTimerInterval = 30.0;
_requestTimer = nil;
}

Expand All @@ -55,7 +55,7 @@ - (void)enterContentZone:(NSArray<NSString *> *)tags {
self.currentTags = tags;

[self fetchContents];;
_requestTimer = [NSTimer scheduledTimerWithTimeInterval:self.requestInterval
_requestTimer = [NSTimer scheduledTimerWithTimeInterval:self.zoneTimerInterval
target:self
selector:@selector(fetchContents)
userInfo:nil
Expand Down
14 changes: 14 additions & 0 deletions CountlyContentConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ typedef void (^ContentCallback)(ContentStatus contentStatus, NSDictionary<NSStri
* Get content callback
*/
- (ContentCallback) getGlobalContentCallback;

/**
* This is an experimental feature and it can have breaking changes
* Set the interval for the automatic content update calls
* @param zoneTimerIntervalSeconds in seconds
*
*/
-(void)setZoneTimerInterval:(NSUInteger)zoneTimerIntervalSeconds;

/**
* This is an experimental feature and it can have breaking changes
* Get zone timer interval
*/
- (NSUInteger) getZoneTimerInterval;
#endif

NS_ASSUME_NONNULL_END
Expand Down
14 changes: 14 additions & 0 deletions CountlyContentConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@interface CountlyContentConfig ()
#if (TARGET_OS_IOS)
@property (nonatomic) ContentCallback contentCallback;
@property (nonatomic) NSUInteger zoneTimerInterval;
#endif
@end

Expand All @@ -33,6 +34,19 @@ - (ContentCallback) getGlobalContentCallback
{
return self.contentCallback;
}


-(void)setZoneTimerInterval:(NSUInteger)zoneTimerIntervalSeconds
{
if (zoneTimerIntervalSeconds > 15) {
self.zoneTimerInterval = zoneTimerIntervalSeconds;
}
}

- (NSUInteger) getZoneTimerInterval
{
return self.zoneTimerInterval;
}
#endif

@end

0 comments on commit 5579d17

Please sign in to comment.