Skip to content

Commit 03389d1

Browse files
authored
Merge pull request #380 from Countly/content_initial_delay
feat: initial delay for the content
2 parents b6843f3 + a2bd79c commit 03389d1

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

CountlyContentBuilderInternal.m

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ @implementation CountlyContentBuilderInternal {
1515
NSTimer *_requestTimer;
1616
NSTimer *_minuteTimer;
1717
}
18+
19+
NSInteger const contentInitialDelay = 4;
20+
1821
#if (TARGET_OS_IOS)
1922
+ (instancetype)sharedInstance {
2023
static CountlyContentBuilderInternal *instance = nil;
@@ -53,13 +56,21 @@ - (void)enterContentZone:(NSArray<NSString *> *)tags {
5356
}
5457

5558
self.currentTags = tags;
59+
int contentDelay = 0;
60+
61+
if (CountlyCommon.sharedInstance.timeSinceLaunch < contentInitialDelay) {
62+
contentDelay = contentInitialDelay;
63+
}
5664

57-
[self fetchContents];;
58-
_requestTimer = [NSTimer scheduledTimerWithTimeInterval:self.zoneTimerInterval
59-
target:self
60-
selector:@selector(fetchContents)
61-
userInfo:nil
62-
repeats:YES];
65+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(contentDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^
66+
{
67+
[self fetchContents];;
68+
self->_requestTimer = [NSTimer scheduledTimerWithTimeInterval:self->_zoneTimerInterval
69+
target:self
70+
selector:@selector(fetchContents)
71+
userInfo:nil
72+
repeats:YES];
73+
});
6374
}
6475

6576
- (void)exitContentZone {

0 commit comments

Comments
 (0)