Skip to content

Commit

Permalink
Fix GCD mutual dependency (segmentio#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fathy Boundjadj authored and Sergei Shatunov committed Aug 15, 2019
1 parent 0edcd5d commit 9dd7005
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions Analytics/Classes/Internal/SEGSegmentIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,18 @@ - (id)initWithAnalytics:(SEGAnalytics *)analytics httpClient:(SEGHTTPClient *)ht
[self trackAttributionData:self.configuration.trackAttributionData];
}];

if ([NSThread isMainThread]) {
[self setupFlushTimer];
} else {
dispatch_sync(dispatch_get_main_queue(), ^{
[self setupFlushTimer];
});
}
self.flushTimer = [NSTimer timerWithTimeInterval:self.configuration.flushInterval
target:self
selector:@selector(flush)
userInfo:nil
repeats:YES];

[NSRunLoop.mainRunLoop addTimer:self.flushTimer
forMode:NSDefaultRunLoopMode];
}
return self;
}

- (void)setupFlushTimer
{
self.flushTimer = [NSTimer scheduledTimerWithTimeInterval:self.configuration.flushInterval
target:self
selector:@selector(flush)
userInfo:nil
repeats:YES];
}

/*
* There is an iOS bug that causes instances of the CTTelephonyNetworkInfo class to
* sometimes get notifications after they have been deallocated.
Expand Down

0 comments on commit 9dd7005

Please sign in to comment.