Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add content zone timer interval #370

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## XX.XX.XX
* Added a config option to content (setZoneTimerInterval) to set content zone timer. (Experimental!)

## 24.7.9
* Improved view tracking capabilities

Expand Down
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
Loading