Skip to content

Commit

Permalink
Merge pull request #534 from adjust/v4290
Browse files Browse the repository at this point in the history
Version 4.29.0
  • Loading branch information
uerceg authored Apr 27, 2021
2 parents 8790a53 + e9a645b commit a01d2e0
Show file tree
Hide file tree
Showing 71 changed files with 2,361 additions and 3,341 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.28.0"
s.version = "4.29.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 = { "Christian Wellenbrock" => "welle@adjust.com" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.28.0" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.29.0" }
s.ios.deployment_target = '6.0'
s.tvos.deployment_target = '9.0'
s.framework = 'SystemConfiguration'
Expand Down
282 changes: 120 additions & 162 deletions Adjust.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Adjust/ADJActivityHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "Adjust.h"
#import "ADJResponseData.h"
#import "ADJActivityState.h"
#import "ADJDeviceInfo.h"
#import "ADJPackageParams.h"
#import "ADJSessionParameters.h"
#import "ADJThirdPartySharing.h"

Expand Down Expand Up @@ -110,8 +110,9 @@
- (void)trackMeasurementConsent:(BOOL)enabled;
- (void)trackSubscription:(ADJSubscription * _Nullable)subscription;
- (void)updateAttStatusFromUserCallback:(int)newAttStatusFromUser;
- (void)trackAdRevenue:(ADJAdRevenue * _Nullable)adRevenue;

- (ADJDeviceInfo * _Nullable)deviceInfo;
- (ADJPackageParams * _Nullable)packageParams;
- (ADJActivityState * _Nullable)activityState;
- (ADJConfig * _Nullable)adjustConfig;
- (ADJSessionParameters * _Nullable)sessionParameters;
Expand Down
122 changes: 90 additions & 32 deletions Adjust/ADJActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2013 adjust GmbH. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "ADJActivityPackage.h"
#import "ADJActivityHandler.h"
#import "ADJPackageBuilder.h"
Expand All @@ -14,7 +16,6 @@
#import "ADJTimerCycle.h"
#import "ADJTimerOnce.h"
#import "ADJUtil.h"
#import "UIDevice+ADJAdditions.h"
#import "ADJAdjustFactory.h"
#import "ADJAttributionHandler.h"
#import "NSString+ADJAdditions.h"
Expand Down Expand Up @@ -87,7 +88,7 @@ @interface ADJActivityHandler()
@property (nonatomic, assign) NSInteger iAdRetriesLeft;
@property (nonatomic, assign) NSInteger adServicesRetriesLeft;
@property (nonatomic, strong) ADJInternalState *internalState;
@property (nonatomic, strong) ADJDeviceInfo *deviceInfo;
@property (nonatomic, strong) ADJPackageParams *packageParams;
@property (nonatomic, strong) ADJTimerOnce *delayStartTimer;
@property (nonatomic, strong) ADJSessionParameters *sessionParameters;
// weak for object that Activity Handler does not "own"
Expand Down Expand Up @@ -562,7 +563,7 @@ - (void)sendIad3ClickPackage:(ADJActivityHandler *)selfI
}];
}
ADJPackageBuilder *clickBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:self.sessionParameters
Expand Down Expand Up @@ -597,7 +598,7 @@ - (void)sendAdServicesClickPackage:(ADJActivityHandler *)selfI
}];
}
ADJPackageBuilder *clickBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:self.sessionParameters
Expand Down Expand Up @@ -760,6 +761,14 @@ - (void)trackMeasurementConsent:(BOOL)enabled {
}];
}

- (void)trackAdRevenue:(ADJAdRevenue *)adRevenue {
[ADJUtil launchInQueue:self.internalQueue
selfInject:self
block:^(ADJActivityHandler * selfI) {
[selfI trackAdRevenueI:selfI adRevenue:adRevenue];
}];
}

