Skip to content

Commit

Permalink
Merge pull request #255 from adjust/v4103
Browse files Browse the repository at this point in the history
Version 4.10.3
  • Loading branch information
uerceg authored Nov 18, 2016
2 parents ca0f26c + 5db3d3d commit ec223b6
Show file tree
Hide file tree
Showing 65 changed files with 421 additions and 299 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.10.2"
s.version = "4.10.3"
s.summary = "This is the iOS SDK of adjust. You can read more about it at http://adjust.com."
s.homepage = "http://adjust.com"
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
s.author = { "Christian Wellenbrock" => "[email protected]" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.10.2" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.10.3" }
s.ios.deployment_target = '6.0'
s.tvos.deployment_target = '9.0'
s.framework = 'SystemConfiguration'
Expand Down
8 changes: 6 additions & 2 deletions Adjust/ADJActivityHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
@property (nonatomic, assign) BOOL background;
@property (nonatomic, assign) BOOL delayStart;
@property (nonatomic, assign) BOOL updatePackages;
@property (nonatomic, copy) NSData* deviceToken;

- (id)init;

- (BOOL)isEnabled;
Expand All @@ -33,7 +35,8 @@
@protocol ADJActivityHandler <NSObject>

- (id)initWithConfig:(ADJConfig *)adjustConfig
sessionParametersActionsArray:(NSArray*)sessionParametersActionsArray;
sessionParametersActionsArray:(NSArray*)sessionParametersActionsArray
deviceToken:(NSData*)deviceToken;

- (void)applicationDidBecomeActive;
- (void)applicationWillResignActive;
Expand Down Expand Up @@ -78,7 +81,8 @@ sessionParametersActionsArray:(NSArray*)sessionParametersActionsArray;
@interface ADJActivityHandler : NSObject <ADJActivityHandler>

+ (id<ADJActivityHandler>)handlerWithConfig:(ADJConfig *)adjustConfig
sessionParametersActionsArray:(NSArray*)sessionParametersActionsArray;
sessionParametersActionsArray:(NSArray*)sessionParametersActionsArray
deviceToken:(NSData*)deviceToken;
- (ADJAttribution*) attribution;

- (void)addSessionCallbackParameterI:(ADJActivityHandler *)selfI
Expand Down
28 changes: 11 additions & 17 deletions Adjust/ADJActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,16 @@ @implementation ADJActivityHandler

+ (id<ADJActivityHandler>)handlerWithConfig:(ADJConfig *)adjustConfig
sessionParametersActionsArray:(NSArray*)sessionParametersActionsArray
deviceToken:(NSData*)deviceToken
{
return [[ADJActivityHandler alloc] initWithConfig:adjustConfig
sessionParametersActionsArray:sessionParametersActionsArray];
sessionParametersActionsArray:sessionParametersActionsArray
deviceToken:deviceToken];
}

- (id)initWithConfig:(ADJConfig *)adjustConfig
sessionParametersActionsArray:(NSArray*)sessionParametersActionsArray
deviceToken:(NSData*)deviceToken
{
self = [super init];
if (self == nil) return nil;
Expand Down Expand Up @@ -153,6 +156,7 @@ - (id)initWithConfig:(ADJConfig *)adjustConfig
} else {
self.internalState.updatePackages = self.activityState.updatePackages;
}
self.internalState.deviceToken = deviceToken;

self.internalQueue = dispatch_queue_create(kInternalQueueName, DISPATCH_QUEUE_SERIAL);
[ADJUtil launchInQueue:self.internalQueue
Expand Down Expand Up @@ -638,8 +642,7 @@ - (void)initI:(ADJActivityHandler *)selfI
selfI.attributionHandler = [ADJAdjustFactory attributionHandlerForActivityHandler:selfI
withAttributionPackage:attributionPackage
startsSending:[selfI toSendI:selfI
sdkClickHandlerOnly:NO]
hasAttributionChangedDelegate:selfI.adjustConfig.hasAttributionChangedDelegate];
sdkClickHandlerOnly:NO]];

