Skip to content

Commit

Permalink
Merge pull request #606 from adjust/v4300
Browse files Browse the repository at this point in the history
Version 4.30.0
  • Loading branch information
Aditi3 authored May 3, 2022
2 parents f0de0b0 + 128c289 commit 334c261
Show file tree
Hide file tree
Showing 41 changed files with 346 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Adjust.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = "Adjust"
s.version = "4.29.7"
s.version = "4.30.0"
s.summary = "This is the iOS SDK of adjust. You can read more about it at http://adjust.com."
s.homepage = "https://github.com/adjust/ios_sdk"
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
s.author = { "Adjust GmbH" => "sdk@adjust.com" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.29.7" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.30.0" }
s.ios.deployment_target = '9.0'
s.tvos.deployment_target = '9.0'
s.framework = 'SystemConfiguration'
Expand Down
1 change: 1 addition & 0 deletions Adjust/ADJActivityHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
- (void)trackSubscription:(ADJSubscription * _Nullable)subscription;
- (void)updateAttStatusFromUserCallback:(int)newAttStatusFromUser;
- (void)trackAdRevenue:(ADJAdRevenue * _Nullable)adRevenue;
- (void)checkForNewAttStatus;

- (ADJPackageParams * _Nullable)packageParams;
- (ADJActivityState * _Nullable)activityState;
Expand Down
142 changes: 127 additions & 15 deletions Adjust/ADJActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,14 @@ - (void)trackAdRevenue:(ADJAdRevenue *)adRevenue {
}];
}

- (void)checkForNewAttStatus {
[ADJUtil launchInQueue:self.internalQueue
selfInject:self
block:^(ADJActivityHandler * selfI) {
[selfI checkForNewAttStatusI:selfI];
}];
}