- (void)writeActivityState {
[ADJUtil launchInQueue:self.internalQueue
selfInject:self
Expand All @@ -779,7 +788,7 @@ - (void)trackAttStatusUpdateI:(ADJActivityHandler *)selfI {
double now = [NSDate.date timeIntervalSince1970];

ADJPackageBuilder *infoBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -845,7 +854,7 @@ - (void)teardown
self.adjustDelegate = nil;
self.adjustConfig = nil;
self.internalState = nil;
self.deviceInfo = nil;
self.packageParams = nil;
self.delayStartTimer = nil;
self.logger = nil;
}
Expand Down Expand Up @@ -888,7 +897,7 @@ - (void)initI:(ADJActivityHandler *)selfI
kForegroundTimerInterval = ADJAdjustFactory.timerInterval;
kBackgroundTimerInterval = ADJAdjustFactory.timerInterval;

selfI.deviceInfo = [ADJDeviceInfo deviceInfoWithSdkPrefix:selfI.adjustConfig.sdkPrefix];
selfI.packageParams = [ADJPackageParams packageParamsWithSdkPrefix:selfI.adjustConfig.sdkPrefix];

// read files that are accessed only in Internal sections
selfI.sessionParameters = [[ADJSessionParameters alloc] init];
Expand Down Expand Up @@ -1159,7 +1168,7 @@ - (void)trackNewSessionI:(double)now withActivityHandler:(ADJActivityHandler *)s
- (void)transferSessionPackageI:(ADJActivityHandler *)selfI
now:(double)now {
ADJPackageBuilder *sessionBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -1234,7 +1243,7 @@ - (void)eventI:(ADJActivityHandler *)selfI

// create and populate event package
ADJPackageBuilder *eventBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -1275,7 +1284,7 @@ - (void)adRevenueI:(ADJActivityHandler *)selfI

// Create and submit ad revenue package.
ADJPackageBuilder *adRevenueBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -1307,7 +1316,7 @@ - (void)trackSubscriptionI:(ADJActivityHandler *)selfI

// Create and submit ad revenue package.
ADJPackageBuilder *subscriptionBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -1352,7 +1361,7 @@ - (void)disableThirdPartySharingI:(ADJActivityHandler *)selfI {

// build package
ADJPackageBuilder *dtpsBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -1389,7 +1398,7 @@ - (BOOL)trackThirdPartySharingI:(ADJActivityHandler *)selfI

// build package
ADJPackageBuilder *tpsBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -1426,7 +1435,7 @@ - (BOOL)trackMeasurementConsentI:(ADJActivityHandler *)selfI

// build package
ADJPackageBuilder *tpsBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand All @@ -1446,6 +1455,42 @@ - (BOOL)trackMeasurementConsentI:(ADJActivityHandler *)selfI
return YES;
}

- (void)trackAdRevenueI:(ADJActivityHandler *)selfI
adRevenue:(ADJAdRevenue *)adRevenue
{
if (!selfI.activityState) {
return;
}
if (![selfI isEnabledI:selfI]) {
return;
}
if (selfI.activityState.isGdprForgotten) {
return;
}
if (![selfI checkAdRevenueI:selfI adRevenue:adRevenue]) {
return;
}

double now = [NSDate.date timeIntervalSince1970];

// Create and submit ad revenue package.
ADJPackageBuilder *adRevenueBuilder = [[ADJPackageBuilder alloc] initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
trackingStatusManager:self.trackingStatusManager
createdAt:now];

ADJActivityPackage *adRevenuePackage = [adRevenueBuilder buildAdRevenuePackage:adRevenue
isInDelay:[selfI.internalState isInDelayedStart]];
[selfI.packageHandler addPackage:adRevenuePackage];
if (selfI.adjustConfig.eventBufferingEnabled) {
[selfI.logger info:@"Buffered event %@", adRevenuePackage.suffix];
} else {
[selfI.packageHandler sendFirstPackage];
}
}

- (void)launchEventResponseTasksI:(ADJActivityHandler *)selfI
eventResponseData:(ADJEventResponseData *)eventResponseData {
[selfI updateAdidI:selfI adid:eventResponseData.adid];
Expand Down Expand Up @@ -1710,7 +1755,7 @@ - (void)setEnabledI:(ADJActivityHandler *)selfI enabled:(BOOL)enabled {
}

- (void)checkForiAdI:(ADJActivityHandler *)selfI {
[[UIDevice currentDevice] adjCheckForiAd:selfI queue:selfI.internalQueue];
[ADJUtil checkForiAd:selfI queue:selfI.internalQueue];
}

- (BOOL)shouldFetchAdServicesI:(ADJActivityHandler *)selfI {
Expand All @@ -1727,7 +1772,7 @@ - (void)checkForAdServicesAttributionI:(ADJActivityHandler *)selfI {
if ([selfI shouldFetchAdServicesI:selfI]) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *error = nil;
NSString *token = [[UIDevice currentDevice] adjFetchAdServicesAttribution:&error];
NSString *token = [ADJUtil fetchAdServicesAttribution:&error];
[selfI setAdServicesAttributionToken:token error:error];
});
}
Expand Down Expand Up @@ -1842,7 +1887,7 @@ - (void)appWillOpenUrlI:(ADJActivityHandler *)selfI
selfI.activityState.lastInterval = lastInterval;
}];
ADJPackageBuilder *clickBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -1946,7 +1991,7 @@ - (void)setDeviceTokenI:(ADJActivityHandler *)selfI
// send info package
double now = [NSDate.date timeIntervalSince1970];
ADJPackageBuilder *infoBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -1995,7 +2040,7 @@ - (void)setPushTokenI:(ADJActivityHandler *)selfI
// send info package
double now = [NSDate.date timeIntervalSince1970];
ADJPackageBuilder *infoBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -2036,7 +2081,7 @@ - (void)setGdprForgetMeI:(ADJActivityHandler *)selfI {
// Send GDPR package
double now = [NSDate.date timeIntervalSince1970];
ADJPackageBuilder *gdprBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
initWithPackageParams:selfI.packageParams
activityState:selfI.activityState
config:selfI.adjustConfig
sessionParameters:selfI.sessionParameters
Expand Down Expand Up @@ -2668,6 +2713,21 @@ - (BOOL)checkActivityStateI:(ADJActivityHandler *)selfI {
return YES;
}

- (BOOL)checkAdRevenueI:(ADJActivityHandler *)selfI
adRevenue:(ADJAdRevenue *)adRevenue {
if (adRevenue == nil) {
[selfI.logger error:@"Ad revenue missing"];
return NO;
}

if (![adRevenue isValid]) {
[selfI.logger error:@"Ad revenue not initialized correctly"];
return NO;
}

return YES;
}

- (void)registerForSKAdNetworkAttribution {
if (!self.adjustConfig.isSKAdNetworkHandlingActive) {
return;
Expand Down Expand Up @@ -2705,6 +2765,13 @@ - (void)checkConversionValue:(ADJResponseData *)responseData {
}

[ADJUtil updateSkAdNetworkConversionValue:conversionValue];

if ([self.adjustDelegate respondsToSelector:@selector(adjustConversionValueUpdated:)]) {
[self.logger debug:@"Launching conversion value updated delegate"];
[ADJUtil launchInMainThread:self.adjustDelegate
selector:@selector(adjustConversionValueUpdated:)
withObject:conversionValue];
}
}

- (void)updateAttStatusFromUserCallback:(int)newAttStatusFromUser {
Expand Down Expand Up @@ -2737,37 +2804,28 @@ - (BOOL)canGetAttStatus {
}

- (BOOL)trackingEnabled {
return UIDevice.currentDevice.adjTrackingEnabled;
return [ADJUtil trackingEnabled];
}

- (int)attStatus {
int readAttStatus = UIDevice.currentDevice.adjATTStatus;

int readAttStatus = [ADJUtil attStatus];
[self updateAttStatus:readAttStatus];

// does not need to track AttStatus update, since it will be send with package

return readAttStatus;
}

- (void)checkForNewAttStatus {
int readAttStatus = UIDevice.currentDevice.adjATTStatus;

int readAttStatus = [ADJUtil attStatus];
BOOL didUpdateAttStatus = [self updateAttStatus:readAttStatus];

if (!didUpdateAttStatus) {
return;
}

[self.activityHandler trackAttStatusUpdate];
}
- (void)updateAttStatusFromUserCallback:(int)newAttStatusFromUser {
BOOL didUpdateAttStatus = [self updateAttStatus:newAttStatusFromUser];

if (!didUpdateAttStatus) {
return;
}

[self.activityHandler trackAttStatusUpdate];
}

Expand Down
2 changes: 1 addition & 1 deletion Adjust/ADJActivityState.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@property (nonatomic, assign) BOOL askingAttribution;
@property (nonatomic, assign) BOOL isThirdPartySharingDisabled;

@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, copy) NSString *dedupeToken;
@property (nonatomic, copy) NSString *deviceToken;
@property (nonatomic, assign) BOOL updatePackages;

Expand Down
Loading

0 comments on commit a01d2e0

Please sign in to comment.