selfI.sdkClickHandler = [ADJAdjustFactory sdkClickHandlerWithStartsPaused:[selfI toSendI:selfI
sdkClickHandlerOnly:YES]];
Expand Down Expand Up @@ -672,6 +675,7 @@ - (void)processSessionI:(ADJActivityHandler *)selfI {
if (selfI.activityState == nil) {
selfI.activityState = [[ADJActivityState alloc] init];
selfI.activityState.sessionCount = 1; // this is the first session
selfI.activityState.deviceToken = [ADJUtil convertDeviceToken:self.internalState.deviceToken];

[selfI transferSessionPackageI:selfI now:now];
[selfI.activityState resetSessionAttributes:now];
Expand Down Expand Up @@ -903,10 +907,6 @@ - (BOOL)updateAttributionI:(ADJActivityHandler *)selfI
return NO;
}

if (![selfI.adjustConfig hasAttributionChangedDelegate]) {
return NO;
}

if (![selfI.adjustDelegate respondsToSelector:@selector(adjustAttributionChanged:)]) {
return NO;
}
Expand Down Expand Up @@ -1008,13 +1008,7 @@ - (BOOL)trySetAttributionDeeplink:(ADJAttribution *)deeplinkAttribution

- (void)setDeviceTokenI:(ADJActivityHandler *)selfI
deviceToken:(NSData *)deviceToken {
if (deviceToken == nil) {
return;
}

NSString *deviceTokenString = [deviceToken.description stringByTrimmingCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
deviceTokenString = [deviceTokenString stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *deviceTokenString = [ADJUtil convertDeviceToken:deviceToken];

if (deviceTokenString == nil) {
return;
Expand All @@ -1025,15 +1019,15 @@ - (void)setDeviceTokenI:(ADJActivityHandler *)selfI
}

double now = [NSDate.date timeIntervalSince1970];
ADJPackageBuilder * clickBuilder = [[ADJPackageBuilder alloc]
ADJPackageBuilder * infoBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:selfI.deviceInfo
activityState:selfI.activityState
config:selfI.adjustConfig
createdAt:now];

clickBuilder.deviceToken = deviceTokenString;
infoBuilder.deviceToken = deviceTokenString;

ADJActivityPackage * clickPackage = [clickBuilder buildClickPackage:@"push"];
ADJActivityPackage * clickPackage = [infoBuilder buildInfoPackage:@"push"];

[selfI.sdkClickHandler sendSdkClick:clickPackage];

Expand Down
1 change: 1 addition & 0 deletions Adjust/ADJActivityKind.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ typedef NS_ENUM(int, ADJActivityKind) {
// ADJActivityKindRevenue = 3,
ADJActivityKindClick = 4,
ADJActivityKindAttribution = 5,
ADJActivityKindInfo = 6,
};

@interface ADJActivityKindUtil : NSObject
Expand Down
6 changes: 3 additions & 3 deletions Adjust/ADJAdjustFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
startsSending:(BOOL)startsSending;
+ (id<ADJRequestHandler>)requestHandlerForPackageHandler:(id<ADJPackageHandler>)packageHandler;
+ (id<ADJActivityHandler>)activityHandlerWithConfig:(ADJConfig *)adjustConfig
sessionParametersActionsArray:(NSArray*)sessionParametersActionsArray;
sessionParametersActionsArray:(NSArray*)sessionParametersActionsArray
deviceToken:(NSData*)deviceToken;
+ (id<ADJSdkClickHandler>)sdkClickHandlerWithStartsPaused:(BOOL)startsSending;

+ (id<ADJLogger>)logger;
Expand All @@ -35,8 +36,7 @@

+ (id<ADJAttributionHandler>)attributionHandlerForActivityHandler:(id<ADJActivityHandler>)activityHandler
withAttributionPackage:(ADJActivityPackage *) attributionPackage
startsSending:(BOOL)startsSending
hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate;
startsSending:(BOOL)startsSending;
+ (BOOL)testing;
+ (NSTimeInterval)maxDelayStart;

Expand Down
15 changes: 8 additions & 7 deletions Adjust/ADJAdjustFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ @implementation ADJAdjustFactory

+ (id<ADJActivityHandler>)activityHandlerWithConfig:(ADJConfig *)adjustConfig
sessionParametersActionsArray:(NSArray*)sessionParametersActionsArray
deviceToken:(NSData*)deviceToken
{
if (internalActivityHandler == nil) {
return [ADJActivityHandler handlerWithConfig:adjustConfig
sessionParametersActionsArray:sessionParametersActionsArray];
sessionParametersActionsArray:sessionParametersActionsArray
deviceToken:deviceToken
];
}
return [internalActivityHandler initWithConfig:adjustConfig
sessionParametersActionsArray:sessionParametersActionsArray];
sessionParametersActionsArray:sessionParametersActionsArray
deviceToken:deviceToken];
}

+ (id<ADJLogger>)logger {
Expand Down Expand Up @@ -106,19 +110,16 @@ + (ADJBackoffStrategy *)sdkClickHandlerBackoffStrategy {
+ (id<ADJAttributionHandler>)attributionHandlerForActivityHandler:(id<ADJActivityHandler>)activityHandler
withAttributionPackage:(ADJActivityPackage *) attributionPackage
startsSending:(BOOL)startsSending
hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate
{
if (internalAttributionHandler == nil) {
return [ADJAttributionHandler handlerWithActivityHandler:activityHandler
withAttributionPackage:attributionPackage
startsSending:startsSending
hasAttributionChangedDelegate:hasAttributionChangedDelegate];
startsSending:startsSending];
}

return [internalAttributionHandler initWithActivityHandler:activityHandler
withAttributionPackage:attributionPackage
startsSending:startsSending
hasAttributionChangedDelegate:hasAttributionChangedDelegate];
startsSending:startsSending];
}

+ (id<ADJSdkClickHandler>)sdkClickHandlerWithStartsPaused:(BOOL)startsSending
Expand Down
6 changes: 2 additions & 4 deletions Adjust/ADJAttributionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

- (id)initWithActivityHandler:(id<ADJActivityHandler>) activityHandler
withAttributionPackage:(ADJActivityPackage *) attributionPackage
startsSending:(BOOL)startsSending
hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate;
startsSending:(BOOL)startsSending;

- (void)checkSessionResponse:(ADJSessionResponseData *)sessionResponseData;

Expand All @@ -35,7 +34,6 @@ hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate;

+ (id<ADJAttributionHandler>)handlerWithActivityHandler:(id<ADJActivityHandler>)activityHandler
withAttributionPackage:(ADJActivityPackage *) attributionPackage
startsSending:(BOOL)startsSending
hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate;
startsSending:(BOOL)startsSending;

@end
14 changes: 3 additions & 11 deletions Adjust/ADJAttributionHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ @interface ADJAttributionHandler()
@property (nonatomic, strong) ADJTimerOnce *attributionTimer;
@property (nonatomic, strong) ADJActivityPackage * attributionPackage;
@property (nonatomic, assign) BOOL paused;
@property (nonatomic, assign) BOOL hasNeedsResponseDelegate;

@end

Expand All @@ -34,19 +33,16 @@ @implementation ADJAttributionHandler

+ (id<ADJAttributionHandler>)handlerWithActivityHandler:(id<ADJActivityHandler>)activityHandler
withAttributionPackage:(ADJActivityPackage *) attributionPackage
startsSending:(BOOL)startsSending
hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate;
startsSending:(BOOL)startsSending;
{
return [[ADJAttributionHandler alloc] initWithActivityHandler:activityHandler
withAttributionPackage:attributionPackage
startsSending:startsSending
hasAttributionChangedDelegate:hasAttributionChangedDelegate];
startsSending:startsSending];
}

- (id)initWithActivityHandler:(id<ADJActivityHandler>) activityHandler
withAttributionPackage:(ADJActivityPackage *) attributionPackage
startsSending:(BOOL)startsSending
hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate;
startsSending:(BOOL)startsSending;
{
self = [super init];
if (self == nil) return nil;
Expand All @@ -56,7 +52,6 @@ - (id)initWithActivityHandler:(id<ADJActivityHandler>) activityHandler
self.logger = ADJAdjustFactory.logger;
self.attributionPackage = attributionPackage;
self.paused = !startsSending;
self.hasNeedsResponseDelegate = hasAttributionChangedDelegate;
__weak __typeof__(self) weakSelf = self;
self.attributionTimer = [ADJTimerOnce timerWithBlock:^{
__typeof__(self) strongSelf = weakSelf;
Expand Down Expand Up @@ -167,9 +162,6 @@ - (void)checkDeeplinkI:(ADJAttributionHandler*)selfI
}

- (void)requestAttributionI:(ADJAttributionHandler*)selfI {
if (!selfI.hasNeedsResponseDelegate) {
return;
}
if (selfI.paused) {
[selfI.logger debug:@"Attribution handler is paused"];
return;
Expand Down
1 change: 0 additions & 1 deletion Adjust/ADJConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
@property (nonatomic, copy) NSString *userAgent;

@property (nonatomic, assign, readonly) BOOL hasResponseDelegate;
@property (nonatomic, assign, readonly) BOOL hasAttributionChangedDelegate;

- (BOOL) isValid;
@end
4 changes: 0 additions & 4 deletions Adjust/ADJConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ - (id)initWithAppToken:(NSString *)appToken
_environment = environment;
// default values
_hasResponseDelegate = NO;
_hasAttributionChangedDelegate = NO;
self.eventBufferingEnabled = NO;

return self;
Expand Down Expand Up @@ -92,7 +91,6 @@ - (void)setLogLevel:(ADJLogLevel)logLevel

- (void)setDelegate:(NSObject<AdjustDelegate> *)delegate {
_hasResponseDelegate = NO;
_hasAttributionChangedDelegate = NO;
BOOL implementsDeeplinkCallback = NO;

if ([ADJUtil isNull:delegate]) {
Expand All @@ -105,7 +103,6 @@ - (void)setDelegate:(NSObject<AdjustDelegate> *)delegate {
[self.logger debug:@"Delegate implements adjustAttributionChanged:"];

_hasResponseDelegate = YES;
_hasAttributionChangedDelegate = YES;
}

if ([delegate respondsToSelector:@selector(adjustEventTrackingSucceeded:)]) {
Expand Down Expand Up @@ -192,7 +189,6 @@ -(id)copyWithZone:(NSZone *)zone
copy.defaultTracker = [self.defaultTracker copyWithZone:zone];
copy.eventBufferingEnabled = self.eventBufferingEnabled;
copy->_hasResponseDelegate = self.hasResponseDelegate;
copy->_hasAttributionChangedDelegate = self.hasAttributionChangedDelegate;
copy.sendInBackground = self.sendInBackground;
copy.delayStart = self.delayStart;
copy.userAgent = [self.userAgent copyWithZone:zone];
Expand Down
1 change: 1 addition & 0 deletions Adjust/ADJDeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
@property (nonatomic, copy) NSString *machineModel;
@property (nonatomic, copy) NSString *cpuSubtype;
@property (nonatomic, copy) NSString *installReceiptBase64;
@property (nonatomic, copy) NSString *osBuild;

- (id)initWithSdkPrefix:(NSString *)sdkPrefix;
+ (ADJDeviceInfo *)deviceInfoWithSdkPrefix:(NSString *)sdkPrefix;
Expand Down
1 change: 1 addition & 0 deletions Adjust/ADJDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ - (id)initWithSdkPrefix:(NSString *)sdkPrefix {
self.systemVersion = device.systemVersion;
self.machineModel = [ADJSystemProfile machineModel];
self.cpuSubtype = [ADJSystemProfile cpuSubtype];
self.osBuild = [ADJSystemProfile osVersion];

if (sdkPrefix == nil) {
self.clientSdk = ADJUtil.clientSdk;
Expand Down
1 change: 1 addition & 0 deletions Adjust/ADJPackageBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
sessionParameters:(ADJSessionParameters *)sessionParameters
isInDelay:(BOOL)isInDelay;
- (ADJActivityPackage *)buildClickPackage:(NSString *)clickSource;
- (ADJActivityPackage *)buildInfoPackage:(NSString *)infoSource;

+ (void)parameters:(NSMutableDictionary *)parameters setDictionary:(NSDictionary *)dictionary forKey:(NSString *)key;
+ (void)parameters:(NSMutableDictionary *)parameters setString:(NSString *)value forKey:(NSString *)key;
Expand Down
21 changes: 18 additions & 3 deletions Adjust/ADJPackageBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ - (ADJActivityPackage *)buildClickPackage:(NSString *)clickSource {
}
[ADJPackageBuilder parameters:parameters setDictionary:self.iadDetails forKey:@"details"];
[ADJPackageBuilder parameters:parameters setString:self.deeplink forKey:@"deeplink"];
[ADJPackageBuilder parameters:parameters setString:self.deviceToken forKey:@"push_token"];

ADJActivityPackage *clickPackage = [self defaultActivityPackage];
clickPackage.path = @"/sdk_click";
Expand All @@ -136,6 +135,22 @@ - (ADJActivityPackage *)buildClickPackage:(NSString *)clickSource {
return clickPackage;
}

- (ADJActivityPackage *)buildInfoPackage:(NSString *)infoSource {
NSMutableDictionary *parameters = [self idsParameters];

[ADJPackageBuilder parameters:parameters setString:infoSource forKey:@"source"];

[ADJPackageBuilder parameters:parameters setString:self.deviceToken forKey:@"push_token"];

ADJActivityPackage *infoPackage = [self defaultActivityPackage];
infoPackage.path = @"/sdk_info";
infoPackage.activityKind = ADJActivityKindInfo;
infoPackage.suffix = @"";
infoPackage.parameters = parameters;

return infoPackage;
}

- (ADJActivityPackage *)buildAttributionPackage {
NSMutableDictionary *parameters = [self idsParameters];

Expand Down Expand Up @@ -208,6 +223,7 @@ - (void) injectDeviceInfo:(ADJDeviceInfo *)deviceInfo
[ADJPackageBuilder parameters:parameters setString:deviceInfo.machineModel forKey:@"hardware_name"];
[ADJPackageBuilder parameters:parameters setString:deviceInfo.cpuSubtype forKey:@"cpu_type"];
[ADJPackageBuilder parameters:parameters setString:deviceInfo.installReceiptBase64 forKey:@"install_receipt"];
[ADJPackageBuilder parameters:parameters setString:deviceInfo.osBuild forKey:@"os_build"];
}

- (void)injectConfig:(ADJConfig*) adjustConfig
Expand All @@ -225,7 +241,7 @@ - (void) injectActivityState:(ADJActivityState *)activityState
[ADJPackageBuilder parameters:parameters setInt:activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setDuration:activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:activityState.uuid forKey:@"ios_uuid"];
[ADJPackageBuilder parameters:parameters setString:activityState.deviceToken forKey:@"push_token"];

// Check if UUID was persisted or not.
// If yes, assign it to persistent_ios_uuid parameter.
Expand All @@ -235,7 +251,6 @@ - (void) injectActivityState:(ADJActivityState *)activityState
} else {
[ADJPackageBuilder parameters:parameters setString:activityState.uuid forKey:@"ios_uuid"];
}

}

- (NSString *)eventSuffix:(ADJEvent *)event {
Expand Down
Loading

0 comments on commit ec223b6

Please sign in to comment.