- (void)writeActivityState {
[ADJUtil launchInQueue:self.internalQueue
selfInject:self
Expand Down Expand Up @@ -914,7 +922,7 @@ - (void)initI:(ADJActivityHandler *)selfI
if (selfI.adjustConfig.eventBufferingEnabled) {
[selfI.logger info:@"Event buffering is enabled"];
}

if (selfI.adjustConfig.defaultTracker != nil) {
[selfI.logger info:@"Default tracker: '%@'", selfI.adjustConfig.defaultTracker];
}
Expand Down Expand Up @@ -1034,7 +1042,9 @@ - (void)startI:(ADJActivityHandler *)selfI {
}

[selfI updateHandlersStatusAndSendI:selfI];


[selfI processCoppaComplianceI:selfI];

[selfI processSessionI:selfI];

[selfI checkAttributionStateI:selfI];
Expand Down Expand Up @@ -1064,6 +1074,8 @@ - (void)processSessionI:(ADJActivityHandler *)selfI {
if ([ADJUserDefaults getGdprForgetMe]) {
[selfI setGdprForgetMeI:selfI];
} else {
[selfI processCoppaComplianceI:selfI];

// check if disable third party sharing request came, then send it first
if ([ADJUserDefaults getDisableThirdPartySharing]) {
[selfI disableThirdPartySharingI:selfI];
Expand Down Expand Up @@ -1356,6 +1368,10 @@ - (void)disableThirdPartySharingI:(ADJActivityHandler *)selfI {
if (selfI.activityState.isThirdPartySharingDisabled) {
return;
}
if (selfI.adjustConfig.coppaCompliantEnabled) {
[selfI.logger warn:@"Call to disable third party sharing API ignored, already done when COPPA enabled"];
return;
}

[ADJUtil launchSynchronisedWithObject:[ADJActivityState class]
block:^{
Expand Down Expand Up @@ -1399,6 +1415,10 @@ - (BOOL)trackThirdPartySharingI:(ADJActivityHandler *)selfI
if (selfI.activityState.isGdprForgotten) {
return NO;
}
if (selfI.adjustConfig.coppaCompliantEnabled) {
[selfI.logger warn:@"Calling third party sharing API not allowed when COPPA enabled"];
return NO;
}

double now = [NSDate.date timeIntervalSince1970];

Expand Down Expand Up @@ -1497,6 +1517,23 @@ - (void)trackAdRevenueI:(ADJActivityHandler *)selfI
}
}

- (void)checkForNewAttStatusI:(ADJActivityHandler *)selfI {
if (!selfI.activityState) {
return;
}
if (![selfI isEnabledI:selfI]) {
return;
}
if (selfI.activityState.isGdprForgotten) {
return;
}
if (!selfI.trackingStatusManager) {
return;
}

[selfI.trackingStatusManager checkForNewAttStatus];
}

- (void)launchEventResponseTasksI:(ADJActivityHandler *)selfI
eventResponseData:(ADJEventResponseData *)eventResponseData {
[selfI updateAdidI:selfI adid:eventResponseData.adid];
Expand Down Expand Up @@ -1709,29 +1746,18 @@ - (void)setEnabledI:(ADJActivityHandler *)selfI enabled:(BOOL)enabled {

// Check if upon enabling install has been tracked.
if (enabled) {
if (![ADJUserDefaults getInstallTracked]) {
double now = [NSDate.date timeIntervalSince1970];
[self trackNewSessionI:now withActivityHandler:selfI];
}
NSData *deviceToken = [ADJUserDefaults getPushTokenData];
if (deviceToken != nil && ![selfI.activityState.deviceToken isEqualToString:[ADJUtil convertDeviceToken:deviceToken]]) {
[self setDeviceToken:deviceToken];
}
NSString *pushToken = [ADJUserDefaults getPushTokenString];
if (pushToken != nil && ![selfI.activityState.deviceToken isEqualToString:pushToken]) {
[self setPushToken:pushToken];
}
if ([ADJUserDefaults getGdprForgetMe]) {
[selfI setGdprForgetMe];
} else {
[selfI processCoppaComplianceI:selfI];
if ([ADJUserDefaults getDisableThirdPartySharing]) {
[selfI disableThirdPartySharing];
}
if (selfI.savedPreLaunch.preLaunchAdjustThirdPartySharingArray != nil) {
for (ADJThirdPartySharing *thirdPartySharing
in selfI.savedPreLaunch.preLaunchAdjustThirdPartySharingArray)
{
[selfI trackThirdPartySharing:thirdPartySharing];
[selfI trackThirdPartySharingI:selfI thirdPartySharing:thirdPartySharing];
}

selfI.savedPreLaunch.preLaunchAdjustThirdPartySharingArray = nil;
Expand All @@ -1745,6 +1771,19 @@ - (void)setEnabledI:(ADJActivityHandler *)selfI enabled:(BOOL)enabled {
}

}

if (![ADJUserDefaults getInstallTracked]) {
double now = [NSDate.date timeIntervalSince1970];
[self trackNewSessionI:now withActivityHandler:selfI];
}
NSData *deviceToken = [ADJUserDefaults getPushTokenData];
if (deviceToken != nil && ![selfI.activityState.deviceToken isEqualToString:[ADJUtil convertDeviceToken:deviceToken]]) {
[self setDeviceToken:deviceToken];
}
NSString *pushToken = [ADJUserDefaults getPushTokenString];
if (pushToken != nil && ![selfI.activityState.deviceToken isEqualToString:pushToken]) {
[self setPushToken:pushToken];
}
if (selfI.adjustConfig.allowiAdInfoReading == YES) {
[selfI checkForiAdI:selfI];
}
Expand Down Expand Up @@ -2791,6 +2830,78 @@ - (void)updateAttStatusFromUserCallback:(int)newAttStatusFromUser {
[self.trackingStatusManager updateAttStatusFromUserCallback:newAttStatusFromUser];
}

- (void)processCoppaComplianceI:(ADJActivityHandler *)selfI {
if (!selfI.adjustConfig.coppaCompliantEnabled) {
[self resetThirdPartySharingCoppaActivityStateI:selfI];
return;
}

[self disableThirdPartySharingForCoppaEnabledI:selfI];
}

- (void)disableThirdPartySharingForCoppaEnabledI:(ADJActivityHandler *)selfI {
if (![selfI shouldDisableThirdPartySharingWhenCoppaEnabled:selfI]) {
return;
}

[ADJUtil launchSynchronisedWithObject:[ADJActivityState class]
block:^{
selfI.activityState.isThirdPartySharingDisabledForCoppa = YES;
}];
[selfI writeActivityStateI:selfI];

ADJThirdPartySharing *thirdPartySharing = [[ADJThirdPartySharing alloc] initWithIsEnabledNumberBool:[NSNumber numberWithBool:NO]];

double now = [NSDate.date timeIntervalSince1970];

// build package
ADJPackageBuilder *tpsBuilder = [[ADJPackageBuilder alloc]
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
trackingStatusManager:self.trackingStatusManager
createdAt:now];

ADJActivityPackage *dtpsPackage = [tpsBuilder buildThirdPartySharingPackage:thirdPartySharing];

[selfI.packageHandler addPackage:dtpsPackage];

if (selfI.adjustConfig.eventBufferingEnabled) {
[selfI.logger info:@"Buffered event %@", dtpsPackage.suffix];
} else {
[selfI.packageHandler sendFirstPackage];
}
}

- (void)resetThirdPartySharingCoppaActivityStateI:(ADJActivityHandler *)selfI {
if (selfI.activityState == nil) {
return;
}

if(selfI.activityState.isThirdPartySharingDisabledForCoppa) {
[ADJUtil launchSynchronisedWithObject:[ADJActivityState class]
block:^{
selfI.activityState.isThirdPartySharingDisabledForCoppa = NO;
}];
[selfI writeActivityStateI:selfI];
}
}

- (BOOL)shouldDisableThirdPartySharingWhenCoppaEnabled:(ADJActivityHandler *)selfI {
if (selfI.activityState == nil) {
return NO;
}
if (![selfI isEnabledI:selfI]) {
return NO;
}
if (selfI.activityState.isGdprForgotten) {
return NO;
}

return !selfI.activityState.isThirdPartySharingDisabledForCoppa;
}

@end

@interface ADJTrackingStatusManager ()
Expand Down Expand Up @@ -2864,4 +2975,5 @@ - (BOOL)updateAttStatus:(int)readAttStatus {

return YES;
}

@end
1 change: 1 addition & 0 deletions Adjust/ADJActivityState.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@property (nonatomic, assign) BOOL isGdprForgotten;
@property (nonatomic, assign) BOOL askingAttribution;
@property (nonatomic, assign) BOOL isThirdPartySharingDisabled;
@property (nonatomic, assign) BOOL isThirdPartySharingDisabledForCoppa;

@property (nonatomic, copy) NSString *dedupeToken;
@property (nonatomic, copy) NSString *deviceToken;
Expand Down
13 changes: 11 additions & 2 deletions Adjust/ADJActivityState.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ - (id)init {
self.isGdprForgotten = NO;
self.askingAttribution = NO;
self.isThirdPartySharingDisabled = NO;
self.isThirdPartySharingDisabledForCoppa = NO;
self.deviceToken = nil;
self.transactionIds = [NSMutableArray arrayWithCapacity:kTransactionIdCount];
self.updatePackages = NO;
Expand Down Expand Up @@ -98,11 +99,11 @@ - (void)assignRandomToken:(NSString *)randomToken {
}

- (NSString *)description {
return [NSString stringWithFormat:@"ec:%d sc:%d ssc:%d ask:%d sl:%.1f ts:%.1f la:%.1f dt:%@ gdprf:%d dtps:%d att:%d",
return [NSString stringWithFormat:@"ec:%d sc:%d ssc:%d ask:%d sl:%.1f ts:%.1f la:%.1f dt:%@ gdprf:%d dtps:%d dtpsc:%d att:%d",
self.eventCount, self.sessionCount,
self.subsessionCount, self.askingAttribution, self.sessionLength,
self.timeSpent, self.lastActivity, self.deviceToken,
self.isGdprForgotten, self.isThirdPartySharingDisabled, self.trackingManagerAuthorizationStatus];
self.isGdprForgotten, self.isThirdPartySharingDisabled, self.isThirdPartySharingDisabledForCoppa, self.trackingManagerAuthorizationStatus];
}

#pragma mark - NSCoding protocol methods
Expand Down Expand Up @@ -158,6 +159,12 @@ - (id)initWithCoder:(NSCoder *)decoder {
} else {
self.isThirdPartySharingDisabled = NO;
}

if ([decoder containsValueForKey:@"isThirdPartySharingDisabledForCoppa"]) {
self.isThirdPartySharingDisabledForCoppa = [decoder decodeBoolForKey:@"isThirdPartySharingDisabledForCoppa"];
} else {
self.isThirdPartySharingDisabledForCoppa = NO;
}

if ([decoder containsValueForKey:@"deviceToken"]) {
self.deviceToken = [decoder decodeObjectForKey:@"deviceToken"];
Expand Down Expand Up @@ -202,6 +209,7 @@ - (void)encodeWithCoder:(NSCoder *)encoder {
[encoder encodeBool:self.isGdprForgotten forKey:@"isGdprForgotten"];
[encoder encodeBool:self.askingAttribution forKey:@"askingAttribution"];
[encoder encodeBool:self.isThirdPartySharingDisabled forKey:@"isThirdPartySharingDisabled"];
[encoder encodeBool:self.isThirdPartySharingDisabledForCoppa forKey:@"isThirdPartySharingDisabledForCoppa"];
[encoder encodeObject:self.deviceToken forKey:@"deviceToken"];
[encoder encodeBool:self.updatePackages forKey:@"updatePackages"];
[encoder encodeObject:self.adid forKey:@"adid"];
Expand Down Expand Up @@ -229,6 +237,7 @@ - (id)copyWithZone:(NSZone *)zone {
copy.lastActivity = self.lastActivity;
copy.askingAttribution = self.askingAttribution;
copy.isThirdPartySharingDisabled = self.isThirdPartySharingDisabled;
copy.isThirdPartySharingDisabledForCoppa = self.isThirdPartySharingDisabledForCoppa;
copy.deviceToken = [self.deviceToken copyWithZone:zone];
copy.updatePackages = self.updatePackages;
copy.trackingManagerAuthorizationStatus = self.trackingManagerAuthorizationStatus;
Expand Down
7 changes: 6 additions & 1 deletion Adjust/ADJConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,14 @@

/**
* @brief Check if adjust configuration object is valid.
*
*
* @return Boolean indicating whether adjust config object is valid or not.
*/
- (BOOL)isValid;

/**
* @brief Enable COPPA (Children's Online Privacy Protection Act) compliant for the application.
*/
@property (nonatomic, assign) BOOL coppaCompliantEnabled;

@end
2 changes: 2 additions & 0 deletions Adjust/ADJConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ - (id)initWithAppToken:(NSString *)appToken
// default values
self.sendInBackground = NO;
self.eventBufferingEnabled = NO;
self.coppaCompliantEnabled = NO;
self.allowIdfaReading = YES;
self.allowiAdInfoReading = YES;
self.allowAdServicesInfoReading = YES;
Expand Down Expand Up @@ -203,6 +204,7 @@ - (id)copyWithZone:(NSZone *)zone {
copy.allowiAdInfoReading = self.allowiAdInfoReading;
copy.allowAdServicesInfoReading = self.allowAdServicesInfoReading;
copy.delayStart = self.delayStart;
copy.coppaCompliantEnabled = self.coppaCompliantEnabled;
copy.userAgent = [self.userAgent copyWithZone:zone];
copy.externalDeviceId = [self.externalDeviceId copyWithZone:zone];
copy.isDeviceKnown = self.isDeviceKnown;
Expand Down
Loading

0 comments on commit 334c261

Please sign in to comment.