Skip to content

Commit

Permalink
- Updates based on pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
justindhill committed Jul 1, 2016
1 parent 1441c80 commit f9eddea
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Analytics/Classes/Internal/SEGSegmentIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ - (id)initWithAnalytics:(SEGAnalytics *)analytics
self.serialQueue = seg_dispatch_queue_create_specific("io.segment.analytics.segmentio", DISPATCH_QUEUE_SERIAL);
self.flushTaskID = UIBackgroundTaskInvalid;
self.analytics = analytics;

#if !TARGET_OS_TV
// Check for previous queue/track data in NSUserDefaults and remove if present
[self dispatchBackground:^{
if ([[NSUserDefaults standardUserDefaults] objectForKey:SEGQueueKey]) {
Expand All @@ -101,13 +103,17 @@ - (id)initWithAnalytics:(SEGAnalytics *)analytics
[[NSUserDefaults standardUserDefaults] removeObjectForKey:SEGTraitsKey];
}
}];
dispatch_sync(dispatch_get_main_queue(), ^{
self.flushTimer = [NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(flush) userInfo:nil repeats:YES];
});


[self addSkipBackupAttributeToItemAtPath:self.userIDURL];
[self addSkipBackupAttributeToItemAtPath:self.anonymousIDURL];
[self addSkipBackupAttributeToItemAtPath:self.traitsURL];
[self addSkipBackupAttributeToItemAtPath:self.queueURL];
#endif

dispatch_sync(dispatch_get_main_queue(), ^{
self.flushTimer = [NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(flush) userInfo:nil repeats:YES];
});
}
return self;
}
Expand Down Expand Up @@ -612,7 +618,7 @@ - (NSMutableArray *)queue
{
if (!_queue) {
#if TARGET_OS_TV
_queue = [[NSUserDefaults standardUserDefaults] objectForKey:SEGQueueKey];
_queue = [[NSUserDefaults standardUserDefaults] objectForKey:SEGQueueKey] ?: [[NSMutableArray alloc] init];
#else
_queue = [NSMutableArray arrayWithContentsOfURL:self.queueURL] ?: [[NSMutableArray alloc] init];
#endif
Expand All @@ -625,7 +631,7 @@ - (NSMutableDictionary *)traits
{
if (!_traits) {
#if TARGET_OS_TV
_traits = [[NSUserDefaults standardUserDefaults] objectForKey:SEGTraitsKey];
_traits = [[NSUserDefaults standardUserDefaults] objectForKey:SEGTraitsKey] ?: [[NSMutableDictionary alloc] init];
#else
_traits = [NSMutableDictionary dictionaryWithContentsOfURL:self.traitsURL] ?: [[NSMutableDictionary alloc] init];
#endif
Expand Down

0 comments on commit f9eddea

Please sign in to comment.