Skip to content

Commit 018ebe4

Browse files
bsneedBrandon Sneed
andauthored
Pull IDFA if it has changed and rebuild context if necessary. (#982)
Co-authored-by: Brandon Sneed <[email protected]>
1 parent fa0d3c5 commit 018ebe4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Segment/Classes/SEGAnalytics.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ @interface SEGAnalytics ()
2727
@property (nonatomic, strong) SEGStoreKitTracker *storeKitTracker;
2828
@property (nonatomic, strong) SEGIntegrationsManager *integrationsManager;
2929
@property (nonatomic, strong) SEGMiddlewareRunner *runner;
30+
@property (nonatomic, strong) NSString *lastIDFA;
3031
@end
3132

3233

@@ -47,6 +48,7 @@ - (instancetype)initWithConfiguration:(SEGAnalyticsConfiguration *)configuration
4748
if (self = [self init]) {
4849
self.oneTimeConfiguration = configuration;
4950
self.enabled = YES;
51+
self.lastIDFA = nil;
5052

5153
// In swift this would not have been OK... But hey.. It's objc
5254
// TODO: Figure out if this is really the best way to do things here.
@@ -556,6 +558,16 @@ - (void)run:(SEGEventType)eventType payload:(SEGPayload *)payload
556558
return;
557559
}
558560

561+
if (getAdTrackingEnabled(self.oneTimeConfiguration)) {
562+
// if idfa has changed since last we looked, we need to rebuild
563+
// the static context to pick up the change.
564+
NSString *idfa = self.oneTimeConfiguration.adSupportBlock();
565+
if (![idfa isEqualToString:self.lastIDFA]) {
566+
self.lastIDFA = idfa;
567+
[[SEGState sharedInstance].context updateStaticContext];
568+
}
569+
}
570+
559571
if (self.oneTimeConfiguration.experimental.nanosecondTimestamps) {
560572
payload.timestamp = iso8601NanoFormattedString([NSDate date]);
561573
} else {

0 commit comments

Comments
 (0)