From bfd7ed9694a34469e202ee3acc2401361346608d Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 7 Dec 2015 16:44:58 +0100 Subject: [PATCH 01/33] Rename responseData --- Adjust/ADJUtil.m | 12 ++++++------ ...ection+NSURLConnectionSynchronousLoadingMocking.m | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Adjust/ADJUtil.m b/Adjust/ADJUtil.m index 8fd5b5caa..b480877bc 100644 --- a/Adjust/ADJUtil.m +++ b/Adjust/ADJUtil.m @@ -275,12 +275,12 @@ + (void)sendNSURLConnectionRequest:(NSMutableURLRequest *)request #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - NSData *responseData = [NSURLConnection sendSynchronousRequest:request + NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&responseError]; #pragma clang diagnostic pop - NSDictionary * jsonResponse = [ADJUtil completionHandler:responseData + NSDictionary * jsonResponse = [ADJUtil completionHandler:data response:(NSHTTPURLResponse *)urlResponse error:responseError prefixErrorMessage:prefixErrorMessage @@ -289,7 +289,7 @@ + (void)sendNSURLConnectionRequest:(NSMutableURLRequest *)request jsonResponseHandler(jsonResponse); } -+ (NSDictionary *)completionHandler:(NSData *)responseData ++ (NSDictionary *)completionHandler:(NSData *)data response:(NSHTTPURLResponse *)urlResponse error:(NSError *)responseError prefixErrorMessage:(NSString *)prefixErrorMessage @@ -302,19 +302,19 @@ + (NSDictionary *)completionHandler:(NSData *)responseData suffixErrorMessage:suffixErrorMessage]]; return nil; } - if ([ADJUtil isNull:responseData]) { + if ([ADJUtil isNull:data]) { [ADJAdjustFactory.logger error:[ADJUtil formatErrorMessage:prefixErrorMessage systemErrorMessage:@"empty error" suffixErrorMessage:suffixErrorMessage]]; return nil; } - NSString *responseString = [[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] adjTrim]; + NSString *responseString = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] adjTrim]; NSInteger statusCode = urlResponse.statusCode; [ADJAdjustFactory.logger verbose:@"Response: %@", responseString]; - NSDictionary *jsonDict = [ADJUtil buildJsonDict:responseData]; + NSDictionary *jsonDict = [ADJUtil buildJsonDict:data]; if ([ADJUtil isNull:jsonDict]) { return nil; diff --git a/AdjustTests/NSURLConnection+NSURLConnectionSynchronousLoadingMocking.m b/AdjustTests/NSURLConnection+NSURLConnectionSynchronousLoadingMocking.m index 673852fe0..23cc0917e 100644 --- a/AdjustTests/NSURLConnection+NSURLConnectionSynchronousLoadingMocking.m +++ b/AdjustTests/NSURLConnection+NSURLConnectionSynchronousLoadingMocking.m @@ -43,9 +43,9 @@ + (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NS // build response (*response) = [[NSHTTPURLResponse alloc] initWithURL:[[NSURL alloc] init] statusCode:statusCode HTTPVersion:@"" headerFields:nil]; - NSData *responseData = [sResponse dataUsingEncoding:NSUTF8StringEncoding]; + NSData *data = [sResponse dataUsingEncoding:NSUTF8StringEncoding]; - return responseData; + return data; /* NSInteger statusCode; @@ -73,9 +73,9 @@ + (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NS // build response (*response) = [[NSHTTPURLResponse alloc] initWithURL:[[NSURL alloc] init] statusCode:statusCode HTTPVersion:@"" headerFields:nil]; - NSData *responseData = [sResponse dataUsingEncoding:NSUTF8StringEncoding]; + NSData *data = [sResponse dataUsingEncoding:NSUTF8StringEncoding]; - return responseData; + return data; */ } From 72195ab3bf152a31dd6109629f6de7dc7a0e297f Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 9 Dec 2015 14:43:19 +0100 Subject: [PATCH 02/33] Add response data files --- Adjust.xcodeproj/project.pbxproj | 32 +++++++++++++++ Adjust/ADJResponseData.h | 22 +++++++++++ Adjust/ADJResponseData.m | 39 +++++++++++++++++++ Adjust/ADJResponseDataTasks.h | 24 ++++++++++++ Adjust/ADJResponseDataTasks.m | 24 ++++++++++++ .../project.pbxproj | 12 ++++++ .../project.pbxproj | 12 ++++++ 7 files changed, 165 insertions(+) create mode 100644 Adjust/ADJResponseData.h create mode 100644 Adjust/ADJResponseData.m create mode 100644 Adjust/ADJResponseDataTasks.h create mode 100644 Adjust/ADJResponseDataTasks.m diff --git a/Adjust.xcodeproj/project.pbxproj b/Adjust.xcodeproj/project.pbxproj index d9687a7ce..ac346f7e3 100644 --- a/Adjust.xcodeproj/project.pbxproj +++ b/Adjust.xcodeproj/project.pbxproj @@ -91,6 +91,14 @@ 96E5E3B818BBB49E008E7B30 /* NSURLConnection+NSURLConnectionSynchronousLoadingMocking.m in Sources */ = {isa = PBXBuildFile; fileRef = 96E5E3AD18BBB49E008E7B30 /* NSURLConnection+NSURLConnectionSynchronousLoadingMocking.m */; }; 96ED00391A38A4CD00209110 /* ADJAttributionHandlerMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 96ED00381A38A4CD00209110 /* ADJAttributionHandlerMock.m */; }; 96ED003E1A38A98C00209110 /* ADJDelegateTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 96ED003D1A38A98C00209110 /* ADJDelegateTest.m */; }; + 96FCC53A1C186426007BBFE1 /* ADJResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC5361C186426007BBFE1 /* ADJResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 96FCC53B1C186426007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5371C186426007BBFE1 /* ADJResponseData.m */; }; + 96FCC53C1C186426007BBFE1 /* ADJResponseDataTasks.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC5381C186426007BBFE1 /* ADJResponseDataTasks.h */; }; + 96FCC53D1C186426007BBFE1 /* ADJResponseDataTasks.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5391C186426007BBFE1 /* ADJResponseDataTasks.m */; }; + 96FCC5521C1865D3007BBFE1 /* ADJResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC54E1C1865D3007BBFE1 /* ADJResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 96FCC5531C1865D3007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC54F1C1865D3007BBFE1 /* ADJResponseData.m */; }; + 96FCC5541C1865D3007BBFE1 /* ADJResponseDataTasks.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC5501C1865D3007BBFE1 /* ADJResponseDataTasks.h */; }; + 96FCC5551C1865D3007BBFE1 /* ADJResponseDataTasks.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5511C1865D3007BBFE1 /* ADJResponseDataTasks.m */; }; 9D363AC31BDA50FA00B47FE9 /* ADJLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 96E5E37318BBB48A008E7B30 /* ADJLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9DE7C8FD1AE688DA001556E5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DE7C8FC1AE688DA001556E5 /* UIKit.framework */; }; 9DFA37B71C0F21D600782607 /* AdjustSdk.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37B51C0F21D600782607 /* AdjustSdk.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -263,6 +271,14 @@ 96ED00381A38A4CD00209110 /* ADJAttributionHandlerMock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJAttributionHandlerMock.m; sourceTree = ""; }; 96ED003C1A38A98C00209110 /* ADJDelegateTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJDelegateTest.h; sourceTree = ""; }; 96ED003D1A38A98C00209110 /* ADJDelegateTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJDelegateTest.m; sourceTree = ""; }; + 96FCC5361C186426007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseData.h; sourceTree = ""; }; + 96FCC5371C186426007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseData.m; sourceTree = ""; }; + 96FCC5381C186426007BBFE1 /* ADJResponseDataTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseDataTasks.h; sourceTree = ""; }; + 96FCC5391C186426007BBFE1 /* ADJResponseDataTasks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseDataTasks.m; sourceTree = ""; }; + 96FCC54E1C1865D3007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJResponseData.h; path = Adjust/ADJResponseData.h; sourceTree = SOURCE_ROOT; }; + 96FCC54F1C1865D3007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJResponseData.m; path = Adjust/ADJResponseData.m; sourceTree = SOURCE_ROOT; }; + 96FCC5501C1865D3007BBFE1 /* ADJResponseDataTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJResponseDataTasks.h; path = Adjust/ADJResponseDataTasks.h; sourceTree = SOURCE_ROOT; }; + 96FCC5511C1865D3007BBFE1 /* ADJResponseDataTasks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJResponseDataTasks.m; path = Adjust/ADJResponseDataTasks.m; sourceTree = SOURCE_ROOT; }; 9DE7C8FC1AE688DA001556E5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 9DFA37AD1C0F219400782607 /* AdjustSdk.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AdjustSdk.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9DFA37B51C0F21D600782607 /* AdjustSdk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdjustSdk.h; sourceTree = ""; }; @@ -452,6 +468,10 @@ 96854A581B1F2779002B2874 /* ADJTimerOnce.m */, 96854A5D1B1F278C002B2874 /* ADJTimerCycle.h */, 96854A5E1B1F278C002B2874 /* ADJTimerCycle.m */, + 96FCC5361C186426007BBFE1 /* ADJResponseData.h */, + 96FCC5371C186426007BBFE1 /* ADJResponseData.m */, + 96FCC5381C186426007BBFE1 /* ADJResponseDataTasks.h */, + 96FCC5391C186426007BBFE1 /* ADJResponseDataTasks.m */, ); path = Adjust; sourceTree = ""; @@ -548,6 +568,10 @@ 9DFA37DC1C0F220200782607 /* ADJUtil.h */, 9DFA37DD1C0F220200782607 /* ADJUtil.m */, 9DFA37DE1C0F220200782607 /* Info.plist */, + 96FCC54E1C1865D3007BBFE1 /* ADJResponseData.h */, + 96FCC54F1C1865D3007BBFE1 /* ADJResponseData.m */, + 96FCC5501C1865D3007BBFE1 /* ADJResponseDataTasks.h */, + 96FCC5511C1865D3007BBFE1 /* ADJResponseDataTasks.m */, ); name = Adjust; sourceTree = ""; @@ -560,9 +584,11 @@ buildActionMask = 2147483647; files = ( 96BCFBD21AC99332005A65C5 /* NSString+ADJAdditions.h in Headers */, + 96FCC53C1C186426007BBFE1 /* ADJResponseDataTasks.h in Headers */, 96BCFBCD1AC99231005A65C5 /* Adjust.h in Headers */, 96BCFBCE1AC99235005A65C5 /* ADJEvent.h in Headers */, 96BCFBD11AC99246005A65C5 /* ADJAttribution.h in Headers */, + 96FCC53A1C186426007BBFE1 /* ADJResponseData.h in Headers */, 9D363AC31BDA50FA00B47FE9 /* ADJLogger.h in Headers */, 96BCFBD01AC9923F005A65C5 /* ADJConfig.h in Headers */, 96BCFBD91AC9934E005A65C5 /* ADJAdjustFactory.h in Headers */, @@ -588,9 +614,11 @@ buildActionMask = 2147483647; files = ( 9DFA37B71C0F21D600782607 /* AdjustSdk.h in Headers */, + 96FCC5541C1865D3007BBFE1 /* ADJResponseDataTasks.h in Headers */, 9DFA37FF1C0F220200782607 /* Adjust.h in Headers */, 9DFA37F11C0F220200782607 /* ADJEvent.h in Headers */, 9DFA37ED1C0F220200782607 /* ADJConfig.h in Headers */, + 96FCC5521C1865D3007BBFE1 /* ADJResponseData.h in Headers */, 9DFA37F31C0F220200782607 /* ADJLogger.h in Headers */, 9DFA37E91C0F220200782607 /* ADJAttribution.h in Headers */, 9DFA38011C0F220200782607 /* ADJUtil.h in Headers */, @@ -809,10 +837,12 @@ 96E5E38118BBB48A008E7B30 /* Adjust.m in Sources */, 96E5E38B18BBB48A008E7B30 /* ADJActivityHandler.m in Sources */, 96E5E39618BBB48A008E7B30 /* ADJRequestHandler.m in Sources */, + 96FCC53B1C186426007BBFE1 /* ADJResponseData.m in Sources */, 96E5E39918BBB48A008E7B30 /* ADJUtil.m in Sources */, 96E5E38C18BBB48A008E7B30 /* ADJActivityKind.m in Sources */, 96C93DF51AC47F2E00B53F56 /* NSData+ADJAdditions.m in Sources */, 96E5E38D18BBB48A008E7B30 /* ADJActivityPackage.m in Sources */, + 96FCC53D1C186426007BBFE1 /* ADJResponseDataTasks.m in Sources */, 965307F61A000DA400107FF9 /* ADJDeviceInfo.m in Sources */, 969952D21A01309200928462 /* ADJAttribution.m in Sources */, 969952CF1A012F5300928462 /* ADJAttributionHandler.m in Sources */, @@ -862,10 +892,12 @@ 9DFA380F1C0F220D00782607 /* UIDevice+ADJAdditions.m in Sources */, 9DFA37E41C0F220200782607 /* ADJActivityPackage.m in Sources */, 9DFA37EE1C0F220200782607 /* ADJConfig.m in Sources */, + 96FCC5531C1865D3007BBFE1 /* ADJResponseData.m in Sources */, 9DFA38001C0F220200782607 /* Adjust.m in Sources */, 9DFA37F21C0F220200782607 /* ADJEvent.m in Sources */, 9DFA38021C0F220200782607 /* ADJUtil.m in Sources */, 9DFA37EC1C0F220200782607 /* ADJAttributionHandler.m in Sources */, + 96FCC5551C1865D3007BBFE1 /* ADJResponseDataTasks.m in Sources */, 9DFA37F41C0F220200782607 /* ADJLogger.m in Sources */, 9DFA37E61C0F220200782607 /* ADJActivityState.m in Sources */, 9DFA380B1C0F220D00782607 /* NSData+ADJAdditions.m in Sources */, diff --git a/Adjust/ADJResponseData.h b/Adjust/ADJResponseData.h new file mode 100644 index 000000000..60db0a5b0 --- /dev/null +++ b/Adjust/ADJResponseData.h @@ -0,0 +1,22 @@ +// +// ADJResponseData.h +// adjust +// +// Created by Pedro Filipe on 07/12/15. +// Copyright © 2015 adjust GmbH. All rights reserved. +// + +#import + +@interface ADJResponseData : NSObject + +@property (nonatomic, copy) NSString *message; + +@property (nonatomic, copy) NSString *timeStamp; + +@property (nonatomic, retain) NSDictionary *jsonResponse; + ++ (ADJResponseData *)responseData; +- (id)init; + +@end diff --git a/Adjust/ADJResponseData.m b/Adjust/ADJResponseData.m new file mode 100644 index 000000000..37da3f783 --- /dev/null +++ b/Adjust/ADJResponseData.m @@ -0,0 +1,39 @@ +// +// ADJResponseData.m +// adjust +// +// Created by Pedro Filipe on 07/12/15. +// Copyright © 2015 adjust GmbH. All rights reserved. +// + +#import "ADJResponseData.h" + +@implementation ADJResponseData + ++ (ADJResponseData *)responseData { + return [[ADJResponseData alloc] init]; +} + +- (id)init { + self = [super init]; + if (self == nil) return nil; + + return self; +} + +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone +{ + ADJResponseData* copy = [[[self class] allocWithZone:zone] init]; + + if (copy) { + copy.message = [self.message copyWithZone:zone]; + copy.timeStamp = [self.timeStamp copyWithZone:zone]; + copy.jsonResponse = [self.jsonResponse copyWithZone:zone]; + } + + return copy; +} + +@end \ No newline at end of file diff --git a/Adjust/ADJResponseDataTasks.h b/Adjust/ADJResponseDataTasks.h new file mode 100644 index 000000000..04cd1ed27 --- /dev/null +++ b/Adjust/ADJResponseDataTasks.h @@ -0,0 +1,24 @@ +// +// ADJResponseDataTasks.h +// adjust +// +// Created by Pedro Filipe on 08/12/15. +// Copyright © 2015 adjust GmbH. All rights reserved. +// + +#import +#import "ADJEvent.h" +#import "ADJAttribution.h" + +@interface ADJResponseDataTasks : NSObject + +@property (nonatomic, retain) ADJResponseData * responseData; + +@property (nonatomic, copy) ADJAttribution *attribution; + +@property (nonatomic, copy) ADJFinishActivity finishDelegate; + ++ (ADJResponseDataTasks *)responseDataTasks; +- (id)init; + +@end diff --git a/Adjust/ADJResponseDataTasks.m b/Adjust/ADJResponseDataTasks.m new file mode 100644 index 000000000..5b32eb124 --- /dev/null +++ b/Adjust/ADJResponseDataTasks.m @@ -0,0 +1,24 @@ +// +// ADJResponseDataTasks.m +// adjust +// +// Created by Pedro Filipe on 08/12/15. +// Copyright © 2015 adjust GmbH. All rights reserved. +// + +#import "ADJResponseDataTasks.h" + +@implementation ADJResponseDataTasks + ++ (ADJResponseDataTasks *)responseDataTasks { + return [[ADJResponseDataTasks alloc] init]; +} + +- (id)init { + self = [super init]; + if (self == nil) return nil; + + return self; +} + +@end diff --git a/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj b/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj index a2126a9a1..838b111ad 100644 --- a/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj +++ b/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj @@ -35,6 +35,8 @@ 963909A61BCBFF8D00A2E8A4 /* ADJTimerOnce.m in Sources */ = {isa = PBXBuildFile; fileRef = 9639098F1BCBFF8D00A2E8A4 /* ADJTimerOnce.m */; }; 963909A71BCBFF8D00A2E8A4 /* Adjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909911BCBFF8D00A2E8A4 /* Adjust.m */; }; 963909A81BCBFF8D00A2E8A4 /* ADJUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909931BCBFF8D00A2E8A4 /* ADJUtil.m */; }; + 96FCC5441C18643E007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5411C18643E007BBFE1 /* ADJResponseData.m */; }; + 96FCC5451C18643E007BBFE1 /* ADJResponseDataTasks.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5431C18643E007BBFE1 /* ADJResponseDataTasks.m */; }; 9DAC2DEB1C0F611300AC9D97 /* URLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DAC2DEA1C0F611300AC9D97 /* URLRequest.m */; }; 9DC95F261C104CEF00138E4B /* ViewControlleriOS.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F251C104CEF00138E4B /* ViewControlleriOS.m */; }; 9DC95F2A1C10515300138E4B /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F291C10515300138E4B /* Constants.m */; }; @@ -93,6 +95,10 @@ 963909911BCBFF8D00A2E8A4 /* Adjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Adjust.m; sourceTree = ""; }; 963909921BCBFF8D00A2E8A4 /* ADJUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJUtil.h; sourceTree = ""; }; 963909931BCBFF8D00A2E8A4 /* ADJUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJUtil.m; sourceTree = ""; }; + 96FCC5401C18643E007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseData.h; sourceTree = ""; }; + 96FCC5411C18643E007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseData.m; sourceTree = ""; }; + 96FCC5421C18643E007BBFE1 /* ADJResponseDataTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseDataTasks.h; sourceTree = ""; }; + 96FCC5431C18643E007BBFE1 /* ADJResponseDataTasks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseDataTasks.m; sourceTree = ""; }; 9DAC2DE91C0F611300AC9D97 /* URLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLRequest.h; sourceTree = ""; }; 9DAC2DEA1C0F611300AC9D97 /* URLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = URLRequest.m; sourceTree = ""; }; 9DC95F241C104CEF00138E4B /* ViewControlleriOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControlleriOS.h; sourceTree = ""; }; @@ -164,6 +170,10 @@ 963909681BCBFF8D00A2E8A4 /* Adjust */ = { isa = PBXGroup; children = ( + 96FCC5401C18643E007BBFE1 /* ADJResponseData.h */, + 96FCC5411C18643E007BBFE1 /* ADJResponseData.m */, + 96FCC5421C18643E007BBFE1 /* ADJResponseDataTasks.h */, + 96FCC5431C18643E007BBFE1 /* ADJResponseDataTasks.m */, 963909691BCBFF8D00A2E8A4 /* ADJActivityHandler.h */, 9639096A1BCBFF8D00A2E8A4 /* ADJActivityHandler.m */, 9639096B1BCBFF8D00A2E8A4 /* ADJActivityKind.h */, @@ -302,7 +312,9 @@ 963909971BCBFF8D00A2E8A4 /* ADJActivityState.m in Sources */, 963909A11BCBFF8D00A2E8A4 /* ADJLogger.m in Sources */, 963909961BCBFF8D00A2E8A4 /* ADJActivityPackage.m in Sources */, + 96FCC5441C18643E007BBFE1 /* ADJResponseData.m in Sources */, 963909A01BCBFF8D00A2E8A4 /* ADJEvent.m in Sources */, + 96FCC5451C18643E007BBFE1 /* ADJResponseDataTasks.m in Sources */, 963909A31BCBFF8D00A2E8A4 /* ADJPackageHandler.m in Sources */, 963909981BCBFF8D00A2E8A4 /* NSData+ADJAdditions.m in Sources */, 963909A41BCBFF8D00A2E8A4 /* ADJRequestHandler.m in Sources */, diff --git a/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj b/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj index 7581a085e..65b0aa2d2 100644 --- a/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj +++ b/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj @@ -34,6 +34,8 @@ 96390A0F1BCC0DF100A2E8A4 /* ADJTimerOnce.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909F81BCC0DF100A2E8A4 /* ADJTimerOnce.m */; }; 96390A101BCC0DF100A2E8A4 /* Adjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909FA1BCC0DF100A2E8A4 /* Adjust.m */; }; 96390A111BCC0DF100A2E8A4 /* ADJUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909FC1BCC0DF100A2E8A4 /* ADJUtil.m */; }; + 96FCC54A1C186458007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5471C186458007BBFE1 /* ADJResponseData.m */; }; + 96FCC54B1C186458007BBFE1 /* ADJResponseDataTasks.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5491C186458007BBFE1 /* ADJResponseDataTasks.m */; }; 9DC95F2F1C10596500138E4B /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F2E1C10596500138E4B /* Constants.m */; }; 9DC95F321C105B4C00138E4B /* URLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F311C105B4C00138E4B /* URLRequest.m */; }; /* End PBXBuildFile section */ @@ -91,6 +93,10 @@ 963909FA1BCC0DF100A2E8A4 /* Adjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Adjust.m; sourceTree = ""; }; 963909FB1BCC0DF100A2E8A4 /* ADJUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJUtil.h; sourceTree = ""; }; 963909FC1BCC0DF100A2E8A4 /* ADJUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJUtil.m; sourceTree = ""; }; + 96FCC5461C186458007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseData.h; sourceTree = ""; }; + 96FCC5471C186458007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseData.m; sourceTree = ""; }; + 96FCC5481C186458007BBFE1 /* ADJResponseDataTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseDataTasks.h; sourceTree = ""; }; + 96FCC5491C186458007BBFE1 /* ADJResponseDataTasks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseDataTasks.m; sourceTree = ""; }; 9DC95F2D1C10596500138E4B /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = ""; }; 9DC95F2E1C10596500138E4B /* Constants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = ""; }; 9DC95F301C105B4C00138E4B /* URLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLRequest.h; sourceTree = ""; }; @@ -157,6 +163,10 @@ 963909D11BCC0DF100A2E8A4 /* Adjust */ = { isa = PBXGroup; children = ( + 96FCC5461C186458007BBFE1 /* ADJResponseData.h */, + 96FCC5471C186458007BBFE1 /* ADJResponseData.m */, + 96FCC5481C186458007BBFE1 /* ADJResponseDataTasks.h */, + 96FCC5491C186458007BBFE1 /* ADJResponseDataTasks.m */, 963909D21BCC0DF100A2E8A4 /* ADJActivityHandler.h */, 963909D31BCC0DF100A2E8A4 /* ADJActivityHandler.m */, 963909D41BCC0DF100A2E8A4 /* ADJActivityKind.h */, @@ -294,7 +304,9 @@ 96390A0A1BCC0DF100A2E8A4 /* ADJLogger.m in Sources */, 963909FF1BCC0DF100A2E8A4 /* ADJActivityPackage.m in Sources */, 96390A091BCC0DF100A2E8A4 /* ADJEvent.m in Sources */, + 96FCC54A1C186458007BBFE1 /* ADJResponseData.m in Sources */, 963909BD1BCC0D8300A2E8A4 /* ViewControllertvOS.m in Sources */, + 96FCC54B1C186458007BBFE1 /* ADJResponseDataTasks.m in Sources */, 96390A0C1BCC0DF100A2E8A4 /* ADJPackageHandler.m in Sources */, 96390A011BCC0DF100A2E8A4 /* NSData+ADJAdditions.m in Sources */, 96390A0D1BCC0DF100A2E8A4 /* ADJRequestHandler.m in Sources */, From 37f1d1036d6377e7c25fce8d4a62962ac1359093 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 9 Dec 2015 14:54:23 +0100 Subject: [PATCH 03/33] Rename delegate to attributionChanged --- Adjust/ADJActivityHandler.m | 13 +++++++------ Adjust/ADJAdjustFactory.h | 2 +- Adjust/ADJAdjustFactory.m | 6 +++--- Adjust/ADJAttributionHandler.h | 4 ++-- Adjust/ADJAttributionHandler.m | 8 ++++---- Adjust/ADJConfig.h | 2 +- Adjust/ADJConfig.m | 10 +++++----- Adjust/ADJPackageBuilder.m | 2 +- 8 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index cec983515..cee2a7a93 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -36,7 +36,7 @@ @interface ADJActivityHandler() @property (nonatomic, retain) ADJActivityState *activityState; @property (nonatomic, retain) ADJTimerCycle *timer; @property (nonatomic, retain) id logger; -@property (nonatomic, weak) NSObject *delegate; +@property (nonatomic, weak) NSObject *attributionChangedDelegate; @property (nonatomic, copy) ADJAttribution *attribution; @property (nonatomic, copy) ADJConfig *adjustConfig; @@ -76,7 +76,7 @@ - (id)initWithConfig:(ADJConfig *)adjustConfig { } self.adjustConfig = adjustConfig; - self.delegate = adjustConfig.delegate; + self.attributionChangedDelegate = adjustConfig.delegate; self.logger = ADJAdjustFactory.logger; [self addNotificationObserver]; @@ -309,13 +309,14 @@ - (BOOL)updateAttribution:(ADJAttribution *)attribution { } - (void)launchAttributionDelegate{ - if (self.delegate == nil) { + if (self.attributionChangedDelegate == nil) { return; } - if (![self.delegate respondsToSelector:@selector(adjustAttributionChanged:)]) { + + if (![self.attributionChangedDelegate respondsToSelector:@selector(adjustAttributionChanged:)]) { return; } - [self.delegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) + [self.attributionChangedDelegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) withObject:self.attribution waitUntilDone:NO]; } @@ -364,7 +365,7 @@ - (void)initInternal { self.attributionHandler = [ADJAdjustFactory attributionHandlerForActivityHandler:self withAttributionPackage:attributionPackage startPaused:[self paused] - hasDelegate:(self.delegate != nil)]; + hasAttributionChangedDelegate:self.adjustConfig.hasAttributionChangedDelegate]; self.timer = [ADJTimerCycle timerWithBlock:^{ [self timerFiredInternal]; } queue:self.internalQueue diff --git a/Adjust/ADJAdjustFactory.h b/Adjust/ADJAdjustFactory.h index a0d6d2a6d..b5bd6d8b0 100644 --- a/Adjust/ADJAdjustFactory.h +++ b/Adjust/ADJAdjustFactory.h @@ -28,7 +28,7 @@ + (id)attributionHandlerForActivityHandler:(id)activityHandler withAttributionPackage:(ADJActivityPackage *) attributionPackage startPaused:(BOOL)startPaused - hasDelegate:(BOOL)hasDelegate; + hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate; + (void)setPackageHandler:(id)packageHandler; + (void)setRequestHandler:(id)requestHandler; diff --git a/Adjust/ADJAdjustFactory.m b/Adjust/ADJAdjustFactory.m index 6ef021666..cc6d76aab 100644 --- a/Adjust/ADJAdjustFactory.m +++ b/Adjust/ADJAdjustFactory.m @@ -84,19 +84,19 @@ + (NSTimeInterval)timerStart { + (id)attributionHandlerForActivityHandler:(id)activityHandler withAttributionPackage:(ADJActivityPackage *) attributionPackage startPaused:(BOOL)startPaused - hasDelegate:(BOOL)hasDelegate + hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate { if (internalAttributionHandler == nil) { return [ADJAttributionHandler handlerWithActivityHandler:activityHandler withAttributionPackage:attributionPackage startPaused:startPaused - hasDelegate:hasDelegate]; + hasAttributionChangedDelegate:hasAttributionChangedDelegate]; } return [internalAttributionHandler initWithActivityHandler:activityHandler withAttributionPackage:attributionPackage startPaused:startPaused - hasDelegate:hasDelegate]; + hasAttributionChangedDelegate:hasAttributionChangedDelegate]; } + (void)setPackageHandler:(id)packageHandler { diff --git a/Adjust/ADJAttributionHandler.h b/Adjust/ADJAttributionHandler.h index 712209a71..5e2f45409 100644 --- a/Adjust/ADJAttributionHandler.h +++ b/Adjust/ADJAttributionHandler.h @@ -15,7 +15,7 @@ - (id)initWithActivityHandler:(id) activityHandler withAttributionPackage:(ADJActivityPackage *) attributionPackage startPaused:(BOOL)startPaused - hasDelegate:(BOOL)hasDelegate; +hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate; - (void)checkAttribution:(NSDictionary *)jsonDict; @@ -32,6 +32,6 @@ + (id)handlerWithActivityHandler:(id)activityHandler withAttributionPackage:(ADJActivityPackage *) attributionPackage startPaused:(BOOL)startPaused - hasDelegate:(BOOL)hasDelegate; + hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate; @end diff --git a/Adjust/ADJAttributionHandler.m b/Adjust/ADJAttributionHandler.m index e57c8315a..3899d65c0 100644 --- a/Adjust/ADJAttributionHandler.m +++ b/Adjust/ADJAttributionHandler.m @@ -34,18 +34,18 @@ @implementation ADJAttributionHandler + (id)handlerWithActivityHandler:(id)activityHandler withAttributionPackage:(ADJActivityPackage *) attributionPackage startPaused:(BOOL)startPaused - hasDelegate:(BOOL)hasDelegate; + hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate; { return [[ADJAttributionHandler alloc] initWithActivityHandler:activityHandler withAttributionPackage:attributionPackage startPaused:startPaused - hasDelegate:hasDelegate]; + hasAttributionChangedDelegate:hasAttributionChangedDelegate]; } - (id)initWithActivityHandler:(id) activityHandler withAttributionPackage:(ADJActivityPackage *) attributionPackage startPaused:(BOOL)startPaused - hasDelegate:(BOOL)hasDelegate; +hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate; { self = [super init]; if (self == nil) return nil; @@ -55,7 +55,7 @@ - (id)initWithActivityHandler:(id) activityHandler self.logger = ADJAdjustFactory.logger; self.attributionPackage = attributionPackage; self.paused = startPaused; - self.hasDelegate = hasDelegate; + self.hasDelegate = hasAttributionChangedDelegate; self.timer = [ADJTimerOnce timerWithBlock:^{ [self getAttributionInternal]; } queue:self.internalQueue]; diff --git a/Adjust/ADJConfig.h b/Adjust/ADJConfig.h index ff5d71dfb..245080306 100644 --- a/Adjust/ADJConfig.h +++ b/Adjust/ADJConfig.h @@ -81,7 +81,7 @@ * methods like adjustAttributionChanged: */ @property (nonatomic, weak) NSObject *delegate; -@property (nonatomic, assign) BOOL hasDelegate; +@property (nonatomic, assign) BOOL hasAttributionChangedDelegate; - (BOOL) isValid; @end diff --git a/Adjust/ADJConfig.m b/Adjust/ADJConfig.m index b52f02718..5a9bc6397 100644 --- a/Adjust/ADJConfig.m +++ b/Adjust/ADJConfig.m @@ -43,7 +43,7 @@ - (id) initSelfWithAppToken:(NSString *)appToken // default values self.logLevel = ADJLogLevelInfo; - self.hasDelegate = NO; + self.hasAttributionChangedDelegate = NO; self.eventBufferingEnabled = NO; return self; @@ -52,7 +52,7 @@ - (id) initSelfWithAppToken:(NSString *)appToken - (void) setDelegate:(NSObject *)delegate { if ([ADJUtil isNull:delegate]) { _delegate = nil; - self.hasDelegate = NO; + self.hasAttributionChangedDelegate = NO; return; } @@ -61,12 +61,12 @@ - (void) setDelegate:(NSObject *)delegate { [logger error:@"Delegate does not implement AdjustDelegate"]; _delegate = nil; - self.hasDelegate = NO; + self.hasAttributionChangedDelegate = NO; return; } _delegate = delegate; - self.hasDelegate = YES; + self.hasAttributionChangedDelegate = YES; } - (BOOL) checkEnvironment:(NSString *)environment @@ -113,7 +113,7 @@ -(id)copyWithZone:(NSZone *)zone copy.sdkPrefix = [self.sdkPrefix copyWithZone:zone]; copy.defaultTracker = [self.defaultTracker copyWithZone:zone]; copy.eventBufferingEnabled = self.eventBufferingEnabled; - copy.hasDelegate = self.hasDelegate; + copy.hasAttributionChangedDelegate = self.hasAttributionChangedDelegate; // adjust delegate not copied } diff --git a/Adjust/ADJPackageBuilder.m b/Adjust/ADJPackageBuilder.m index 1abc9cd52..5f9ee3c95 100644 --- a/Adjust/ADJPackageBuilder.m +++ b/Adjust/ADJPackageBuilder.m @@ -183,7 +183,7 @@ - (void)injectConfig:(ADJConfig*) adjustConfig { [self parameters:parameters setString:adjustConfig.appToken forKey:@"app_token"]; [self parameters:parameters setString:adjustConfig.environment forKey:@"environment"]; - [self parameters:parameters setBool:adjustConfig.hasDelegate forKey:@"needs_attribution_data"]; + [self parameters:parameters setBool:adjustConfig.hasAttributionChangedDelegate forKey:@"needs_attribution_data"]; } - (void) injectActivityState:(ADJActivityState *)activityState From fc29006b6ca4ccdff8bffda8a122516311f3dd5e Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 9 Dec 2015 15:28:36 +0100 Subject: [PATCH 04/33] Response delegate --- Adjust/ADJActivityHandler.h | 9 ++- Adjust/ADJActivityHandler.m | 66 ++++++++++++++------ Adjust/ADJActivityPackage.h | 5 ++ Adjust/ADJAttributionHandler.h | 2 +- Adjust/ADJAttributionHandler.m | 44 ++++++++------ Adjust/ADJEvent.h | 8 +++ Adjust/ADJEvent.m | 8 +++ Adjust/ADJPackageBuilder.m | 2 + Adjust/ADJPackageHandler.h | 4 +- Adjust/ADJPackageHandler.m | 8 +-- Adjust/ADJRequestHandler.m | 8 +-- Adjust/ADJResponseData.m | 5 ++ Adjust/ADJResponseDataTasks.h | 3 +- Adjust/ADJUtil.h | 12 +++- Adjust/ADJUtil.m | 107 +++++++++++++++++++++------------ AdjustSdk/AdjustSdk.h | 1 + 16 files changed, 198 insertions(+), 94 deletions(-) diff --git a/Adjust/ADJActivityHandler.h b/Adjust/ADJActivityHandler.h index d89215690..ffa9a8b93 100644 --- a/Adjust/ADJActivityHandler.h +++ b/Adjust/ADJActivityHandler.h @@ -7,7 +7,7 @@ // #import "Adjust.h" -#import "ADJAttribution.h" +#import "ADJResponseDataTasks.h" @protocol ADJActivityHandler @@ -18,7 +18,8 @@ - (void)trackEvent:(ADJEvent *)event; -- (void)finishedTracking:(NSDictionary *)jsonDict; +- (void)finishedTracking:(ADJResponseDataTasks *)responseData; +- (void)launchResponseTasks:(ADJResponseDataTasks *)responseData; - (void)setEnabled:(BOOL)enabled; - (BOOL)isEnabled; - (void)appWillOpenUrl:(NSURL*)url; @@ -28,14 +29,12 @@ - (void) setAttribution:(ADJAttribution*)attribution; - (void) setAskingAttribution:(BOOL)askingAttribution; -- (BOOL) updateAttribution:(ADJAttribution*) attribution; +- (SEL) updateAttribution:(ADJAttribution *)attribution; - (void) setIadDate:(NSDate*)iAdImpressionDate withPurchaseDate:(NSDate*)appPurchaseDate; - (void)setIadDetails:(NSDictionary *)attributionDetails error:(NSError *)error retriesLeft:(int)retriesLeft; -- (void) launchAttributionDelegate; - - (void) setOfflineMode:(BOOL)offline; @end diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index cee2a7a93..52cff7799 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -18,6 +18,7 @@ #import "ADJAdjustFactory.h" #import "ADJAttributionHandler.h" #import "NSString+ADJAdditions.h" +#import "ADJResponseDataTasks.h" static NSString * const kActivityStateFilename = @"AdjustIoActivityState"; static NSString * const kAttributionFilename = @"AdjustIoAttribution"; @@ -109,11 +110,24 @@ - (void)trackEvent:(ADJEvent *)event }); } -- (void)finishedTracking:(NSDictionary *)jsonDict{ - if ([ADJUtil isNull:jsonDict]) return; +- (void)finishedTracking:(ADJResponseDataTasks *)responseDataTasks { + // no response json to check for attributes and no callback for events + if ([ADJUtil isNull:responseDataTasks.responseData.jsonResponse] && [ADJUtil isNull:responseDataTasks.finishDelegate]) { + return; + } + // callback for events is present + if ([ADJUtil isNull:responseDataTasks.responseData.jsonResponse]) { + [self launchResponseTasks:responseDataTasks]; + return; + } + // attribute might be present + [self.attributionHandler checkResponse:responseDataTasks]; +} - [self launchDeepLink:jsonDict]; - [self.attributionHandler checkAttribution:jsonDict]; +- (void)launchResponseTasks:(ADJResponseDataTasks *)responseData { + dispatch_async(self.internalQueue, ^{ + [self launchResponseTasksInternal:responseData]; + }); } - (void)launchDeepLink:(NSDictionary *)jsonDict{ @@ -293,31 +307,25 @@ - (void)setIadDetails:(NSDictionary *)attributionDetails [self.packageHandler addPackage:clickPackage]; } -- (BOOL)updateAttribution:(ADJAttribution *)attribution { +- (SEL)updateAttribution:(ADJAttribution *)attribution { if (attribution == nil) { - return NO; + return nil; } if ([attribution isEqual:self.attribution]) { - return NO; + return nil; } self.attribution = attribution; [self writeAttribution]; - [self launchAttributionDelegate]; - - return YES; -} - -- (void)launchAttributionDelegate{ if (self.attributionChangedDelegate == nil) { - return; + return nil; } if (![self.attributionChangedDelegate respondsToSelector:@selector(adjustAttributionChanged:)]) { - return; + return nil; } - [self.attributionChangedDelegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) - withObject:self.attribution waitUntilDone:NO]; + + return @selector(adjustAttributionChanged:); } - (void)setAskingAttribution:(BOOL)askingAttribution { @@ -490,6 +498,30 @@ - (void)eventInternal:(ADJEvent *)event [self writeActivityState]; } +- (void) launchResponseTasksInternal:(ADJResponseDataTasks *)responseDataTasks { + + SEL updateAttributionSEL = [self updateAttribution:responseDataTasks.attribution]; + ADJAttribution * localAttributionCopy = self.attribution; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + // first try to update and launch the attribution changed listener + if (updateAttributionSEL != nil) { + [self.attributionChangedDelegate performSelectorOnMainThread:updateAttributionSEL + withObject:localAttributionCopy + waitUntilDone:YES]; + } + // second try to launch the finished activity listener + if (responseDataTasks.finishDelegate != nil) { + dispatch_sync(dispatch_get_main_queue(), ^{ + responseDataTasks.finishDelegate(responseDataTasks.responseData); + }); + } + // in last, try to launch the deeplink + [self launchDeepLink:responseDataTasks.responseData.jsonResponse]; + }); +} + + - (void) appWillOpenUrlInternal:(NSURL *)url { if ([ADJUtil isNull:url]) { return; diff --git a/Adjust/ADJActivityPackage.h b/Adjust/ADJActivityPackage.h index a6b84a84e..83ffb6d9e 100644 --- a/Adjust/ADJActivityPackage.h +++ b/Adjust/ADJActivityPackage.h @@ -7,6 +7,7 @@ // #import "ADJActivityKind.h" +#import "ADJEvent.h" @interface ADJActivityPackage : NSObject @@ -19,6 +20,10 @@ @property (nonatomic, assign) ADJActivityKind activityKind; @property (nonatomic, copy) NSString *suffix; +// callbacks +@property (nonatomic, copy) ADJFinishActivity successDelegate; +@property (nonatomic, copy) ADJFinishActivity failureDelegate; + - (NSString *)extendedString; - (NSString *)successMessage; - (NSString *)failureMessage; diff --git a/Adjust/ADJAttributionHandler.h b/Adjust/ADJAttributionHandler.h index 5e2f45409..8e6504c4a 100644 --- a/Adjust/ADJAttributionHandler.h +++ b/Adjust/ADJAttributionHandler.h @@ -17,7 +17,7 @@ startPaused:(BOOL)startPaused hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate; -- (void)checkAttribution:(NSDictionary *)jsonDict; +- (void)checkResponse:(ADJResponseDataTasks *)responseDataTasks; - (void)getAttribution; diff --git a/Adjust/ADJAttributionHandler.m b/Adjust/ADJAttributionHandler.m index 3899d65c0..5d90326c4 100644 --- a/Adjust/ADJAttributionHandler.m +++ b/Adjust/ADJAttributionHandler.m @@ -62,9 +62,9 @@ - (id)initWithActivityHandler:(id) activityHandler return self; } -- (void) checkAttribution:(NSDictionary *)jsonDict { +- (void) checkResponse:(ADJResponseDataTasks *)responseDataTasks { dispatch_async(self.internalQueue, ^{ - [self checkAttributionInternal:jsonDict]; + [self checkResponseInternal:responseDataTasks]; }); } @@ -96,28 +96,36 @@ - (void) resumeSending { } #pragma mark - internal --(void) checkAttributionInternal:(NSDictionary *)jsonDict { - if ([ADJUtil isNull:jsonDict]) return; +- (void) checkResponseInternal:(ADJResponseDataTasks *)responseDataTasks { + [self checkAttributionInternal:responseDataTasks]; - NSDictionary* jsonAttribution = [jsonDict objectForKey:@"attribution"]; - ADJAttribution *attribution = [ADJAttribution dataWithJsonDict:jsonAttribution]; + [self.activityHandler launchResponseTasks:responseDataTasks]; +} + +- (void) checkAttributionInternal:(ADJResponseDataTasks *)responseDataTasks { + NSDictionary * jsonResponse = responseDataTasks.responseData.jsonResponse; + + if (jsonResponse == nil) { + return; + } - NSNumber *timerMilliseconds = [jsonDict objectForKey:@"ask_in"]; + NSNumber *timerMilliseconds = [jsonResponse objectForKey:@"ask_in"]; - if (timerMilliseconds == nil) { - [self.activityHandler updateAttribution:attribution]; + if (timerMilliseconds != nil) { + [self.activityHandler setAskingAttribution:YES]; - [self.activityHandler setAskingAttribution:NO]; + [self getAttributionWithDelay:[timerMilliseconds intValue]]; return; - }; + } - [self.activityHandler setAskingAttribution:YES]; + [self.activityHandler setAskingAttribution:NO]; - [self getAttributionWithDelay:[timerMilliseconds intValue]]; + NSDictionary * jsonAttribution = [jsonResponse objectForKey:@"attribution"]; + responseDataTasks.attribution = [ADJAttribution dataWithJsonDict:jsonAttribution]; } --(void) getAttributionInternal { +- (void) getAttributionInternal { if (!self.hasDelegate) { return; } @@ -129,9 +137,11 @@ -(void) getAttributionInternal { [ADJUtil sendRequest:[self request] prefixErrorMessage:@"Failed to get attribution" - jsonResponseHandler:^(NSDictionary *jsonDict) { - [self checkAttribution:jsonDict]; - }]; + activityPackage:self.attributionPackage +responseDataTasksHandler:^(ADJResponseDataTasks * responseDataTasks) + { + [self checkResponse:responseDataTasks]; + }]; } #pragma mark - private diff --git a/Adjust/ADJEvent.h b/Adjust/ADJEvent.h index 7fcb8881d..2b7df612d 100644 --- a/Adjust/ADJEvent.h +++ b/Adjust/ADJEvent.h @@ -7,6 +7,9 @@ // #import +#import "ADJResponseData.h" + +typedef void (^ADJFinishActivity)(ADJResponseData * responseData); @interface ADJEvent : NSObject @@ -18,6 +21,8 @@ @property (nonatomic, copy, readonly) NSString* currency; @property (nonatomic, copy, readonly) NSData* receipt; @property (nonatomic, assign, readonly) BOOL emptyReceipt; +@property (nonatomic, copy, readonly) ADJFinishActivity successDelegate; +@property (nonatomic, copy, readonly) ADJFinishActivity failureDelegate; /** * Create Event object with Event Token. @@ -86,4 +91,7 @@ */ - (void) setReceipt:(NSData *)receipt transactionId:(NSString *)transactionId; +- (void) setSuccessDelegate:(ADJFinishActivity)successDelegate; +- (void) setFailureDelegate:(ADJFinishActivity)failureDelegate; + @end diff --git a/Adjust/ADJEvent.m b/Adjust/ADJEvent.m index 56742249a..bef08c3ad 100644 --- a/Adjust/ADJEvent.m +++ b/Adjust/ADJEvent.m @@ -158,6 +158,14 @@ - (void) setReceipt:(NSData *)receipt transactionId:(NSString *)transactionId { _transactionId = transactionId; } +- (void) setSuccessDelegate:(ADJFinishActivity)successDelegate { + _successDelegate = successDelegate; +} + +- (void) setFailureDelegate:(ADJFinishActivity)failureDelegate { + _failureDelegate = failureDelegate; +} + - (BOOL) checkReceipt:(NSData *)receipt transactionId:(NSString *)transactionId { if ([ADJUtil isNotNull:receipt] && [ADJUtil isNull:transactionId]) { [self.logger error:@"Missing transactionId"]; diff --git a/Adjust/ADJPackageBuilder.m b/Adjust/ADJPackageBuilder.m index 5f9ee3c95..8d94306e1 100644 --- a/Adjust/ADJPackageBuilder.m +++ b/Adjust/ADJPackageBuilder.m @@ -80,6 +80,8 @@ - (ADJActivityPackage *)buildEventPackage:(ADJEvent *) event{ eventPackage.activityKind = ADJActivityKindEvent; eventPackage.suffix = [self eventSuffix:event]; eventPackage.parameters = parameters; + eventPackage.successDelegate = event.successDelegate; + eventPackage.failureDelegate = event.failureDelegate; return eventPackage; } diff --git a/Adjust/ADJPackageHandler.h b/Adjust/ADJPackageHandler.h index a08664c13..edc0c3b6b 100644 --- a/Adjust/ADJPackageHandler.h +++ b/Adjust/ADJPackageHandler.h @@ -10,6 +10,7 @@ #import "ADJActivityPackage.h" #import "ADJPackageHandler.h" #import "ADJActivityHandler.h" +#import "ADJResponseDataTasks.h" @protocol ADJPackageHandler @@ -18,11 +19,10 @@ - (void)addPackage:(ADJActivityPackage *)package; - (void)sendFirstPackage; -- (void)sendNextPackage; +- (void)sendNextPackage:(ADJResponseDataTasks *)responseDataTasks; - (void)closeFirstPackage; - (void)pauseSending; - (void)resumeSending; -- (void)finishedTracking:(NSDictionary *)jsonDict; @end diff --git a/Adjust/ADJPackageHandler.m b/Adjust/ADJPackageHandler.m index 9b8fcdaff..7e6568222 100644 --- a/Adjust/ADJPackageHandler.m +++ b/Adjust/ADJPackageHandler.m @@ -64,10 +64,12 @@ - (void)sendFirstPackage { }); } -- (void)sendNextPackage { +- (void)sendNextPackage:(ADJResponseDataTasks *)responseDataTasks{ dispatch_async(self.internalQueue, ^{ [self sendNextInternal]; }); + + [self.activityHandler finishedTracking:responseDataTasks]; } - (void)closeFirstPackage { @@ -82,10 +84,6 @@ - (void)resumeSending { self.paused = NO; } -- (void)finishedTracking:(NSDictionary *)jsonDict{ - [self.activityHandler finishedTracking:jsonDict]; -} - #pragma mark - internal - (void)initInternal:(id)activityHandler startPaused:(BOOL)startPaused diff --git a/Adjust/ADJRequestHandler.m b/Adjust/ADJRequestHandler.m index cfa46be5e..085e6e9b6 100644 --- a/Adjust/ADJRequestHandler.m +++ b/Adjust/ADJRequestHandler.m @@ -59,14 +59,14 @@ - (void)sendInternal:(ADJActivityPackage *)package{ [ADJUtil sendRequest:[self requestForPackage:package] prefixErrorMessage:package.failureMessage suffixErrorMessage:@"Will retry later" - jsonResponseHandler:^(NSDictionary *jsonDict) { - if (jsonDict == nil) { + activityPackage:package +responseDataTasksHandler:^(ADJResponseDataTasks * responseDataTasks) { + if (responseDataTasks.responseData.jsonResponse == nil) { [self.packageHandler closeFirstPackage]; return; } - [self.packageHandler finishedTracking:jsonDict]; - [self.packageHandler sendNextPackage]; + [self.packageHandler sendNextPackage:responseDataTasks]; }]; } diff --git a/Adjust/ADJResponseData.m b/Adjust/ADJResponseData.m index 37da3f783..81e2c8d81 100644 --- a/Adjust/ADJResponseData.m +++ b/Adjust/ADJResponseData.m @@ -21,6 +21,11 @@ - (id)init { return self; } +- (NSString *)description { + return [NSString stringWithFormat:@"message:%@ timestamp:%@ json:%@", + self.message, self.timeStamp, self.jsonResponse]; +} + #pragma mark - NSCopying -(id)copyWithZone:(NSZone *)zone diff --git a/Adjust/ADJResponseDataTasks.h b/Adjust/ADJResponseDataTasks.h index 04cd1ed27..58a6b0369 100644 --- a/Adjust/ADJResponseDataTasks.h +++ b/Adjust/ADJResponseDataTasks.h @@ -7,8 +7,9 @@ // #import -#import "ADJEvent.h" +#import "ADJResponseData.h" #import "ADJAttribution.h" +#import "ADJEvent.h" @interface ADJResponseDataTasks : NSObject diff --git a/Adjust/ADJUtil.h b/Adjust/ADJUtil.h index f5833781e..635b51588 100644 --- a/Adjust/ADJUtil.h +++ b/Adjust/ADJUtil.h @@ -7,6 +7,9 @@ // #import #import "ADJActivityKind.h" +#import "ADJResponseDataTasks.h" +#import "ADJActivityPackage.h" +#import "ADJEvent.h" @interface ADJUtil : NSObject @@ -16,7 +19,8 @@ + (void)excludeFromBackup:(NSString *)filename; + (NSString *)formatSeconds1970:(double)value; + (NSString *)formatDate:(NSDate *)value; -+ (NSDictionary *) buildJsonDict:(NSData *)jsonData; ++ (void) buildJsonDict:(NSData *)jsonData + responseData:(ADJResponseData *)responseData; + (NSString *)getFullFilename:(NSString *) baseFilename; @@ -33,12 +37,14 @@ + (BOOL)isNotNull:(id)value; + (void)sendRequest:(NSMutableURLRequest *)request prefixErrorMessage:(NSString *)prefixErrorMessage -jsonResponseHandler:(void (^) (NSDictionary * jsonDict))jsonResponseHandler; + activityPackage:(ADJActivityPackage *)activityPackage +responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler; + (void)sendRequest:(NSMutableURLRequest *)request prefixErrorMessage:(NSString *)prefixErrorMessage suffixErrorMessage:(NSString *)suffixErrorMessage -jsonResponseHandler:(void (^) (NSDictionary * jsonDict))jsonResponseHandler; + activityPackage:(ADJActivityPackage *)activityPackage +responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler; + (NSDictionary *)convertDictionaryValues:(NSDictionary *)dictionary; diff --git a/Adjust/ADJUtil.m b/Adjust/ADJUtil.m index b480877bc..4eab3c30c 100644 --- a/Adjust/ADJUtil.m +++ b/Adjust/ADJUtil.m @@ -12,6 +12,7 @@ #import "ADJAdjustFactory.h" #import "NSString+ADJAdditions.h" #import "ADJAdjustFactory.h" +#import "ADJResponseDataTasks.h" #include @@ -113,25 +114,31 @@ + (NSString *)formatDate:(NSDate *) value { return [dateFormat stringFromDate:value]; } -+ (NSDictionary *)buildJsonDict:(NSData *)jsonData { ++ (void) buildJsonDict:(NSData *)jsonData + responseData:(ADJResponseData *)responseData +{ if (jsonData == nil) { - return nil; + return; } NSError *error = nil; NSDictionary *jsonDict = nil; @try { jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; } @catch (NSException *ex) { - [ADJAdjustFactory.logger error:@"Failed to parse json response. (%@)", ex.description]; - return nil; + NSString * message = [NSString stringWithFormat:@"Failed to parse json response. (%@)", ex.description]; + [ADJAdjustFactory.logger error:message]; + responseData.message = message; + return; } if (error != nil) { - [ADJAdjustFactory.logger error:@"Failed to parse json response. (%@)", error.localizedDescription]; - return nil; + NSString * message = [NSString stringWithFormat:@"Failed to parse json response. (%@)", error.localizedDescription]; + [ADJAdjustFactory.logger error:message]; + responseData.message = message; + return; } - return jsonDict; + responseData.jsonResponse = jsonDict; } + (NSString *)getFullFilename:(NSString *) baseFilename { @@ -221,46 +228,57 @@ + (NSString *)formatErrorMessage:(NSString *)prefixErrorMessage } + (void)sendRequest:(NSMutableURLRequest *)request - prefixErrorMessage:(NSString *)prefixErrorMessage - jsonResponseHandler:(void (^) (NSDictionary * jsonDict))jsonResponseHandler + prefixErrorMessage:(NSString *)prefixErrorMessage + activityPackage:(ADJActivityPackage *)activityPackage +responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler { [ADJUtil sendRequest:request - prefixErrorMessage:prefixErrorMessage - suffixErrorMessage:nil - jsonResponseHandler:jsonResponseHandler]; + prefixErrorMessage:prefixErrorMessage + suffixErrorMessage:nil + activityPackage:activityPackage +responseDataTasksHandler:responseDataTasksHandler]; } + (void)sendRequest:(NSMutableURLRequest *)request - prefixErrorMessage:(NSString *)prefixErrorMessage - suffixErrorMessage:(NSString *)suffixErrorMessage - jsonResponseHandler:(void (^) (NSDictionary * jsonDict))jsonResponseHandler + prefixErrorMessage:(NSString *)prefixErrorMessage + suffixErrorMessage:(NSString *)suffixErrorMessage + activityPackage:(ADJActivityPackage *)activityPackage +responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler { Class NSURLSessionClass = NSClassFromString(@"NSURLSession"); if (NSURLSessionClass != nil) { [ADJUtil sendNSURLSessionRequest:request prefixErrorMessage:prefixErrorMessage suffixErrorMessage:suffixErrorMessage - jsonResponseHandler:jsonResponseHandler]; + activityPackage:activityPackage + responseDataTasksHandler:responseDataTasksHandler]; } else { [ADJUtil sendNSURLConnectionRequest:request prefixErrorMessage:prefixErrorMessage suffixErrorMessage:suffixErrorMessage - jsonResponseHandler:jsonResponseHandler]; + activityPackage:activityPackage + responseDataTasksHandler:responseDataTasksHandler]; } } + (void)sendNSURLSessionRequest:(NSMutableURLRequest *)request prefixErrorMessage:(NSString *)prefixErrorMessage suffixErrorMessage:(NSString *)suffixErrorMessage - jsonResponseHandler:(void (^) (NSDictionary * jsonDict))jsonResponseHandler + activityPackage:(ADJActivityPackage *)activityPackage + responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler { NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) { - NSDictionary * jsonResponse = [ADJUtil completionHandler:data response:(NSHTTPURLResponse *)response error:error prefixErrorMessage:prefixErrorMessage suffixErrorMessage:suffixErrorMessage]; - jsonResponseHandler(jsonResponse); + ADJResponseDataTasks * responseDataTasks = [ADJUtil completionHandler:data + response:(NSHTTPURLResponse *)response + error:error + prefixErrorMessage:prefixErrorMessage + suffixErrorMessage:suffixErrorMessage + activityPackage:activityPackage]; + responseDataTasksHandler(responseDataTasks); }]; [task resume]; } @@ -268,7 +286,8 @@ + (void)sendNSURLSessionRequest:(NSMutableURLRequest *)request + (void)sendNSURLConnectionRequest:(NSMutableURLRequest *)request prefixErrorMessage:(NSString *)prefixErrorMessage suffixErrorMessage:(NSString *)suffixErrorMessage - jsonResponseHandler:(void (^) (NSDictionary * jsonDict))jsonResponseHandler + activityPackage:(ADJActivityPackage *)activityPackage + responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler { NSError *responseError = nil; NSHTTPURLResponse *urlResponse = nil; @@ -280,33 +299,39 @@ + (void)sendNSURLConnectionRequest:(NSMutableURLRequest *)request error:&responseError]; #pragma clang diagnostic pop - NSDictionary * jsonResponse = [ADJUtil completionHandler:data - response:(NSHTTPURLResponse *)urlResponse - error:responseError - prefixErrorMessage:prefixErrorMessage - suffixErrorMessage:suffixErrorMessage]; + ADJResponseDataTasks * responseDataTasks = [ADJUtil completionHandler:data + response:(NSHTTPURLResponse *)urlResponse + error:responseError + prefixErrorMessage:prefixErrorMessage + suffixErrorMessage:suffixErrorMessage + activityPackage:activityPackage]; - jsonResponseHandler(jsonResponse); + responseDataTasksHandler(responseDataTasks); } -+ (NSDictionary *)completionHandler:(NSData *)data - response:(NSHTTPURLResponse *)urlResponse - error:(NSError *)responseError - prefixErrorMessage:(NSString *)prefixErrorMessage - suffixErrorMessage:(NSString *)suffixErrorMessage ++ (ADJResponseDataTasks *)completionHandler:(NSData *)data + response:(NSHTTPURLResponse *)urlResponse + error:(NSError *)responseError + prefixErrorMessage:(NSString *)prefixErrorMessage + suffixErrorMessage:(NSString *)suffixErrorMessage + activityPackage:(ADJActivityPackage *)activityPackage { + ADJResponseDataTasks * responseDataTasks = [ADJResponseDataTasks responseDataTasks]; + responseDataTasks.responseData = [ADJResponseData responseData]; + responseDataTasks.finishDelegate = activityPackage.failureDelegate; + // connection error if (responseError != nil) { [ADJAdjustFactory.logger error:[ADJUtil formatErrorMessage:prefixErrorMessage systemErrorMessage:responseError.localizedDescription suffixErrorMessage:suffixErrorMessage]]; - return nil; + return responseDataTasks; } if ([ADJUtil isNull:data]) { [ADJAdjustFactory.logger error:[ADJUtil formatErrorMessage:prefixErrorMessage systemErrorMessage:@"empty error" suffixErrorMessage:suffixErrorMessage]]; - return nil; + return responseDataTasks; } NSString *responseString = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] adjTrim]; @@ -314,13 +339,16 @@ + (NSDictionary *)completionHandler:(NSData *)data [ADJAdjustFactory.logger verbose:@"Response: %@", responseString]; - NSDictionary *jsonDict = [ADJUtil buildJsonDict:data]; + [ADJUtil buildJsonDict:data responseData:responseDataTasks.responseData]; - if ([ADJUtil isNull:jsonDict]) { - return nil; + if ([ADJUtil isNull:responseDataTasks.responseData.jsonResponse]) { + return responseDataTasks; } - NSString* messageResponse = [jsonDict objectForKey:@"message"]; + NSString* messageResponse = [responseDataTasks.responseData.jsonResponse objectForKey:@"message"]; + + responseDataTasks.responseData.message = messageResponse; + responseDataTasks.responseData.timeStamp = [responseDataTasks.responseData.jsonResponse objectForKey:@"timestamp"]; if (messageResponse == nil) { messageResponse = @"No message found"; @@ -328,11 +356,12 @@ + (NSDictionary *)completionHandler:(NSData *)data if (statusCode == 200) { [ADJAdjustFactory.logger info:@"%@", messageResponse]; + responseDataTasks.finishDelegate = activityPackage.successDelegate; } else { [ADJAdjustFactory.logger error:@"%@", messageResponse]; } - return jsonDict; + return responseDataTasks; } // convert all values to strings, if value is dictionary -> recursive call diff --git a/AdjustSdk/AdjustSdk.h b/AdjustSdk/AdjustSdk.h index 185bad7fb..e31075be5 100644 --- a/AdjustSdk/AdjustSdk.h +++ b/AdjustSdk/AdjustSdk.h @@ -21,3 +21,4 @@ FOUNDATION_EXPORT const unsigned char AdjustSdkVersionString[]; #import #import #import +#import From 4eb6bf87d495738ebe6fea5fce1cdfad13635ddc Mon Sep 17 00:00:00 2001 From: Pedro Filipe Date: Tue, 15 Dec 2015 20:17:22 +0100 Subject: [PATCH 05/33] README push token --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 081590837..fd9997223 100644 --- a/README.md +++ b/README.md @@ -503,6 +503,16 @@ To obtain the device identifier IDFA, call the function `idfa`: NSString * idfa = [Adjust idfa]; ``` +### 14. Push token + +To send us the push notification token, then add the following call to `Adjust` in the `didRegisterForRemoteNotificationsWithDeviceToken` of your app delegate: + +```objc +- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { + [Adjust setDeviceToken:deviceToken]; +} +``` + [adjust.com]: http://adjust.com [cocoapods]: http://cocoapods.org [carthage]: https://github.com/Carthage/Carthage From 3a53340276c6241cc45e47ed2ce8f80bc3b68b25 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 6 Jan 2016 15:47:50 +0100 Subject: [PATCH 06/33] Delegate for all event/sessions --- Adjust.xcodeproj/project.pbxproj | 54 +++++++---- Adjust/ADJActivityHandler.h | 14 +-- Adjust/ADJActivityHandler.m | 51 ++++++---- Adjust/ADJActivityPackage.h | 5 - Adjust/ADJAttributionHandler.h | 2 +- Adjust/ADJAttributionHandler.m | 26 +++-- Adjust/ADJConfig.h | 10 ++ Adjust/ADJConfig.m | 8 ++ Adjust/ADJEvent.h | 8 -- Adjust/ADJEvent.m | 8 -- Adjust/ADJFailureResponseData.h | 31 ++++++ Adjust/ADJFailureResponseData.m | 56 +++++++++++ Adjust/ADJPackageBuilder.m | 2 - Adjust/ADJPackageHandler.h | 6 +- Adjust/ADJPackageHandler.m | 9 +- Adjust/ADJRequestHandler.h | 1 - Adjust/ADJRequestHandler.m | 8 +- Adjust/ADJResponseData.h | 27 +++++- Adjust/ADJResponseData.m | 41 +++++++- Adjust/ADJResponseDataTasks.h | 25 ----- Adjust/ADJResponseDataTasks.m | 24 ----- Adjust/ADJSuccessResponseData.h | 29 ++++++ Adjust/ADJSuccessResponseData.m | 54 +++++++++++ Adjust/ADJUtil.h | 6 +- Adjust/ADJUtil.m | 97 ++++++++++--------- .../project.pbxproj | 18 ++-- .../project.pbxproj | 18 ++-- 27 files changed, 426 insertions(+), 212 deletions(-) create mode 100644 Adjust/ADJFailureResponseData.h create mode 100644 Adjust/ADJFailureResponseData.m delete mode 100644 Adjust/ADJResponseDataTasks.h delete mode 100644 Adjust/ADJResponseDataTasks.m create mode 100644 Adjust/ADJSuccessResponseData.h create mode 100644 Adjust/ADJSuccessResponseData.m diff --git a/Adjust.xcodeproj/project.pbxproj b/Adjust.xcodeproj/project.pbxproj index ac346f7e3..59230572c 100644 --- a/Adjust.xcodeproj/project.pbxproj +++ b/Adjust.xcodeproj/project.pbxproj @@ -38,12 +38,20 @@ 9679921118BBAE2800394606 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679921018BBAE2800394606 /* Foundation.framework */; }; 9679922018BBAE2800394606 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679921018BBAE2800394606 /* Foundation.framework */; }; 9679922518BBAE2800394606 /* libAdjust.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679920D18BBAE2800394606 /* libAdjust.a */; }; + 968173831C3C2D07002AE1DE /* ADJSuccessResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 968173811C3C2D07002AE1DE /* ADJSuccessResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 968173841C3C2D07002AE1DE /* ADJSuccessResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 968173821C3C2D07002AE1DE /* ADJSuccessResponseData.m */; }; + 968173871C3C2D36002AE1DE /* ADJFailureResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 968173851C3C2D36002AE1DE /* ADJFailureResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 968173881C3C2D36002AE1DE /* ADJFailureResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 968173861C3C2D36002AE1DE /* ADJFailureResponseData.m */; }; 96854A591B1F2779002B2874 /* ADJTimerOnce.h in Headers */ = {isa = PBXBuildFile; fileRef = 96854A571B1F2779002B2874 /* ADJTimerOnce.h */; }; 96854A5A1B1F2779002B2874 /* ADJTimerOnce.m in Sources */ = {isa = PBXBuildFile; fileRef = 96854A581B1F2779002B2874 /* ADJTimerOnce.m */; }; 96854A5F1B1F278C002B2874 /* ADJTimerCycle.h in Headers */ = {isa = PBXBuildFile; fileRef = 96854A5D1B1F278C002B2874 /* ADJTimerCycle.h */; }; 96854A601B1F278C002B2874 /* ADJTimerCycle.m in Sources */ = {isa = PBXBuildFile; fileRef = 96854A5E1B1F278C002B2874 /* ADJTimerCycle.m */; }; 969952CF1A012F5300928462 /* ADJAttributionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 969952CE1A012F5300928462 /* ADJAttributionHandler.m */; }; 969952D21A01309200928462 /* ADJAttribution.m in Sources */ = {isa = PBXBuildFile; fileRef = 969952D11A01309200928462 /* ADJAttribution.m */; }; + 96BA93FB1C3D56D900C96245 /* ADJSuccessResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 968173811C3C2D07002AE1DE /* ADJSuccessResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 96BA93FC1C3D56F400C96245 /* ADJFailureResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 968173851C3C2D36002AE1DE /* ADJFailureResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 96BA93FD1C3D574F00C96245 /* ADJSuccessResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 968173821C3C2D07002AE1DE /* ADJSuccessResponseData.m */; }; + 96BA93FE1C3D575D00C96245 /* ADJFailureResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 968173861C3C2D36002AE1DE /* ADJFailureResponseData.m */; }; 96BCFBCD1AC99231005A65C5 /* Adjust.h in Headers */ = {isa = PBXBuildFile; fileRef = 96E5E34C18BBB48A008E7B30 /* Adjust.h */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCFBCE1AC99235005A65C5 /* ADJEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 9609BC6819EEA55800E02303 /* ADJEvent.h */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCFBD01AC9923F005A65C5 /* ADJConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 960A8BB71A029A8000F2BB95 /* ADJConfig.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -91,14 +99,10 @@ 96E5E3B818BBB49E008E7B30 /* NSURLConnection+NSURLConnectionSynchronousLoadingMocking.m in Sources */ = {isa = PBXBuildFile; fileRef = 96E5E3AD18BBB49E008E7B30 /* NSURLConnection+NSURLConnectionSynchronousLoadingMocking.m */; }; 96ED00391A38A4CD00209110 /* ADJAttributionHandlerMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 96ED00381A38A4CD00209110 /* ADJAttributionHandlerMock.m */; }; 96ED003E1A38A98C00209110 /* ADJDelegateTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 96ED003D1A38A98C00209110 /* ADJDelegateTest.m */; }; - 96FCC53A1C186426007BBFE1 /* ADJResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC5361C186426007BBFE1 /* ADJResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 96FCC53A1C186426007BBFE1 /* ADJResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC5361C186426007BBFE1 /* ADJResponseData.h */; }; 96FCC53B1C186426007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5371C186426007BBFE1 /* ADJResponseData.m */; }; - 96FCC53C1C186426007BBFE1 /* ADJResponseDataTasks.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC5381C186426007BBFE1 /* ADJResponseDataTasks.h */; }; - 96FCC53D1C186426007BBFE1 /* ADJResponseDataTasks.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5391C186426007BBFE1 /* ADJResponseDataTasks.m */; }; - 96FCC5521C1865D3007BBFE1 /* ADJResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC54E1C1865D3007BBFE1 /* ADJResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 96FCC5521C1865D3007BBFE1 /* ADJResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC54E1C1865D3007BBFE1 /* ADJResponseData.h */; }; 96FCC5531C1865D3007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC54F1C1865D3007BBFE1 /* ADJResponseData.m */; }; - 96FCC5541C1865D3007BBFE1 /* ADJResponseDataTasks.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC5501C1865D3007BBFE1 /* ADJResponseDataTasks.h */; }; - 96FCC5551C1865D3007BBFE1 /* ADJResponseDataTasks.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5511C1865D3007BBFE1 /* ADJResponseDataTasks.m */; }; 9D363AC31BDA50FA00B47FE9 /* ADJLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 96E5E37318BBB48A008E7B30 /* ADJLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9DE7C8FD1AE688DA001556E5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DE7C8FC1AE688DA001556E5 /* UIKit.framework */; }; 9DFA37B71C0F21D600782607 /* AdjustSdk.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37B51C0F21D600782607 /* AdjustSdk.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -213,6 +217,10 @@ 9679920D18BBAE2800394606 /* libAdjust.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAdjust.a; sourceTree = BUILT_PRODUCTS_DIR; }; 9679921018BBAE2800394606 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 9679921D18BBAE2800394606 /* AdjustTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AdjustTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 968173811C3C2D07002AE1DE /* ADJSuccessResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSuccessResponseData.h; sourceTree = ""; }; + 968173821C3C2D07002AE1DE /* ADJSuccessResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSuccessResponseData.m; sourceTree = ""; }; + 968173851C3C2D36002AE1DE /* ADJFailureResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJFailureResponseData.h; sourceTree = ""; }; + 968173861C3C2D36002AE1DE /* ADJFailureResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJFailureResponseData.m; sourceTree = ""; }; 96854A571B1F2779002B2874 /* ADJTimerOnce.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJTimerOnce.h; sourceTree = ""; }; 96854A581B1F2779002B2874 /* ADJTimerOnce.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJTimerOnce.m; sourceTree = ""; }; 96854A5D1B1F278C002B2874 /* ADJTimerCycle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJTimerCycle.h; sourceTree = ""; }; @@ -273,8 +281,6 @@ 96ED003D1A38A98C00209110 /* ADJDelegateTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJDelegateTest.m; sourceTree = ""; }; 96FCC5361C186426007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseData.h; sourceTree = ""; }; 96FCC5371C186426007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseData.m; sourceTree = ""; }; - 96FCC5381C186426007BBFE1 /* ADJResponseDataTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseDataTasks.h; sourceTree = ""; }; - 96FCC5391C186426007BBFE1 /* ADJResponseDataTasks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseDataTasks.m; sourceTree = ""; }; 96FCC54E1C1865D3007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJResponseData.h; path = Adjust/ADJResponseData.h; sourceTree = SOURCE_ROOT; }; 96FCC54F1C1865D3007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJResponseData.m; path = Adjust/ADJResponseData.m; sourceTree = SOURCE_ROOT; }; 96FCC5501C1865D3007BBFE1 /* ADJResponseDataTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJResponseDataTasks.h; path = Adjust/ADJResponseDataTasks.h; sourceTree = SOURCE_ROOT; }; @@ -470,8 +476,10 @@ 96854A5E1B1F278C002B2874 /* ADJTimerCycle.m */, 96FCC5361C186426007BBFE1 /* ADJResponseData.h */, 96FCC5371C186426007BBFE1 /* ADJResponseData.m */, - 96FCC5381C186426007BBFE1 /* ADJResponseDataTasks.h */, - 96FCC5391C186426007BBFE1 /* ADJResponseDataTasks.m */, + 968173811C3C2D07002AE1DE /* ADJSuccessResponseData.h */, + 968173821C3C2D07002AE1DE /* ADJSuccessResponseData.m */, + 968173851C3C2D36002AE1DE /* ADJFailureResponseData.h */, + 968173861C3C2D36002AE1DE /* ADJFailureResponseData.m */, ); path = Adjust; sourceTree = ""; @@ -583,14 +591,14 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 96BCFBD21AC99332005A65C5 /* NSString+ADJAdditions.h in Headers */, - 96FCC53C1C186426007BBFE1 /* ADJResponseDataTasks.h in Headers */, 96BCFBCD1AC99231005A65C5 /* Adjust.h in Headers */, + 96BCFBD21AC99332005A65C5 /* NSString+ADJAdditions.h in Headers */, 96BCFBCE1AC99235005A65C5 /* ADJEvent.h in Headers */, - 96BCFBD11AC99246005A65C5 /* ADJAttribution.h in Headers */, - 96FCC53A1C186426007BBFE1 /* ADJResponseData.h in Headers */, - 9D363AC31BDA50FA00B47FE9 /* ADJLogger.h in Headers */, 96BCFBD01AC9923F005A65C5 /* ADJConfig.h in Headers */, + 9D363AC31BDA50FA00B47FE9 /* ADJLogger.h in Headers */, + 96BCFBD11AC99246005A65C5 /* ADJAttribution.h in Headers */, + 968173831C3C2D07002AE1DE /* ADJSuccessResponseData.h in Headers */, + 968173871C3C2D36002AE1DE /* ADJFailureResponseData.h in Headers */, 96BCFBD91AC9934E005A65C5 /* ADJAdjustFactory.h in Headers */, 96BCFBD81AC9934B005A65C5 /* ADJActivityState.h in Headers */, 96BCFBD61AC99345005A65C5 /* ADJActivityKind.h in Headers */, @@ -606,6 +614,7 @@ 96BCFBD41AC99338005A65C5 /* NSData+ADJAdditions.h in Headers */, 96BCFBDE1AC99365005A65C5 /* ADJUtil.h in Headers */, 96BCFBDC1AC99360005A65C5 /* ADJRequestHandler.h in Headers */, + 96FCC53A1C186426007BBFE1 /* ADJResponseData.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -614,13 +623,13 @@ buildActionMask = 2147483647; files = ( 9DFA37B71C0F21D600782607 /* AdjustSdk.h in Headers */, - 96FCC5541C1865D3007BBFE1 /* ADJResponseDataTasks.h in Headers */, 9DFA37FF1C0F220200782607 /* Adjust.h in Headers */, 9DFA37F11C0F220200782607 /* ADJEvent.h in Headers */, 9DFA37ED1C0F220200782607 /* ADJConfig.h in Headers */, - 96FCC5521C1865D3007BBFE1 /* ADJResponseData.h in Headers */, 9DFA37F31C0F220200782607 /* ADJLogger.h in Headers */, 9DFA37E91C0F220200782607 /* ADJAttribution.h in Headers */, + 96BA93FB1C3D56D900C96245 /* ADJSuccessResponseData.h in Headers */, + 96BA93FC1C3D56F400C96245 /* ADJFailureResponseData.h in Headers */, 9DFA38011C0F220200782607 /* ADJUtil.h in Headers */, 9DFA37EF1C0F220200782607 /* ADJDeviceInfo.h in Headers */, 9DFA380C1C0F220D00782607 /* NSString+ADJAdditions.h in Headers */, @@ -637,6 +646,7 @@ 9DFA37E31C0F220200782607 /* ADJActivityPackage.h in Headers */, 9DFA37E71C0F220200782607 /* ADJAdjustFactory.h in Headers */, 9DFA37EB1C0F220200782607 /* ADJAttributionHandler.h in Headers */, + 96FCC5521C1865D3007BBFE1 /* ADJResponseData.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -716,7 +726,7 @@ }; }; }; - buildConfigurationList = 9679920818BBAE2800394606 /* Build configuration list for PBXProject "Adjust" */; + buildConfigurationList = 9679920818BBAE2800394606 /* Build configuration list for PBXProject "adjust" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; @@ -842,7 +852,7 @@ 96E5E38C18BBB48A008E7B30 /* ADJActivityKind.m in Sources */, 96C93DF51AC47F2E00B53F56 /* NSData+ADJAdditions.m in Sources */, 96E5E38D18BBB48A008E7B30 /* ADJActivityPackage.m in Sources */, - 96FCC53D1C186426007BBFE1 /* ADJResponseDataTasks.m in Sources */, + 968173881C3C2D36002AE1DE /* ADJFailureResponseData.m in Sources */, 965307F61A000DA400107FF9 /* ADJDeviceInfo.m in Sources */, 969952D21A01309200928462 /* ADJAttribution.m in Sources */, 969952CF1A012F5300928462 /* ADJAttributionHandler.m in Sources */, @@ -850,6 +860,7 @@ 9609BC6A19EEA55800E02303 /* ADJEvent.m in Sources */, 96E5E39518BBB48A008E7B30 /* ADJPackageHandler.m in Sources */, 96854A5A1B1F2779002B2874 /* ADJTimerOnce.m in Sources */, + 968173841C3C2D07002AE1DE /* ADJSuccessResponseData.m in Sources */, 96E5E39318BBB48A008E7B30 /* ADJLogger.m in Sources */, 96E5E39418BBB48A008E7B30 /* ADJPackageBuilder.m in Sources */, 960A8BB91A029A8000F2BB95 /* ADJConfig.m in Sources */, @@ -886,6 +897,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 96BA93FE1C3D575D00C96245 /* ADJFailureResponseData.m in Sources */, + 96BA93FD1C3D574F00C96245 /* ADJSuccessResponseData.m in Sources */, 9DFA37E81C0F220200782607 /* ADJAdjustFactory.m in Sources */, 9DFA37E21C0F220200782607 /* ADJActivityKind.m in Sources */, 9DFA37FA1C0F220200782607 /* ADJRequestHandler.m in Sources */, @@ -897,7 +910,6 @@ 9DFA37F21C0F220200782607 /* ADJEvent.m in Sources */, 9DFA38021C0F220200782607 /* ADJUtil.m in Sources */, 9DFA37EC1C0F220200782607 /* ADJAttributionHandler.m in Sources */, - 96FCC5551C1865D3007BBFE1 /* ADJResponseDataTasks.m in Sources */, 9DFA37F41C0F220200782607 /* ADJLogger.m in Sources */, 9DFA37E61C0F220200782607 /* ADJActivityState.m in Sources */, 9DFA380B1C0F220D00782607 /* NSData+ADJAdditions.m in Sources */, @@ -1196,7 +1208,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 9679920818BBAE2800394606 /* Build configuration list for PBXProject "Adjust" */ = { + 9679920818BBAE2800394606 /* Build configuration list for PBXProject "adjust" */ = { isa = XCConfigurationList; buildConfigurations = ( 9679922E18BBAE2800394606 /* Debug */, diff --git a/Adjust/ADJActivityHandler.h b/Adjust/ADJActivityHandler.h index ffa9a8b93..30af13186 100644 --- a/Adjust/ADJActivityHandler.h +++ b/Adjust/ADJActivityHandler.h @@ -7,7 +7,7 @@ // #import "Adjust.h" -#import "ADJResponseDataTasks.h" +#import "ADJResponseData.h" @protocol ADJActivityHandler @@ -18,19 +18,19 @@ - (void)trackEvent:(ADJEvent *)event; -- (void)finishedTracking:(ADJResponseDataTasks *)responseData; -- (void)launchResponseTasks:(ADJResponseDataTasks *)responseData; +- (void)finishedTracking:(ADJResponseData *)responseData; +- (void)launchResponseTasks:(ADJResponseData *)responseData; - (void)setEnabled:(BOOL)enabled; - (BOOL)isEnabled; - (void)appWillOpenUrl:(NSURL*)url; - (void)setDeviceToken:(NSData *)deviceToken; - (ADJAttribution*) attribution; -- (void) setAttribution:(ADJAttribution*)attribution; -- (void) setAskingAttribution:(BOOL)askingAttribution; +- (void)setAttribution:(ADJAttribution*)attribution; +- (void)setAskingAttribution:(BOOL)askingAttribution; -- (SEL) updateAttribution:(ADJAttribution *)attribution; -- (void) setIadDate:(NSDate*)iAdImpressionDate withPurchaseDate:(NSDate*)appPurchaseDate; +- (SEL)updateAttribution:(ADJAttribution *)attribution; +- (void)setIadDate:(NSDate*)iAdImpressionDate withPurchaseDate:(NSDate*)appPurchaseDate; - (void)setIadDetails:(NSDictionary *)attributionDetails error:(NSError *)error retriesLeft:(int)retriesLeft; diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index 52cff7799..aad8591b5 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -18,7 +18,6 @@ #import "ADJAdjustFactory.h" #import "ADJAttributionHandler.h" #import "NSString+ADJAdditions.h" -#import "ADJResponseDataTasks.h" static NSString * const kActivityStateFilename = @"AdjustIoActivityState"; static NSString * const kAttributionFilename = @"AdjustIoAttribution"; @@ -110,21 +109,21 @@ - (void)trackEvent:(ADJEvent *)event }); } -- (void)finishedTracking:(ADJResponseDataTasks *)responseDataTasks { - // no response json to check for attributes and no callback for events - if ([ADJUtil isNull:responseDataTasks.responseData.jsonResponse] && [ADJUtil isNull:responseDataTasks.finishDelegate]) { +- (void)finishedTracking:(ADJResponseData *)responseData { + // no response json to check for attributes and no callback for failed package + if ([ADJUtil isNull:responseData.jsonResponse] && [ADJUtil isNull:self.adjustConfig.failureDelegate]) { return; } - // callback for events is present - if ([ADJUtil isNull:responseDataTasks.responseData.jsonResponse]) { - [self launchResponseTasks:responseDataTasks]; + // callback for failed package is present + if ([ADJUtil isNull:responseData.jsonResponse]) { + [self launchResponseTasks:responseData]; return; } // attribute might be present - [self.attributionHandler checkResponse:responseDataTasks]; + [self.attributionHandler checkResponse:responseData]; } -- (void)launchResponseTasks:(ADJResponseDataTasks *)responseData { +- (void)launchResponseTasks:(ADJResponseData *)responseData { dispatch_async(self.internalQueue, ^{ [self launchResponseTasksInternal:responseData]; }); @@ -498,9 +497,9 @@ - (void)eventInternal:(ADJEvent *)event [self writeActivityState]; } -- (void) launchResponseTasksInternal:(ADJResponseDataTasks *)responseDataTasks { +- (void) launchResponseTasksInternal:(ADJResponseData *)responseData { - SEL updateAttributionSEL = [self updateAttribution:responseDataTasks.attribution]; + SEL updateAttributionSEL = [self updateAttribution:responseData.attribution]; ADJAttribution * localAttributionCopy = self.attribution; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ @@ -511,16 +510,34 @@ - (void) launchResponseTasksInternal:(ADJResponseDataTasks *)responseDataTasks { waitUntilDone:YES]; } // second try to launch the finished activity listener - if (responseDataTasks.finishDelegate != nil) { - dispatch_sync(dispatch_get_main_queue(), ^{ - responseDataTasks.finishDelegate(responseDataTasks.responseData); - }); - } + [self launchFinishedDelegate:responseData]; // in last, try to launch the deeplink - [self launchDeepLink:responseDataTasks.responseData.jsonResponse]; + [self launchDeepLink:responseData.jsonResponse]; }); } +- (void) launchFinishedDelegate:(ADJResponseData *)responseData { + // no event or session package + if (responseData.activityKind != ADJActivityKindEvent && responseData.activityKind != ADJActivityKindSession) { + return; + } + // no success callback + if (responseData.success && [ADJUtil isNull:self.adjustConfig.successDelegate]) { + return; + } + // no failure callback + if (!responseData.success && [ADJUtil isNull:self.adjustConfig.failureDelegate]) { + return; + } + // add it to the handler queue + dispatch_sync(dispatch_get_main_queue(), ^{ + if (responseData.success) { + self.adjustConfig.successDelegate([responseData successResponseData]); + } else { + self.adjustConfig.failureDelegate([responseData failureResponseData]); + } + }); +} - (void) appWillOpenUrlInternal:(NSURL *)url { if ([ADJUtil isNull:url]) { diff --git a/Adjust/ADJActivityPackage.h b/Adjust/ADJActivityPackage.h index 83ffb6d9e..a6b84a84e 100644 --- a/Adjust/ADJActivityPackage.h +++ b/Adjust/ADJActivityPackage.h @@ -7,7 +7,6 @@ // #import "ADJActivityKind.h" -#import "ADJEvent.h" @interface ADJActivityPackage : NSObject @@ -20,10 +19,6 @@ @property (nonatomic, assign) ADJActivityKind activityKind; @property (nonatomic, copy) NSString *suffix; -// callbacks -@property (nonatomic, copy) ADJFinishActivity successDelegate; -@property (nonatomic, copy) ADJFinishActivity failureDelegate; - - (NSString *)extendedString; - (NSString *)successMessage; - (NSString *)failureMessage; diff --git a/Adjust/ADJAttributionHandler.h b/Adjust/ADJAttributionHandler.h index 8e6504c4a..24015e113 100644 --- a/Adjust/ADJAttributionHandler.h +++ b/Adjust/ADJAttributionHandler.h @@ -17,7 +17,7 @@ startPaused:(BOOL)startPaused hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate; -- (void)checkResponse:(ADJResponseDataTasks *)responseDataTasks; +- (void)checkResponse:(ADJResponseData *)responseData; - (void)getAttribution; diff --git a/Adjust/ADJAttributionHandler.m b/Adjust/ADJAttributionHandler.m index 5d90326c4..db974c67d 100644 --- a/Adjust/ADJAttributionHandler.m +++ b/Adjust/ADJAttributionHandler.m @@ -62,9 +62,9 @@ - (id)initWithActivityHandler:(id) activityHandler return self; } -- (void) checkResponse:(ADJResponseDataTasks *)responseDataTasks { +- (void) checkResponse:(ADJResponseData *)responseData { dispatch_async(self.internalQueue, ^{ - [self checkResponseInternal:responseDataTasks]; + [self checkResponseInternal:responseData]; }); } @@ -96,20 +96,18 @@ - (void) resumeSending { } #pragma mark - internal -- (void) checkResponseInternal:(ADJResponseDataTasks *)responseDataTasks { - [self checkAttributionInternal:responseDataTasks]; +- (void) checkResponseInternal:(ADJResponseData *)responseData { + [self checkAttributionInternal:responseData]; - [self.activityHandler launchResponseTasks:responseDataTasks]; + [self.activityHandler launchResponseTasks:responseData]; } -- (void) checkAttributionInternal:(ADJResponseDataTasks *)responseDataTasks { - NSDictionary * jsonResponse = responseDataTasks.responseData.jsonResponse; - - if (jsonResponse == nil) { +- (void) checkAttributionInternal:(ADJResponseData *)responseData { + if (responseData.jsonResponse == nil) { return; } - NSNumber *timerMilliseconds = [jsonResponse objectForKey:@"ask_in"]; + NSNumber *timerMilliseconds = [responseData.jsonResponse objectForKey:@"ask_in"]; if (timerMilliseconds != nil) { [self.activityHandler setAskingAttribution:YES]; @@ -121,8 +119,8 @@ - (void) checkAttributionInternal:(ADJResponseDataTasks *)responseDataTasks { [self.activityHandler setAskingAttribution:NO]; - NSDictionary * jsonAttribution = [jsonResponse objectForKey:@"attribution"]; - responseDataTasks.attribution = [ADJAttribution dataWithJsonDict:jsonAttribution]; + NSDictionary * jsonAttribution = [responseData.jsonResponse objectForKey:@"attribution"]; + responseData.attribution = [ADJAttribution dataWithJsonDict:jsonAttribution]; } - (void) getAttributionInternal { @@ -138,9 +136,9 @@ - (void) getAttributionInternal { [ADJUtil sendRequest:[self request] prefixErrorMessage:@"Failed to get attribution" activityPackage:self.attributionPackage -responseDataTasksHandler:^(ADJResponseDataTasks * responseDataTasks) + responseDataHandler:^(ADJResponseData * responseData) { - [self checkResponse:responseDataTasks]; + [self checkResponse:responseData]; }]; } diff --git a/Adjust/ADJConfig.h b/Adjust/ADJConfig.h index 245080306..140ac9b30 100644 --- a/Adjust/ADJConfig.h +++ b/Adjust/ADJConfig.h @@ -9,6 +9,8 @@ #import #import "ADJLogger.h" #import "ADJAttribution.h" +#import "ADJSuccessResponseData.h" +#import "ADJFailureResponseData.h" /** * Optional delegate that will get informed about tracking results @@ -25,12 +27,17 @@ @end +typedef void (^ADJTrackingSucceeded)(ADJSuccessResponseData * successResponseData); +typedef void (^ADJTrackingFailed)(ADJFailureResponseData * failureResponseData); + @interface ADJConfig : NSObject @property (nonatomic, copy, readonly) NSString *appToken; @property (nonatomic, copy, readonly) NSString *environment; @property (nonatomic, copy) NSString *sdkPrefix; @property (nonatomic, copy) NSString *defaultTracker; +@property (nonatomic, copy, readonly) ADJTrackingSucceeded successDelegate; +@property (nonatomic, copy, readonly) ADJTrackingFailed failureDelegate; /** * Configuration object for the initialization of the Adjust SDK. @@ -83,5 +90,8 @@ @property (nonatomic, weak) NSObject *delegate; @property (nonatomic, assign) BOOL hasAttributionChangedDelegate; +- (void) setSuccessDelegate:(ADJTrackingSucceeded)successDelegate; +- (void) setFailureDelegate:(ADJTrackingFailed)failureDelegate; + - (BOOL) isValid; @end diff --git a/Adjust/ADJConfig.m b/Adjust/ADJConfig.m index 5a9bc6397..71b01e397 100644 --- a/Adjust/ADJConfig.m +++ b/Adjust/ADJConfig.m @@ -99,6 +99,14 @@ - (BOOL)checkAppToken:(NSString *)appToken { return YES; } +- (void) setSuccessDelegate:(ADJTrackingSucceeded)successDelegate { + _successDelegate = successDelegate; +} + +- (void) setFailureDelegate:(ADJTrackingFailed)failureDelegate { + _failureDelegate = failureDelegate; +} + - (BOOL) isValid { return self.appToken != nil; } diff --git a/Adjust/ADJEvent.h b/Adjust/ADJEvent.h index 2b7df612d..7fcb8881d 100644 --- a/Adjust/ADJEvent.h +++ b/Adjust/ADJEvent.h @@ -7,9 +7,6 @@ // #import -#import "ADJResponseData.h" - -typedef void (^ADJFinishActivity)(ADJResponseData * responseData); @interface ADJEvent : NSObject @@ -21,8 +18,6 @@ typedef void (^ADJFinishActivity)(ADJResponseData * responseData); @property (nonatomic, copy, readonly) NSString* currency; @property (nonatomic, copy, readonly) NSData* receipt; @property (nonatomic, assign, readonly) BOOL emptyReceipt; -@property (nonatomic, copy, readonly) ADJFinishActivity successDelegate; -@property (nonatomic, copy, readonly) ADJFinishActivity failureDelegate; /** * Create Event object with Event Token. @@ -91,7 +86,4 @@ typedef void (^ADJFinishActivity)(ADJResponseData * responseData); */ - (void) setReceipt:(NSData *)receipt transactionId:(NSString *)transactionId; -- (void) setSuccessDelegate:(ADJFinishActivity)successDelegate; -- (void) setFailureDelegate:(ADJFinishActivity)failureDelegate; - @end diff --git a/Adjust/ADJEvent.m b/Adjust/ADJEvent.m index bef08c3ad..56742249a 100644 --- a/Adjust/ADJEvent.m +++ b/Adjust/ADJEvent.m @@ -158,14 +158,6 @@ - (void) setReceipt:(NSData *)receipt transactionId:(NSString *)transactionId { _transactionId = transactionId; } -- (void) setSuccessDelegate:(ADJFinishActivity)successDelegate { - _successDelegate = successDelegate; -} - -- (void) setFailureDelegate:(ADJFinishActivity)failureDelegate { - _failureDelegate = failureDelegate; -} - - (BOOL) checkReceipt:(NSData *)receipt transactionId:(NSString *)transactionId { if ([ADJUtil isNotNull:receipt] && [ADJUtil isNull:transactionId]) { [self.logger error:@"Missing transactionId"]; diff --git a/Adjust/ADJFailureResponseData.h b/Adjust/ADJFailureResponseData.h new file mode 100644 index 000000000..135c12ad0 --- /dev/null +++ b/Adjust/ADJFailureResponseData.h @@ -0,0 +1,31 @@ +// +// ADJFailureResponseData.h +// adjust +// +// Created by Pedro Filipe on 05/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import +#import "ADJActivityKind.h" + +@interface ADJFailureResponseData : NSObject + +@property (nonatomic, copy) NSString * activityKindString; + +@property (nonatomic, copy) NSString * message; + +@property (nonatomic, copy) NSString * timeStamp; + +@property (nonatomic, copy) NSString * adid; + +@property (nonatomic, copy) NSString * eventToken; + +@property (nonatomic, assign) BOOL willRetry; + +@property (nonatomic, retain) NSDictionary *jsonResponse; + ++ (ADJFailureResponseData *)failureResponseData; +- (id)init; + +@end diff --git a/Adjust/ADJFailureResponseData.m b/Adjust/ADJFailureResponseData.m new file mode 100644 index 000000000..df63a0c31 --- /dev/null +++ b/Adjust/ADJFailureResponseData.m @@ -0,0 +1,56 @@ +// +// ADJFailureResponseData.m +// adjust +// +// Created by Pedro Filipe on 05/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import "ADJFailureResponseData.h" + +@implementation ADJFailureResponseData + ++ (ADJFailureResponseData *)failureResponseData { + return [[ADJFailureResponseData alloc] init]; +} + +- (id)init { + self = [super init]; + if (self == nil) return nil; + + return self; +} + +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone +{ + ADJFailureResponseData* copy = [[[self class] allocWithZone:zone] init]; + + if (copy) { + copy.activityKindString = [self.activityKindString copyWithZone:zone]; + copy.message = [self.message copyWithZone:zone]; + copy.timeStamp = [self.timeStamp copyWithZone:zone]; + copy.adid = [self.adid copyWithZone:zone]; + copy.eventToken = [self.eventToken copyWithZone:zone]; + copy.willRetry = self.willRetry; + copy.jsonResponse = [self.jsonResponse copyWithZone:zone]; + } + + return copy; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat: @"%@ msg:%@ time:%@ adid:%@ event:%@ retry:%@ json:%@", + self.activityKindString, + self.message, + self.timeStamp, + self.adid, + self.eventToken, + self.willRetry ? @"YES" : @"NO", + self.jsonResponse]; +} + +@end diff --git a/Adjust/ADJPackageBuilder.m b/Adjust/ADJPackageBuilder.m index 8d94306e1..5f9ee3c95 100644 --- a/Adjust/ADJPackageBuilder.m +++ b/Adjust/ADJPackageBuilder.m @@ -80,8 +80,6 @@ - (ADJActivityPackage *)buildEventPackage:(ADJEvent *) event{ eventPackage.activityKind = ADJActivityKindEvent; eventPackage.suffix = [self eventSuffix:event]; eventPackage.parameters = parameters; - eventPackage.successDelegate = event.successDelegate; - eventPackage.failureDelegate = event.failureDelegate; return eventPackage; } diff --git a/Adjust/ADJPackageHandler.h b/Adjust/ADJPackageHandler.h index edc0c3b6b..f1ffaba03 100644 --- a/Adjust/ADJPackageHandler.h +++ b/Adjust/ADJPackageHandler.h @@ -10,7 +10,7 @@ #import "ADJActivityPackage.h" #import "ADJPackageHandler.h" #import "ADJActivityHandler.h" -#import "ADJResponseDataTasks.h" +#import "ADJResponseData.h" @protocol ADJPackageHandler @@ -19,8 +19,8 @@ - (void)addPackage:(ADJActivityPackage *)package; - (void)sendFirstPackage; -- (void)sendNextPackage:(ADJResponseDataTasks *)responseDataTasks; -- (void)closeFirstPackage; +- (void)sendNextPackage:(ADJResponseData *)responseData; +- (void)closeFirstPackage:(ADJResponseData *)responseData;; - (void)pauseSending; - (void)resumeSending; diff --git a/Adjust/ADJPackageHandler.m b/Adjust/ADJPackageHandler.m index 7e6568222..be9f9345b 100644 --- a/Adjust/ADJPackageHandler.m +++ b/Adjust/ADJPackageHandler.m @@ -64,16 +64,19 @@ - (void)sendFirstPackage { }); } -- (void)sendNextPackage:(ADJResponseDataTasks *)responseDataTasks{ +- (void)sendNextPackage:(ADJResponseData *)responseData{ dispatch_async(self.internalQueue, ^{ [self sendNextInternal]; }); - [self.activityHandler finishedTracking:responseDataTasks]; + [self.activityHandler finishedTracking:responseData]; } -- (void)closeFirstPackage { +- (void)closeFirstPackage:(ADJResponseData *)responseData { dispatch_semaphore_signal(self.sendingSemaphore); + + responseData.willRetry = YES; + [self.activityHandler finishedTracking:responseData]; } - (void)pauseSending { diff --git a/Adjust/ADJRequestHandler.h b/Adjust/ADJRequestHandler.h index 46b01008f..99f0c2f34 100644 --- a/Adjust/ADJRequestHandler.h +++ b/Adjust/ADJRequestHandler.h @@ -7,7 +7,6 @@ // #import -#import "ADJRequestHandler.h" #import "ADJPackageHandler.h" @protocol ADJRequestHandler diff --git a/Adjust/ADJRequestHandler.m b/Adjust/ADJRequestHandler.m index 085e6e9b6..ee12a30f1 100644 --- a/Adjust/ADJRequestHandler.m +++ b/Adjust/ADJRequestHandler.m @@ -60,13 +60,13 @@ - (void)sendInternal:(ADJActivityPackage *)package{ prefixErrorMessage:package.failureMessage suffixErrorMessage:@"Will retry later" activityPackage:package -responseDataTasksHandler:^(ADJResponseDataTasks * responseDataTasks) { - if (responseDataTasks.responseData.jsonResponse == nil) { - [self.packageHandler closeFirstPackage]; + responseDataHandler:^(ADJResponseData * responseData) { + if (responseData.jsonResponse == nil) { + [self.packageHandler closeFirstPackage:responseData]; return; } - [self.packageHandler sendNextPackage:responseDataTasks]; + [self.packageHandler sendNextPackage:responseData]; }]; } diff --git a/Adjust/ADJResponseData.h b/Adjust/ADJResponseData.h index 60db0a5b0..80bbd6c48 100644 --- a/Adjust/ADJResponseData.h +++ b/Adjust/ADJResponseData.h @@ -7,16 +7,35 @@ // #import +#import "ADJActivityPackage.h" +#import "ADJAttribution.h" +#import "ADJSuccessResponseData.h" +#import "ADJFailureResponseData.h" @interface ADJResponseData : NSObject -@property (nonatomic, copy) NSString *message; +@property (nonatomic, assign) ADJActivityKind activityKind; -@property (nonatomic, copy) NSString *timeStamp; +@property (nonatomic, copy) NSString * message; + +@property (nonatomic, copy) NSString * timeStamp; + +@property (nonatomic, copy) NSString * adid; + +@property (nonatomic, copy) NSString * eventToken; + +@property (nonatomic, assign) BOOL success; + +@property (nonatomic, assign) BOOL willRetry; @property (nonatomic, retain) NSDictionary *jsonResponse; -+ (ADJResponseData *)responseData; -- (id)init; +@property (nonatomic, copy) ADJAttribution *attribution; + ++ (ADJResponseData *)responseDataWithActivityPackage:(ADJActivityPackage *)activityPackage; +- (id)initWithActivityPackage:(ADJActivityPackage *)activityPackage; + +- (ADJSuccessResponseData *)successResponseData; +- (ADJFailureResponseData *)failureResponseData; @end diff --git a/Adjust/ADJResponseData.m b/Adjust/ADJResponseData.m index 81e2c8d81..9f3785c33 100644 --- a/Adjust/ADJResponseData.m +++ b/Adjust/ADJResponseData.m @@ -7,17 +7,21 @@ // #import "ADJResponseData.h" +#import "ADJActivityKind.h" @implementation ADJResponseData -+ (ADJResponseData *)responseData { - return [[ADJResponseData alloc] init]; ++ (ADJResponseData *)responseDataWithActivityPackage:(ADJActivityPackage *)activityPackage { + return [[ADJResponseData alloc] initWithActivityPackage:activityPackage]; } -- (id)init { +- (id)initWithActivityPackage:(ADJActivityPackage *)activityPackage { self = [super init]; if (self == nil) return nil; + self.activityKind = activityPackage.activityKind; + self.eventToken = [activityPackage.parameters objectForKey:@"event_token"]; + return self; } @@ -26,6 +30,31 @@ - (NSString *)description { self.message, self.timeStamp, self.jsonResponse]; } +- (ADJSuccessResponseData *)successResponseData { + ADJSuccessResponseData * successResponseData = [ADJSuccessResponseData successResponseData]; + successResponseData.activityKindString = [ADJActivityKindUtil activityKindToString:self.activityKind]; + successResponseData.message = self.message; + successResponseData.timeStamp = self.timeStamp; + successResponseData.adid = self.adid; + successResponseData.eventToken = self.eventToken; + successResponseData.jsonResponse = self.jsonResponse; + + return successResponseData; +} + +- (ADJFailureResponseData *)failureResponseData { + ADJFailureResponseData * failureResponseData = [ADJFailureResponseData failureResponseData]; + failureResponseData.activityKindString = [ADJActivityKindUtil activityKindToString:self.activityKind]; + failureResponseData.message = self.message; + failureResponseData.timeStamp = self.timeStamp; + failureResponseData.adid = self.adid; + failureResponseData.eventToken = self.eventToken; + failureResponseData.willRetry = self.willRetry; + failureResponseData.jsonResponse = self.jsonResponse; + + return failureResponseData; +} + #pragma mark - NSCopying -(id)copyWithZone:(NSZone *)zone @@ -33,9 +62,15 @@ -(id)copyWithZone:(NSZone *)zone ADJResponseData* copy = [[[self class] allocWithZone:zone] init]; if (copy) { + copy.activityKind = self.activityKind; copy.message = [self.message copyWithZone:zone]; copy.timeStamp = [self.timeStamp copyWithZone:zone]; + copy.adid = [self.adid copyWithZone:zone]; + copy.eventToken = [self.eventToken copyWithZone:zone]; + copy.success = self.success; + copy.willRetry = self.willRetry; copy.jsonResponse = [self.jsonResponse copyWithZone:zone]; + copy.attribution = [self.attribution copyWithZone:zone]; } return copy; diff --git a/Adjust/ADJResponseDataTasks.h b/Adjust/ADJResponseDataTasks.h deleted file mode 100644 index 58a6b0369..000000000 --- a/Adjust/ADJResponseDataTasks.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// ADJResponseDataTasks.h -// adjust -// -// Created by Pedro Filipe on 08/12/15. -// Copyright © 2015 adjust GmbH. All rights reserved. -// - -#import -#import "ADJResponseData.h" -#import "ADJAttribution.h" -#import "ADJEvent.h" - -@interface ADJResponseDataTasks : NSObject - -@property (nonatomic, retain) ADJResponseData * responseData; - -@property (nonatomic, copy) ADJAttribution *attribution; - -@property (nonatomic, copy) ADJFinishActivity finishDelegate; - -+ (ADJResponseDataTasks *)responseDataTasks; -- (id)init; - -@end diff --git a/Adjust/ADJResponseDataTasks.m b/Adjust/ADJResponseDataTasks.m deleted file mode 100644 index 5b32eb124..000000000 --- a/Adjust/ADJResponseDataTasks.m +++ /dev/null @@ -1,24 +0,0 @@ -// -// ADJResponseDataTasks.m -// adjust -// -// Created by Pedro Filipe on 08/12/15. -// Copyright © 2015 adjust GmbH. All rights reserved. -// - -#import "ADJResponseDataTasks.h" - -@implementation ADJResponseDataTasks - -+ (ADJResponseDataTasks *)responseDataTasks { - return [[ADJResponseDataTasks alloc] init]; -} - -- (id)init { - self = [super init]; - if (self == nil) return nil; - - return self; -} - -@end diff --git a/Adjust/ADJSuccessResponseData.h b/Adjust/ADJSuccessResponseData.h new file mode 100644 index 000000000..f3a1eb3b5 --- /dev/null +++ b/Adjust/ADJSuccessResponseData.h @@ -0,0 +1,29 @@ +// +// ADJSuccessResponseData.h +// adjust +// +// Created by Pedro Filipe on 05/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import +#import "ADJActivityKind.h" + +@interface ADJSuccessResponseData : NSObject + +@property (nonatomic, copy) NSString * activityKindString; + +@property (nonatomic, copy) NSString * message; + +@property (nonatomic, copy) NSString * timeStamp; + +@property (nonatomic, copy) NSString * adid; + +@property (nonatomic, copy) NSString * eventToken; + +@property (nonatomic, retain) NSDictionary *jsonResponse; + ++ (ADJSuccessResponseData *)successResponseData; +- (id)init; + +@end diff --git a/Adjust/ADJSuccessResponseData.m b/Adjust/ADJSuccessResponseData.m new file mode 100644 index 000000000..e82105d6b --- /dev/null +++ b/Adjust/ADJSuccessResponseData.m @@ -0,0 +1,54 @@ +// +// ADJSuccessResponseData.m +// adjust +// +// Created by Pedro Filipe on 05/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import "ADJSuccessResponseData.h" + +@implementation ADJSuccessResponseData + ++ (ADJSuccessResponseData *)successResponseData { + return [[ADJSuccessResponseData alloc] init]; +} + +- (id)init { + self = [super init]; + if (self == nil) return nil; + + return self; +} + +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone +{ + ADJSuccessResponseData* copy = [[[self class] allocWithZone:zone] init]; + + if (copy) { + copy.activityKindString = [self.activityKindString copyWithZone:zone]; + copy.message = [self.message copyWithZone:zone]; + copy.timeStamp = [self.timeStamp copyWithZone:zone]; + copy.adid = [self.adid copyWithZone:zone]; + copy.eventToken = [self.eventToken copyWithZone:zone]; + copy.jsonResponse = [self.jsonResponse copyWithZone:zone]; + } + + return copy; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat: @"%@ msg:%@ time:%@ adid:%@ event:%@ json:%@", + self.activityKindString, + self.message, + self.timeStamp, + self.adid, + self.eventToken, + self.jsonResponse]; +} + +@end diff --git a/Adjust/ADJUtil.h b/Adjust/ADJUtil.h index 635b51588..3577d4cd2 100644 --- a/Adjust/ADJUtil.h +++ b/Adjust/ADJUtil.h @@ -7,7 +7,7 @@ // #import #import "ADJActivityKind.h" -#import "ADJResponseDataTasks.h" +#import "ADJResponseData.h" #import "ADJActivityPackage.h" #import "ADJEvent.h" @@ -38,13 +38,13 @@ + (void)sendRequest:(NSMutableURLRequest *)request prefixErrorMessage:(NSString *)prefixErrorMessage activityPackage:(ADJActivityPackage *)activityPackage -responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler; +responseDataHandler:(void (^) (ADJResponseData * responseData))responseDataHandler; + (void)sendRequest:(NSMutableURLRequest *)request prefixErrorMessage:(NSString *)prefixErrorMessage suffixErrorMessage:(NSString *)suffixErrorMessage activityPackage:(ADJActivityPackage *)activityPackage -responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler; +responseDataHandler:(void (^) (ADJResponseData * responseData))responseDataHandler; + (NSDictionary *)convertDictionaryValues:(NSDictionary *)dictionary; diff --git a/Adjust/ADJUtil.m b/Adjust/ADJUtil.m index 4eab3c30c..28bc7b894 100644 --- a/Adjust/ADJUtil.m +++ b/Adjust/ADJUtil.m @@ -12,7 +12,7 @@ #import "ADJAdjustFactory.h" #import "NSString+ADJAdditions.h" #import "ADJAdjustFactory.h" -#import "ADJResponseDataTasks.h" +#import "ADJResponseData.h" #include @@ -230,20 +230,20 @@ + (NSString *)formatErrorMessage:(NSString *)prefixErrorMessage + (void)sendRequest:(NSMutableURLRequest *)request prefixErrorMessage:(NSString *)prefixErrorMessage activityPackage:(ADJActivityPackage *)activityPackage -responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler +responseDataHandler:(void (^) (ADJResponseData * responseData))responseDataHandler { [ADJUtil sendRequest:request prefixErrorMessage:prefixErrorMessage suffixErrorMessage:nil activityPackage:activityPackage -responseDataTasksHandler:responseDataTasksHandler]; + responseDataHandler:responseDataHandler]; } + (void)sendRequest:(NSMutableURLRequest *)request prefixErrorMessage:(NSString *)prefixErrorMessage suffixErrorMessage:(NSString *)suffixErrorMessage activityPackage:(ADJActivityPackage *)activityPackage -responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler +responseDataHandler:(void (^) (ADJResponseData * responseData))responseDataHandler { Class NSURLSessionClass = NSClassFromString(@"NSURLSession"); if (NSURLSessionClass != nil) { @@ -251,13 +251,13 @@ + (void)sendRequest:(NSMutableURLRequest *)request prefixErrorMessage:prefixErrorMessage suffixErrorMessage:suffixErrorMessage activityPackage:activityPackage - responseDataTasksHandler:responseDataTasksHandler]; + responseDataHandler:responseDataHandler]; } else { [ADJUtil sendNSURLConnectionRequest:request prefixErrorMessage:prefixErrorMessage suffixErrorMessage:suffixErrorMessage activityPackage:activityPackage - responseDataTasksHandler:responseDataTasksHandler]; + responseDataHandler:responseDataHandler]; } } @@ -265,20 +265,20 @@ + (void)sendNSURLSessionRequest:(NSMutableURLRequest *)request prefixErrorMessage:(NSString *)prefixErrorMessage suffixErrorMessage:(NSString *)suffixErrorMessage activityPackage:(ADJActivityPackage *)activityPackage - responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler + responseDataHandler:(void (^) (ADJResponseData * responseData))responseDataHandler { NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) { - ADJResponseDataTasks * responseDataTasks = [ADJUtil completionHandler:data - response:(NSHTTPURLResponse *)response - error:error - prefixErrorMessage:prefixErrorMessage - suffixErrorMessage:suffixErrorMessage - activityPackage:activityPackage]; - responseDataTasksHandler(responseDataTasks); + ADJResponseData * responseData = [ADJUtil completionHandler:data + response:(NSHTTPURLResponse *)response + error:error + prefixErrorMessage:prefixErrorMessage + suffixErrorMessage:suffixErrorMessage + activityPackage:activityPackage]; + responseDataHandler(responseData); }]; [task resume]; } @@ -287,7 +287,7 @@ + (void)sendNSURLConnectionRequest:(NSMutableURLRequest *)request prefixErrorMessage:(NSString *)prefixErrorMessage suffixErrorMessage:(NSString *)suffixErrorMessage activityPackage:(ADJActivityPackage *)activityPackage - responseDataTasksHandler:(void (^) (ADJResponseDataTasks * responseDataTasks))responseDataTasksHandler + responseDataHandler:(void (^) (ADJResponseData * responseData))responseDataHandler { NSError *responseError = nil; NSHTTPURLResponse *urlResponse = nil; @@ -299,39 +299,41 @@ + (void)sendNSURLConnectionRequest:(NSMutableURLRequest *)request error:&responseError]; #pragma clang diagnostic pop - ADJResponseDataTasks * responseDataTasks = [ADJUtil completionHandler:data - response:(NSHTTPURLResponse *)urlResponse - error:responseError - prefixErrorMessage:prefixErrorMessage - suffixErrorMessage:suffixErrorMessage - activityPackage:activityPackage]; + ADJResponseData * responseData = [ADJUtil completionHandler:data + response:(NSHTTPURLResponse *)urlResponse + error:responseError + prefixErrorMessage:prefixErrorMessage + suffixErrorMessage:suffixErrorMessage + activityPackage:activityPackage]; - responseDataTasksHandler(responseDataTasks); + responseDataHandler(responseData); } -+ (ADJResponseDataTasks *)completionHandler:(NSData *)data - response:(NSHTTPURLResponse *)urlResponse - error:(NSError *)responseError - prefixErrorMessage:(NSString *)prefixErrorMessage - suffixErrorMessage:(NSString *)suffixErrorMessage - activityPackage:(ADJActivityPackage *)activityPackage ++ (ADJResponseData *)completionHandler:(NSData *)data + response:(NSHTTPURLResponse *)urlResponse + error:(NSError *)responseError + prefixErrorMessage:(NSString *)prefixErrorMessage + suffixErrorMessage:(NSString *)suffixErrorMessage + activityPackage:(ADJActivityPackage *)activityPackage { - ADJResponseDataTasks * responseDataTasks = [ADJResponseDataTasks responseDataTasks]; - responseDataTasks.responseData = [ADJResponseData responseData]; - responseDataTasks.finishDelegate = activityPackage.failureDelegate; + ADJResponseData * responseData = [ADJResponseData responseDataWithActivityPackage:activityPackage]; // connection error if (responseError != nil) { - [ADJAdjustFactory.logger error:[ADJUtil formatErrorMessage:prefixErrorMessage - systemErrorMessage:responseError.localizedDescription - suffixErrorMessage:suffixErrorMessage]]; - return responseDataTasks; + NSString * errorMessage = [ADJUtil formatErrorMessage:prefixErrorMessage + systemErrorMessage:responseError.localizedDescription + suffixErrorMessage:suffixErrorMessage]; + [ADJAdjustFactory.logger error:errorMessage]; + responseData.message = errorMessage; + return responseData; } if ([ADJUtil isNull:data]) { - [ADJAdjustFactory.logger error:[ADJUtil formatErrorMessage:prefixErrorMessage - systemErrorMessage:@"empty error" - suffixErrorMessage:suffixErrorMessage]]; - return responseDataTasks; + NSString * errorMessage = [ADJUtil formatErrorMessage:prefixErrorMessage + systemErrorMessage:@"empty error" + suffixErrorMessage:suffixErrorMessage]; + [ADJAdjustFactory.logger error:errorMessage]; + responseData.message = errorMessage; + return responseData; } NSString *responseString = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] adjTrim]; @@ -339,16 +341,17 @@ + (ADJResponseDataTasks *)completionHandler:(NSData *)data [ADJAdjustFactory.logger verbose:@"Response: %@", responseString]; - [ADJUtil buildJsonDict:data responseData:responseDataTasks.responseData]; + [ADJUtil buildJsonDict:data responseData:responseData]; - if ([ADJUtil isNull:responseDataTasks.responseData.jsonResponse]) { - return responseDataTasks; + if ([ADJUtil isNull:responseData.jsonResponse]) { + return responseData; } - NSString* messageResponse = [responseDataTasks.responseData.jsonResponse objectForKey:@"message"]; + NSString* messageResponse = [responseData.jsonResponse objectForKey:@"message"]; - responseDataTasks.responseData.message = messageResponse; - responseDataTasks.responseData.timeStamp = [responseDataTasks.responseData.jsonResponse objectForKey:@"timestamp"]; + responseData.message = messageResponse; + responseData.timeStamp = [responseData.jsonResponse objectForKey:@"timestamp"]; + responseData.adid = [responseData.jsonResponse objectForKey:@"adid"]; if (messageResponse == nil) { messageResponse = @"No message found"; @@ -356,12 +359,12 @@ + (ADJResponseDataTasks *)completionHandler:(NSData *)data if (statusCode == 200) { [ADJAdjustFactory.logger info:@"%@", messageResponse]; - responseDataTasks.finishDelegate = activityPackage.successDelegate; + responseData.success = YES; } else { [ADJAdjustFactory.logger error:@"%@", messageResponse]; } - return responseDataTasks; + return responseData; } // convert all values to strings, if value is dictionary -> recursive call diff --git a/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj b/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj index 838b111ad..bd563e135 100644 --- a/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj +++ b/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj @@ -35,8 +35,9 @@ 963909A61BCBFF8D00A2E8A4 /* ADJTimerOnce.m in Sources */ = {isa = PBXBuildFile; fileRef = 9639098F1BCBFF8D00A2E8A4 /* ADJTimerOnce.m */; }; 963909A71BCBFF8D00A2E8A4 /* Adjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909911BCBFF8D00A2E8A4 /* Adjust.m */; }; 963909A81BCBFF8D00A2E8A4 /* ADJUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909931BCBFF8D00A2E8A4 /* ADJUtil.m */; }; + 96BA940B1C3D57FD00C96245 /* ADJFailureResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA94091C3D57FD00C96245 /* ADJFailureResponseData.m */; }; + 96BA940C1C3D57FD00C96245 /* ADJSuccessResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA940A1C3D57FD00C96245 /* ADJSuccessResponseData.m */; }; 96FCC5441C18643E007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5411C18643E007BBFE1 /* ADJResponseData.m */; }; - 96FCC5451C18643E007BBFE1 /* ADJResponseDataTasks.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5431C18643E007BBFE1 /* ADJResponseDataTasks.m */; }; 9DAC2DEB1C0F611300AC9D97 /* URLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DAC2DEA1C0F611300AC9D97 /* URLRequest.m */; }; 9DC95F261C104CEF00138E4B /* ViewControlleriOS.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F251C104CEF00138E4B /* ViewControlleriOS.m */; }; 9DC95F2A1C10515300138E4B /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F291C10515300138E4B /* Constants.m */; }; @@ -95,10 +96,12 @@ 963909911BCBFF8D00A2E8A4 /* Adjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Adjust.m; sourceTree = ""; }; 963909921BCBFF8D00A2E8A4 /* ADJUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJUtil.h; sourceTree = ""; }; 963909931BCBFF8D00A2E8A4 /* ADJUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJUtil.m; sourceTree = ""; }; + 96BA94071C3D57FD00C96245 /* ADJSuccessResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSuccessResponseData.h; sourceTree = ""; }; + 96BA94081C3D57FD00C96245 /* ADJFailureResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJFailureResponseData.h; sourceTree = ""; }; + 96BA94091C3D57FD00C96245 /* ADJFailureResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJFailureResponseData.m; sourceTree = ""; }; + 96BA940A1C3D57FD00C96245 /* ADJSuccessResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSuccessResponseData.m; sourceTree = ""; }; 96FCC5401C18643E007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseData.h; sourceTree = ""; }; 96FCC5411C18643E007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseData.m; sourceTree = ""; }; - 96FCC5421C18643E007BBFE1 /* ADJResponseDataTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseDataTasks.h; sourceTree = ""; }; - 96FCC5431C18643E007BBFE1 /* ADJResponseDataTasks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseDataTasks.m; sourceTree = ""; }; 9DAC2DE91C0F611300AC9D97 /* URLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLRequest.h; sourceTree = ""; }; 9DAC2DEA1C0F611300AC9D97 /* URLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = URLRequest.m; sourceTree = ""; }; 9DC95F241C104CEF00138E4B /* ViewControlleriOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewControlleriOS.h; sourceTree = ""; }; @@ -170,10 +173,12 @@ 963909681BCBFF8D00A2E8A4 /* Adjust */ = { isa = PBXGroup; children = ( + 96BA94071C3D57FD00C96245 /* ADJSuccessResponseData.h */, + 96BA94081C3D57FD00C96245 /* ADJFailureResponseData.h */, + 96BA94091C3D57FD00C96245 /* ADJFailureResponseData.m */, + 96BA940A1C3D57FD00C96245 /* ADJSuccessResponseData.m */, 96FCC5401C18643E007BBFE1 /* ADJResponseData.h */, 96FCC5411C18643E007BBFE1 /* ADJResponseData.m */, - 96FCC5421C18643E007BBFE1 /* ADJResponseDataTasks.h */, - 96FCC5431C18643E007BBFE1 /* ADJResponseDataTasks.m */, 963909691BCBFF8D00A2E8A4 /* ADJActivityHandler.h */, 9639096A1BCBFF8D00A2E8A4 /* ADJActivityHandler.m */, 9639096B1BCBFF8D00A2E8A4 /* ADJActivityKind.h */, @@ -302,6 +307,7 @@ 9639099F1BCBFF8D00A2E8A4 /* ADJDeviceInfo.m in Sources */, 963909A81BCBFF8D00A2E8A4 /* ADJUtil.m in Sources */, 9DAC2DEB1C0F611300AC9D97 /* URLRequest.m in Sources */, + 96BA940B1C3D57FD00C96245 /* ADJFailureResponseData.m in Sources */, 9639099D1BCBFF8D00A2E8A4 /* ADJAttributionHandler.m in Sources */, 963909A21BCBFF8D00A2E8A4 /* ADJPackageBuilder.m in Sources */, 963909A51BCBFF8D00A2E8A4 /* ADJTimerCycle.m in Sources */, @@ -310,11 +316,11 @@ 963909951BCBFF8D00A2E8A4 /* ADJActivityKind.m in Sources */, 9639099A1BCBFF8D00A2E8A4 /* UIDevice+ADJAdditions.m in Sources */, 963909971BCBFF8D00A2E8A4 /* ADJActivityState.m in Sources */, + 96BA940C1C3D57FD00C96245 /* ADJSuccessResponseData.m in Sources */, 963909A11BCBFF8D00A2E8A4 /* ADJLogger.m in Sources */, 963909961BCBFF8D00A2E8A4 /* ADJActivityPackage.m in Sources */, 96FCC5441C18643E007BBFE1 /* ADJResponseData.m in Sources */, 963909A01BCBFF8D00A2E8A4 /* ADJEvent.m in Sources */, - 96FCC5451C18643E007BBFE1 /* ADJResponseDataTasks.m in Sources */, 963909A31BCBFF8D00A2E8A4 /* ADJPackageHandler.m in Sources */, 963909981BCBFF8D00A2E8A4 /* NSData+ADJAdditions.m in Sources */, 963909A41BCBFF8D00A2E8A4 /* ADJRequestHandler.m in Sources */, diff --git a/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj b/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj index 65b0aa2d2..c8187e027 100644 --- a/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj +++ b/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj @@ -34,8 +34,9 @@ 96390A0F1BCC0DF100A2E8A4 /* ADJTimerOnce.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909F81BCC0DF100A2E8A4 /* ADJTimerOnce.m */; }; 96390A101BCC0DF100A2E8A4 /* Adjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909FA1BCC0DF100A2E8A4 /* Adjust.m */; }; 96390A111BCC0DF100A2E8A4 /* ADJUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909FC1BCC0DF100A2E8A4 /* ADJUtil.m */; }; + 96BA94051C3D57ED00C96245 /* ADJFailureResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA94031C3D57ED00C96245 /* ADJFailureResponseData.m */; }; + 96BA94061C3D57ED00C96245 /* ADJSuccessResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA94041C3D57ED00C96245 /* ADJSuccessResponseData.m */; }; 96FCC54A1C186458007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5471C186458007BBFE1 /* ADJResponseData.m */; }; - 96FCC54B1C186458007BBFE1 /* ADJResponseDataTasks.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5491C186458007BBFE1 /* ADJResponseDataTasks.m */; }; 9DC95F2F1C10596500138E4B /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F2E1C10596500138E4B /* Constants.m */; }; 9DC95F321C105B4C00138E4B /* URLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F311C105B4C00138E4B /* URLRequest.m */; }; /* End PBXBuildFile section */ @@ -93,10 +94,12 @@ 963909FA1BCC0DF100A2E8A4 /* Adjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Adjust.m; sourceTree = ""; }; 963909FB1BCC0DF100A2E8A4 /* ADJUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJUtil.h; sourceTree = ""; }; 963909FC1BCC0DF100A2E8A4 /* ADJUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJUtil.m; sourceTree = ""; }; + 96BA94011C3D57ED00C96245 /* ADJSuccessResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSuccessResponseData.h; sourceTree = ""; }; + 96BA94021C3D57ED00C96245 /* ADJFailureResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJFailureResponseData.h; sourceTree = ""; }; + 96BA94031C3D57ED00C96245 /* ADJFailureResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJFailureResponseData.m; sourceTree = ""; }; + 96BA94041C3D57ED00C96245 /* ADJSuccessResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSuccessResponseData.m; sourceTree = ""; }; 96FCC5461C186458007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseData.h; sourceTree = ""; }; 96FCC5471C186458007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseData.m; sourceTree = ""; }; - 96FCC5481C186458007BBFE1 /* ADJResponseDataTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseDataTasks.h; sourceTree = ""; }; - 96FCC5491C186458007BBFE1 /* ADJResponseDataTasks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseDataTasks.m; sourceTree = ""; }; 9DC95F2D1C10596500138E4B /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = ""; }; 9DC95F2E1C10596500138E4B /* Constants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = ""; }; 9DC95F301C105B4C00138E4B /* URLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLRequest.h; sourceTree = ""; }; @@ -163,10 +166,12 @@ 963909D11BCC0DF100A2E8A4 /* Adjust */ = { isa = PBXGroup; children = ( + 96BA94011C3D57ED00C96245 /* ADJSuccessResponseData.h */, + 96BA94021C3D57ED00C96245 /* ADJFailureResponseData.h */, + 96BA94031C3D57ED00C96245 /* ADJFailureResponseData.m */, + 96BA94041C3D57ED00C96245 /* ADJSuccessResponseData.m */, 96FCC5461C186458007BBFE1 /* ADJResponseData.h */, 96FCC5471C186458007BBFE1 /* ADJResponseData.m */, - 96FCC5481C186458007BBFE1 /* ADJResponseDataTasks.h */, - 96FCC5491C186458007BBFE1 /* ADJResponseDataTasks.m */, 963909D21BCC0DF100A2E8A4 /* ADJActivityHandler.h */, 963909D31BCC0DF100A2E8A4 /* ADJActivityHandler.m */, 963909D41BCC0DF100A2E8A4 /* ADJActivityKind.h */, @@ -294,6 +299,7 @@ 96390A081BCC0DF100A2E8A4 /* ADJDeviceInfo.m in Sources */, 96390A111BCC0DF100A2E8A4 /* ADJUtil.m in Sources */, 96390A061BCC0DF100A2E8A4 /* ADJAttributionHandler.m in Sources */, + 96BA94051C3D57ED00C96245 /* ADJFailureResponseData.m in Sources */, 96390A0B1BCC0DF100A2E8A4 /* ADJPackageBuilder.m in Sources */, 96390A0E1BCC0DF100A2E8A4 /* ADJTimerCycle.m in Sources */, 9DC95F2F1C10596500138E4B /* Constants.m in Sources */, @@ -302,11 +308,11 @@ 96390A031BCC0DF100A2E8A4 /* UIDevice+ADJAdditions.m in Sources */, 96390A001BCC0DF100A2E8A4 /* ADJActivityState.m in Sources */, 96390A0A1BCC0DF100A2E8A4 /* ADJLogger.m in Sources */, + 96BA94061C3D57ED00C96245 /* ADJSuccessResponseData.m in Sources */, 963909FF1BCC0DF100A2E8A4 /* ADJActivityPackage.m in Sources */, 96390A091BCC0DF100A2E8A4 /* ADJEvent.m in Sources */, 96FCC54A1C186458007BBFE1 /* ADJResponseData.m in Sources */, 963909BD1BCC0D8300A2E8A4 /* ViewControllertvOS.m in Sources */, - 96FCC54B1C186458007BBFE1 /* ADJResponseDataTasks.m in Sources */, 96390A0C1BCC0DF100A2E8A4 /* ADJPackageHandler.m in Sources */, 96390A011BCC0DF100A2E8A4 /* NSData+ADJAdditions.m in Sources */, 96390A0D1BCC0DF100A2E8A4 /* ADJRequestHandler.m in Sources */, From 66a00d082c0d68a465d791473ccad1a3c88fa3a7 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 6 Jan 2016 15:51:34 +0100 Subject: [PATCH 07/33] Update example app --- .../AdjustExample-iOS/AppDelegate.m | 10 +++++++ .../AdjustExample-tvOS/AppDelegate.m | 27 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m b/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m index f0dad7e39..49e5b05d3 100644 --- a/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m +++ b/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m @@ -36,6 +36,16 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // set an attribution delegate [adjustConfig setDelegate:self]; + // set finished success tracking delegate + [adjustConfig setSuccessDelegate:^(ADJSuccessResponseData *successResponseData) { + NSLog(@"adjust successResponseData %@", successResponseData); + }]; + + // set finished failure tracking delegate + [adjustConfig setFailureDelegate:^(ADJFailureResponseData *failureResponseData) { + NSLog(@"adjust failureResponseData %@", failureResponseData); + }]; + [Adjust appDidLaunch:adjustConfig]; // put the SDK in offline mode diff --git a/examples/AdjustExample-tvOS/AdjustExample-tvOS/AppDelegate.m b/examples/AdjustExample-tvOS/AdjustExample-tvOS/AppDelegate.m index 59e7c62a0..825e5940d 100644 --- a/examples/AdjustExample-tvOS/AdjustExample-tvOS/AppDelegate.m +++ b/examples/AdjustExample-tvOS/AdjustExample-tvOS/AppDelegate.m @@ -22,15 +22,42 @@ - (void)adjustAttributionChanged:(ADJAttribution *)attribution { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. + + // configure adjust NSString *yourAppToken = kAppToken; NSString *environment = ADJEnvironmentSandbox; ADJConfig *adjustConfig = [ADJConfig configWithAppToken:yourAppToken environment:environment]; + // change the log level [adjustConfig setLogLevel:ADJLogLevelVerbose]; + + // enable event buffering + //[adjustConfig setEventBufferingEnabled:YES]; + + // set default tracker + //[adjustConfig setDefaultTracker:@"{TrackerToken}"]; + + // set an attribution delegate [adjustConfig setDelegate:self]; + // set finished success tracking delegate + [adjustConfig setSuccessDelegate:^(ADJSuccessResponseData *successResponseData) { + NSLog(@"adjust successResponseData %@", successResponseData); + }]; + + // set finished failure tracking delegate + [adjustConfig setFailureDelegate:^(ADJFailureResponseData *failureResponseData) { + NSLog(@"adjust failureResponseData %@", failureResponseData); + }]; + [Adjust appDidLaunch:adjustConfig]; + // put the SDK in offline mode + //[Adjust setOfflineMode:YES]; + + // disable the SDK + //[Adjust setEnabled:NO]; + return YES; } From b33b837274d2db462c7668155db5358309f96f68 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 6 Jan 2016 17:13:48 +0100 Subject: [PATCH 08/33] Save non-copied delegates --- Adjust/ADJActivityHandler.m | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index aad8591b5..9efd5c2d0 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -37,6 +37,8 @@ @interface ADJActivityHandler() @property (nonatomic, retain) ADJTimerCycle *timer; @property (nonatomic, retain) id logger; @property (nonatomic, weak) NSObject *attributionChangedDelegate; +@property (nonatomic, copy) ADJTrackingSucceeded successDelegate; +@property (nonatomic, copy) ADJTrackingFailed failureDelegate; @property (nonatomic, copy) ADJAttribution *attribution; @property (nonatomic, copy) ADJConfig *adjustConfig; @@ -77,6 +79,8 @@ - (id)initWithConfig:(ADJConfig *)adjustConfig { self.adjustConfig = adjustConfig; self.attributionChangedDelegate = adjustConfig.delegate; + self.successDelegate = adjustConfig.successDelegate; + self.failureDelegate = adjustConfig.failureDelegate; self.logger = ADJAdjustFactory.logger; [self addNotificationObserver]; @@ -111,7 +115,7 @@ - (void)trackEvent:(ADJEvent *)event - (void)finishedTracking:(ADJResponseData *)responseData { // no response json to check for attributes and no callback for failed package - if ([ADJUtil isNull:responseData.jsonResponse] && [ADJUtil isNull:self.adjustConfig.failureDelegate]) { + if ([ADJUtil isNull:responseData.jsonResponse] && [ADJUtil isNull:self.failureDelegate]) { return; } // callback for failed package is present @@ -522,19 +526,19 @@ - (void) launchFinishedDelegate:(ADJResponseData *)responseData { return; } // no success callback - if (responseData.success && [ADJUtil isNull:self.adjustConfig.successDelegate]) { + if (responseData.success && [ADJUtil isNull:self.successDelegate]) { return; } // no failure callback - if (!responseData.success && [ADJUtil isNull:self.adjustConfig.failureDelegate]) { + if (!responseData.success && [ADJUtil isNull:self.failureDelegate]) { return; } // add it to the handler queue dispatch_sync(dispatch_get_main_queue(), ^{ if (responseData.success) { - self.adjustConfig.successDelegate([responseData successResponseData]); + self.successDelegate([responseData successResponseData]); } else { - self.adjustConfig.failureDelegate([responseData failureResponseData]); + self.failureDelegate([responseData failureResponseData]); } }); } From e666217762d7a894c0b6b3a39a01d69a05fe9e99 Mon Sep 17 00:00:00 2001 From: Pedro Filipe Date: Wed, 6 Jan 2016 17:26:44 +0100 Subject: [PATCH 09/33] Update README.md --- README.md | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fd9997223..0adae9f4c 100644 --- a/README.md +++ b/README.md @@ -441,7 +441,38 @@ Here is a quick summary of its properties: - `NSString creative` the creative grouping level of the current install. - `NSString clickLabel` the click label of the current install. -### 10. Disable tracking +### 10. Set block callbacks for tracked events and sessions + +You can register blocks to be callback when events and sessions are tracked. +There is a block callback for when the event or session is correctly tracked, and a block callback for when there was some type of failure. +You can add any or both of the block callback after creating the `ADJConfig` object: + +```objc +ADJConfig *adjustConfig = [ADJConfig configWithAppToken:yourAppToken environment:environment]; + +[adjustConfig setSuccessDelegate:^(ADJSuccessResponseData *successResponseData) { + // ... +}]; + +[adjustConfig setFailureDelegate:^(ADJFailureResponseData *failureResponseData) { + // ... +}]; + +[Adjust appDidLaunch:adjustConfig]; +``` + +The block callback will be called after the SDK tries to send a package to the server. Within the block callback you have access to the `successResponseData` or `failureResponseData` object. Here is a quick summary of its common properties: + +- `NSString activityKindString` the type of package send, either `"event"` or `"session"`. +- `NSString message` the message from the server or the error logged by the SDK. +- `NSString timestamp` timestamp from the server. +- `NSString adid` a unique device identifier provided by adjust. +- `NSString eventToken` the event token, if the package tracked was an event. +- `NSDictionary jsonResponse` the json object with the reponse from the server. + +The extra parameter in `failureResponseData` is currently only `BOOL willRetry` and it indicates whether the package will try to be send again to the server. + +### 11. Disable tracking You can disable the adjust SDK from tracking any activities of the current device by calling `setEnabled` with parameter `NO`. This setting is remembered @@ -455,7 +486,7 @@ You can check if the adjust SDK is currently enabled by calling the function `isEnabled`. It is always possible to activate the adjust SDK by invoking `setEnabled` with the enabled parameter as `YES`. -### 11. Offline mode +### 12. Offline mode You can put the adjust SDK in offline mode to suspend transmission to our servers while retaining tracked data to be sent later. While in offline mode, all information is saved @@ -475,7 +506,7 @@ Unlike disabling tracking, this setting is *not remembered* bettween sessions. This means that the SDK is in online mode whenever it is started, even if the app was terminated in offline mode. -### 12. Partner parameters +### 13. Partner parameters You can also add parameters to be transmitted to network partners, for the integrations that have been activated in your adjust dashboard. @@ -493,7 +524,7 @@ ADJEvent *event = [ADJEvent eventWithEventToken:@"abc123"]; You can read more about special partners and these integrations in our [guide to special partners.][special-partners] -### 13. Device IDS +### 14. Device IDS Certain services (such as Google Analytics) require you to coordinate Device and Client IDs in order to prevent duplicate reporting. @@ -503,7 +534,7 @@ To obtain the device identifier IDFA, call the function `idfa`: NSString * idfa = [Adjust idfa]; ``` -### 14. Push token +### 15. Push token To send us the push notification token, then add the following call to `Adjust` in the `didRegisterForRemoteNotificationsWithDeviceToken` of your app delegate: From e727bba02d987b354739e02adcfc926842c80243 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 7 Jan 2016 14:07:49 +0100 Subject: [PATCH 10/33] Refactor json parsing --- Adjust/ADJUtil.h | 5 +++-- Adjust/ADJUtil.m | 38 +++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Adjust/ADJUtil.h b/Adjust/ADJUtil.h index 3577d4cd2..7f048ef22 100644 --- a/Adjust/ADJUtil.h +++ b/Adjust/ADJUtil.h @@ -19,8 +19,9 @@ + (void)excludeFromBackup:(NSString *)filename; + (NSString *)formatSeconds1970:(double)value; + (NSString *)formatDate:(NSDate *)value; -+ (void) buildJsonDict:(NSData *)jsonData - responseData:(ADJResponseData *)responseData; ++ (NSDictionary *) buildJsonDict:(NSData *)jsonData + exceptionPtr:(NSException **)exceptionPtr + errorPtr:(NSError **)error; + (NSString *)getFullFilename:(NSString *) baseFilename; diff --git a/Adjust/ADJUtil.m b/Adjust/ADJUtil.m index 28bc7b894..276c305fe 100644 --- a/Adjust/ADJUtil.m +++ b/Adjust/ADJUtil.m @@ -114,18 +114,16 @@ + (NSString *)formatDate:(NSDate *) value { return [dateFormat stringFromDate:value]; } -+ (void) buildJsonDict:(NSData *)jsonData - responseData:(ADJResponseData *)responseData ++ (void) saveJsonResponse:(NSData *)jsonData + responseData:(ADJResponseData *)responseData { - if (jsonData == nil) { - return; - } NSError *error = nil; - NSDictionary *jsonDict = nil; - @try { - jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; - } @catch (NSException *ex) { - NSString * message = [NSString stringWithFormat:@"Failed to parse json response. (%@)", ex.description]; + NSException *exception = nil; + + NSDictionary *jsonDict = [ADJUtil buildJsonDict:jsonData exceptionPtr:&exception errorPtr:&error]; + + if (exception != nil) { + NSString * message = [NSString stringWithFormat:@"Failed to parse json response. (%@)", exception.description]; [ADJAdjustFactory.logger error:message]; responseData.message = message; return; @@ -141,6 +139,24 @@ + (void) buildJsonDict:(NSData *)jsonData responseData.jsonResponse = jsonDict; } ++ (NSDictionary *) buildJsonDict:(NSData *)jsonData + exceptionPtr:(NSException **)exceptionPtr + errorPtr:(NSError **)error +{ + if (jsonData == nil) { + return nil; + } + NSDictionary *jsonDict = nil; + @try { + jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:error]; + } @catch (NSException *ex) { + *exceptionPtr = ex; + return nil; + } + + return jsonDict; +} + + (NSString *)getFullFilename:(NSString *) baseFilename { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [paths objectAtIndex:0]; @@ -341,7 +357,7 @@ + (ADJResponseData *)completionHandler:(NSData *)data [ADJAdjustFactory.logger verbose:@"Response: %@", responseString]; - [ADJUtil buildJsonDict:data responseData:responseData]; + [ADJUtil saveJsonResponse:data responseData:responseData]; if ([ADJUtil isNull:responseData.jsonResponse]) { return responseData; From 514b7863a081d84a5159f61bffb3c60778a1eac3 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 20 Jan 2016 13:27:31 +0100 Subject: [PATCH 11/33] Refactor conditionals --- Adjust/ADJActivityHandler.m | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index 9efd5c2d0..d4f14b7df 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -114,13 +114,13 @@ - (void)trackEvent:(ADJEvent *)event } - (void)finishedTracking:(ADJResponseData *)responseData { - // no response json to check for attributes and no callback for failed package - if ([ADJUtil isNull:responseData.jsonResponse] && [ADJUtil isNull:self.failureDelegate]) { - return; - } - // callback for failed package is present + // no response json to check for attributes if ([ADJUtil isNull:responseData.jsonResponse]) { - [self launchResponseTasks:responseData]; + // callback for failed package is present + if (![ADJUtil isNull:self.failureDelegate]) { + [self.logger debug:@"No json with failure delegate"]; + [self launchResponseTasks:responseData]; + } return; } // attribute might be present @@ -521,26 +521,24 @@ - (void) launchResponseTasksInternal:(ADJResponseData *)responseData { } - (void) launchFinishedDelegate:(ADJResponseData *)responseData { - // no event or session package - if (responseData.activityKind != ADJActivityKindEvent && responseData.activityKind != ADJActivityKindSession) { + // no event package + if (responseData.activityKind != ADJActivityKindEvent) { return; } - // no success callback + // success callback if (responseData.success && [ADJUtil isNull:self.successDelegate]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + self.successDelegate([responseData successResponseData]); + }); return; } - // no failure callback + // failure callback if (!responseData.success && [ADJUtil isNull:self.failureDelegate]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + self.failureDelegate([responseData failureResponseData]); + }); return; } - // add it to the handler queue - dispatch_sync(dispatch_get_main_queue(), ^{ - if (responseData.success) { - self.successDelegate([responseData successResponseData]); - } else { - self.failureDelegate([responseData failureResponseData]); - } - }); } - (void) appWillOpenUrlInternal:(NSURL *)url { From 026c65431d414c1d0f1c30ce2db10ac69539c1e5 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 20 Jan 2016 16:33:50 +0100 Subject: [PATCH 12/33] Move response delegate to protocol --- Adjust/ADJActivityHandler.m | 59 +++++++++++++++++++-------------- Adjust/ADJConfig.h | 27 +++++++++------ Adjust/ADJConfig.m | 43 +++++++++++++++--------- Adjust/ADJFailureResponseData.h | 7 ++++ Adjust/ADJPackageBuilder.m | 2 +- Adjust/ADJSuccessResponseData.h | 6 ++++ 6 files changed, 94 insertions(+), 50 deletions(-) diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index d4f14b7df..2e768852e 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -36,9 +36,7 @@ @interface ADJActivityHandler() @property (nonatomic, retain) ADJActivityState *activityState; @property (nonatomic, retain) ADJTimerCycle *timer; @property (nonatomic, retain) id logger; -@property (nonatomic, weak) NSObject *attributionChangedDelegate; -@property (nonatomic, copy) ADJTrackingSucceeded successDelegate; -@property (nonatomic, copy) ADJTrackingFailed failureDelegate; +@property (nonatomic, weak) NSObject *adjustDelegate; @property (nonatomic, copy) ADJAttribution *attribution; @property (nonatomic, copy) ADJConfig *adjustConfig; @@ -78,9 +76,7 @@ - (id)initWithConfig:(ADJConfig *)adjustConfig { } self.adjustConfig = adjustConfig; - self.attributionChangedDelegate = adjustConfig.delegate; - self.successDelegate = adjustConfig.successDelegate; - self.failureDelegate = adjustConfig.failureDelegate; + self.adjustDelegate = adjustConfig.delegate; self.logger = ADJAdjustFactory.logger; [self addNotificationObserver]; @@ -116,11 +112,17 @@ - (void)trackEvent:(ADJEvent *)event - (void)finishedTracking:(ADJResponseData *)responseData { // no response json to check for attributes if ([ADJUtil isNull:responseData.jsonResponse]) { - // callback for failed package is present - if (![ADJUtil isNull:self.failureDelegate]) { - [self.logger debug:@"No json with failure delegate"]; - [self launchResponseTasks:responseData]; + if (self.adjustDelegate == nil) { + return; + } + if (![self.adjustDelegate respondsToSelector:@selector(adjustTrackingFailed:)]) { + return; } + + // callback for failed package is present + [self.logger debug:@"No json with failure delegate"]; + [self launchResponseTasks:responseData]; + return; } // attribute might be present @@ -320,11 +322,11 @@ - (SEL)updateAttribution:(ADJAttribution *)attribution { self.attribution = attribution; [self writeAttribution]; - if (self.attributionChangedDelegate == nil) { + if (self.adjustDelegate == nil) { return nil; } - if (![self.attributionChangedDelegate respondsToSelector:@selector(adjustAttributionChanged:)]) { + if (![self.adjustDelegate respondsToSelector:@selector(adjustAttributionChanged:)]) { return nil; } @@ -504,14 +506,13 @@ - (void)eventInternal:(ADJEvent *)event - (void) launchResponseTasksInternal:(ADJResponseData *)responseData { SEL updateAttributionSEL = [self updateAttribution:responseData.attribution]; - ADJAttribution * localAttributionCopy = self.attribution; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // first try to update and launch the attribution changed listener if (updateAttributionSEL != nil) { - [self.attributionChangedDelegate performSelectorOnMainThread:updateAttributionSEL - withObject:localAttributionCopy - waitUntilDone:YES]; + [self.adjustDelegate performSelectorOnMainThread:updateAttributionSEL + withObject:responseData.attribution + waitUntilDone:YES]; } // second try to launch the finished activity listener [self launchFinishedDelegate:responseData]; @@ -525,18 +526,28 @@ - (void) launchFinishedDelegate:(ADJResponseData *)responseData { if (responseData.activityKind != ADJActivityKindEvent) { return; } + + // no response delegate + if (self.adjustDelegate == nil) { + return; + } + // success callback - if (responseData.success && [ADJUtil isNull:self.successDelegate]) { - dispatch_sync(dispatch_get_main_queue(), ^{ - self.successDelegate([responseData successResponseData]); - }); + if (responseData.success + && [self.adjustDelegate respondsToSelector:@selector(adjustTrackingSucceeded:)]) + { + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustTrackingSucceeded:) + withObject:[responseData successResponseData] + waitUntilDone:YES]; return; } // failure callback - if (!responseData.success && [ADJUtil isNull:self.failureDelegate]) { - dispatch_sync(dispatch_get_main_queue(), ^{ - self.failureDelegate([responseData failureResponseData]); - }); + if (!responseData.success + && [self.adjustDelegate respondsToSelector:@selector(adjustTrackingFailed:)]) + { + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustTrackingFailed:) + withObject:[responseData failureResponseData] + waitUntilDone:YES]; return; } } diff --git a/Adjust/ADJConfig.h b/Adjust/ADJConfig.h index 140ac9b30..94de3bcd0 100644 --- a/Adjust/ADJConfig.h +++ b/Adjust/ADJConfig.h @@ -25,10 +25,21 @@ */ - (void)adjustAttributionChanged:(ADJAttribution *)attribution; -@end +/** + * Optional delegate method that gets called when an event is tracked with success + * + * @param successResponseData The response information from tracking with success. See ADJSuccessResponseData for details. + */ +- (void)adjustTrackingSucceeded:(ADJSuccessResponseData *)successResponseData; + +/** + * Optional delegate method that gets called when an event is tracked with failure + * + * @param failureResponseData The response information from tracking with failure. See ADJFailureResponseData for details. + */ +- (void)adjustTrackingFailed:(ADJFailureResponseData *)failureResponseData; -typedef void (^ADJTrackingSucceeded)(ADJSuccessResponseData * successResponseData); -typedef void (^ADJTrackingFailed)(ADJFailureResponseData * failureResponseData); +@end @interface ADJConfig : NSObject @@ -36,8 +47,6 @@ typedef void (^ADJTrackingFailed)(ADJFailureResponseData * failureResponseData); @property (nonatomic, copy, readonly) NSString *environment; @property (nonatomic, copy) NSString *sdkPrefix; @property (nonatomic, copy) NSString *defaultTracker; -@property (nonatomic, copy, readonly) ADJTrackingSucceeded successDelegate; -@property (nonatomic, copy, readonly) ADJTrackingFailed failureDelegate; /** * Configuration object for the initialization of the Adjust SDK. @@ -80,18 +89,16 @@ typedef void (^ADJTrackingFailed)(ADJFailureResponseData * failureResponseData); @property (nonatomic, assign) BOOL eventBufferingEnabled; /** - * Set the optional delegate that will inform you about attribution + * Set the optional delegate that will inform you about attribution or events * * See the AdjustDelegate declaration above for details * * @var delegate The delegate that might implement the optional delegate - * methods like adjustAttributionChanged: + * methods like adjustAttributionChanged, adjustTrackingSucceeded or adjustTrackingFailed: */ @property (nonatomic, weak) NSObject *delegate; +@property (nonatomic, assign) BOOL hasDelegate; @property (nonatomic, assign) BOOL hasAttributionChangedDelegate; -- (void) setSuccessDelegate:(ADJTrackingSucceeded)successDelegate; -- (void) setFailureDelegate:(ADJTrackingFailed)failureDelegate; - - (BOOL) isValid; @end diff --git a/Adjust/ADJConfig.m b/Adjust/ADJConfig.m index 71b01e397..03da8837b 100644 --- a/Adjust/ADJConfig.m +++ b/Adjust/ADJConfig.m @@ -43,30 +43,50 @@ - (id) initSelfWithAppToken:(NSString *)appToken // default values self.logLevel = ADJLogLevelInfo; - self.hasAttributionChangedDelegate = NO; + self.hasDelegate = NO; + self.hasAttributionChangedDelegate = NO; self.eventBufferingEnabled = NO; return self; } - (void) setDelegate:(NSObject *)delegate { + self.hasDelegate = NO; + self.hasAttributionChangedDelegate = NO; + if ([ADJUtil isNull:delegate]) { _delegate = nil; - self.hasAttributionChangedDelegate = NO; return; } - if (![delegate respondsToSelector:@selector(adjustAttributionChanged:)]) { - id logger = ADJAdjustFactory.logger; - [logger error:@"Delegate does not implement AdjustDelegate"]; + id logger = ADJAdjustFactory.logger; + + if ([delegate respondsToSelector:@selector(adjustAttributionChanged:)]) { + [logger debug:@"Delegate implements adjustAttributionChanged:"]; + + self.hasDelegate = YES; + self.hasAttributionChangedDelegate = YES; + } + + if ([delegate respondsToSelector:@selector(adjustTrackingSucceeded:)]) { + [logger debug:@"Delegate implements adjustTrackingSucceeded:"]; + + self.hasDelegate = YES; + } + if ([delegate respondsToSelector:@selector(adjustTrackingFailed:)]) { + [logger debug:@"Delegate implements adjustTrackingFailed:"]; + + self.hasDelegate = YES; + } + + if (!self.hasDelegate) { + [logger error:@"Delegate does not implement any optional method"]; _delegate = nil; - self.hasAttributionChangedDelegate = NO; return; } _delegate = delegate; - self.hasAttributionChangedDelegate = YES; } - (BOOL) checkEnvironment:(NSString *)environment @@ -99,14 +119,6 @@ - (BOOL)checkAppToken:(NSString *)appToken { return YES; } -- (void) setSuccessDelegate:(ADJTrackingSucceeded)successDelegate { - _successDelegate = successDelegate; -} - -- (void) setFailureDelegate:(ADJTrackingFailed)failureDelegate { - _failureDelegate = failureDelegate; -} - - (BOOL) isValid { return self.appToken != nil; } @@ -121,6 +133,7 @@ -(id)copyWithZone:(NSZone *)zone copy.sdkPrefix = [self.sdkPrefix copyWithZone:zone]; copy.defaultTracker = [self.defaultTracker copyWithZone:zone]; copy.eventBufferingEnabled = self.eventBufferingEnabled; + copy.hasDelegate = self.hasDelegate; copy.hasAttributionChangedDelegate = self.hasAttributionChangedDelegate; // adjust delegate not copied } diff --git a/Adjust/ADJFailureResponseData.h b/Adjust/ADJFailureResponseData.h index 135c12ad0..2911b4fae 100644 --- a/Adjust/ADJFailureResponseData.h +++ b/Adjust/ADJFailureResponseData.h @@ -11,18 +11,25 @@ @interface ADJFailureResponseData : NSObject +// activity type of the tracked package. For now only "event" is tracked. @property (nonatomic, copy) NSString * activityKindString; +// error message from the server or the sdk. @property (nonatomic, copy) NSString * message; +// timeStamp from the server. @property (nonatomic, copy) NSString * timeStamp; +// adid of the device. @property (nonatomic, copy) NSString * adid; +// event token of the tracked event. @property (nonatomic, copy) NSString * eventToken; +// indicates if the package will be retried to be send later @property (nonatomic, assign) BOOL willRetry; +// the server response in json format @property (nonatomic, retain) NSDictionary *jsonResponse; + (ADJFailureResponseData *)failureResponseData; diff --git a/Adjust/ADJPackageBuilder.m b/Adjust/ADJPackageBuilder.m index 5f9ee3c95..ea03816b1 100644 --- a/Adjust/ADJPackageBuilder.m +++ b/Adjust/ADJPackageBuilder.m @@ -183,7 +183,7 @@ - (void)injectConfig:(ADJConfig*) adjustConfig { [self parameters:parameters setString:adjustConfig.appToken forKey:@"app_token"]; [self parameters:parameters setString:adjustConfig.environment forKey:@"environment"]; - [self parameters:parameters setBool:adjustConfig.hasAttributionChangedDelegate forKey:@"needs_attribution_data"]; + [self parameters:parameters setBool:adjustConfig.hasDelegate forKey:@"needs_response_details"]; } - (void) injectActivityState:(ADJActivityState *)activityState diff --git a/Adjust/ADJSuccessResponseData.h b/Adjust/ADJSuccessResponseData.h index f3a1eb3b5..e0151f9f6 100644 --- a/Adjust/ADJSuccessResponseData.h +++ b/Adjust/ADJSuccessResponseData.h @@ -11,16 +11,22 @@ @interface ADJSuccessResponseData : NSObject +// activity type of the tracked package. For now only "event" is tracked. @property (nonatomic, copy) NSString * activityKindString; +// message from the server. @property (nonatomic, copy) NSString * message; +// timeStamp from the server. @property (nonatomic, copy) NSString * timeStamp; +// adid of the device. @property (nonatomic, copy) NSString * adid; +// event token of the tracked event. @property (nonatomic, copy) NSString * eventToken; +// the server response in json format @property (nonatomic, retain) NSDictionary *jsonResponse; + (ADJSuccessResponseData *)successResponseData; From 4718248687306faaefd17ba442e4f8af5b7c212b Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 20 Jan 2016 17:37:18 +0100 Subject: [PATCH 13/33] Split response and attribution tasks --- Adjust/ADJActivityHandler.h | 1 + Adjust/ADJActivityHandler.m | 35 ++++++++++++++++++++++------------ Adjust/ADJAttributionHandler.m | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Adjust/ADJActivityHandler.h b/Adjust/ADJActivityHandler.h index 30af13186..41ea4f073 100644 --- a/Adjust/ADJActivityHandler.h +++ b/Adjust/ADJActivityHandler.h @@ -20,6 +20,7 @@ - (void)finishedTracking:(ADJResponseData *)responseData; - (void)launchResponseTasks:(ADJResponseData *)responseData; +- (void)launchAttributionTasks:(ADJResponseData *)responseData; - (void)setEnabled:(BOOL)enabled; - (BOOL)isEnabled; - (void)appWillOpenUrl:(NSURL*)url; diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index 2e768852e..f1b8a79a2 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -110,7 +110,12 @@ - (void)trackEvent:(ADJEvent *)event } - (void)finishedTracking:(ADJResponseData *)responseData { - // no response json to check for attributes + // redirect session responses to attribution handler to check for attribution information + if (responseData.activityKind == ADJActivityKindSession) { + [self.attributionHandler checkResponse:responseData]; + return; + } + // no response json to check for attributes and no callback for failed package if ([ADJUtil isNull:responseData.jsonResponse]) { if (self.adjustDelegate == nil) { return; @@ -118,15 +123,9 @@ - (void)finishedTracking:(ADJResponseData *)responseData { if (![self.adjustDelegate respondsToSelector:@selector(adjustTrackingFailed:)]) { return; } - - // callback for failed package is present - [self.logger debug:@"No json with failure delegate"]; - [self launchResponseTasks:responseData]; - - return; } - // attribute might be present - [self.attributionHandler checkResponse:responseData]; + + [self launchResponseTasks:responseData]; } - (void)launchResponseTasks:(ADJResponseData *)responseData { @@ -135,6 +134,12 @@ - (void)launchResponseTasks:(ADJResponseData *)responseData { }); } +- (void)launchAttributionTasks:(ADJResponseData *)responseData { + dispatch_async(self.internalQueue, ^{ + [self launchAttributionTasksInternal:responseData]; + }); +} + - (void)launchDeepLink:(NSDictionary *)jsonDict{ if ([ADJUtil isNull:jsonDict]) return; @@ -504,18 +509,24 @@ - (void)eventInternal:(ADJEvent *)event } - (void) launchResponseTasksInternal:(ADJResponseData *)responseData { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + // try to launch the finished activity listener + [self launchFinishedDelegate:responseData]; + // in last, try to launch the deeplink + [self launchDeepLink:responseData.jsonResponse]; + }); +} +- (void) launchAttributionTasksInternal:(ADJResponseData *)responseData { SEL updateAttributionSEL = [self updateAttribution:responseData.attribution]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - // first try to update and launch the attribution changed listener + // try to update and launch the attribution changed listener if (updateAttributionSEL != nil) { [self.adjustDelegate performSelectorOnMainThread:updateAttributionSEL withObject:responseData.attribution waitUntilDone:YES]; } - // second try to launch the finished activity listener - [self launchFinishedDelegate:responseData]; // in last, try to launch the deeplink [self launchDeepLink:responseData.jsonResponse]; }); diff --git a/Adjust/ADJAttributionHandler.m b/Adjust/ADJAttributionHandler.m index db974c67d..ba7bab7cb 100644 --- a/Adjust/ADJAttributionHandler.m +++ b/Adjust/ADJAttributionHandler.m @@ -99,7 +99,7 @@ - (void) resumeSending { - (void) checkResponseInternal:(ADJResponseData *)responseData { [self checkAttributionInternal:responseData]; - [self.activityHandler launchResponseTasks:responseData]; + [self.activityHandler launchAttributionTasks:responseData]; } - (void) checkAttributionInternal:(ADJResponseData *)responseData { From d4d21f033755ed686b586a6894f88142d311274c Mon Sep 17 00:00:00 2001 From: Pedro Filipe Date: Thu, 21 Jan 2016 12:29:19 +0100 Subject: [PATCH 14/33] Update README.md --- README.md | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 0adae9f4c..d3958286a 100644 --- a/README.md +++ b/README.md @@ -441,29 +441,27 @@ Here is a quick summary of its properties: - `NSString creative` the creative grouping level of the current install. - `NSString clickLabel` the click label of the current install. -### 10. Set block callbacks for tracked events and sessions +### 10. Implement callbacks for tracked events -You can register blocks to be callback when events and sessions are tracked. -There is a block callback for when the event or session is correctly tracked, and a block callback for when there was some type of failure. -You can add any or both of the block callback after creating the `ADJConfig` object: +You can register a delegate callback to be notified of successful and failed tracked events. +The same optional protocol `AdjustDelegate` used for the attribution changed callback [here](#9-implement-the-attribution-callback) is used. +Follow the same steps and implement the following delegate callback function for successful tracked events: ```objc -ADJConfig *adjustConfig = [ADJConfig configWithAppToken:yourAppToken environment:environment]; - -[adjustConfig setSuccessDelegate:^(ADJSuccessResponseData *successResponseData) { - // ... -}]; +- (void)adjustTrackingSucceeded:(ADJSuccessResponseData *)successResponseData { +} +``` -[adjustConfig setFailureDelegate:^(ADJFailureResponseData *failureResponseData) { - // ... -}]; +And the following delegate callback function for failed tracked events: -[Adjust appDidLaunch:adjustConfig]; +```objc +- (void)adjustTrackingFailed:(ADJFailureResponseData *)failureResponseData { +} ``` -The block callback will be called after the SDK tries to send a package to the server. Within the block callback you have access to the `successResponseData` or `failureResponseData` object. Here is a quick summary of its common properties: +The delegate function will be called after the SDK tries to send a package to the server. Within the delegate callback you have access to the `successResponseData` or `failureResponseData` object. Here is a quick summary of its common properties: -- `NSString activityKindString` the type of package send, either `"event"` or `"session"`. +- `NSString activityKindString` the type of package send, for now only `"event"`. - `NSString message` the message from the server or the error logged by the SDK. - `NSString timestamp` timestamp from the server. - `NSString adid` a unique device identifier provided by adjust. @@ -522,7 +520,7 @@ ADJEvent *event = [ADJEvent eventWithEventToken:@"abc123"]; ``` You can read more about special partners and these integrations in our -[guide to special partners.][special-partners] +[guide to special partnersd.][special-partners] ### 14. Device IDS From d9c6466088e285adf52300a4dc8169a92741ed02 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 1 Feb 2016 15:44:24 +0100 Subject: [PATCH 15/33] Split launch session/attribution --- Adjust/ADJActivityHandler.h | 6 +- Adjust/ADJActivityHandler.m | 153 ++++++++++++++++++--------------- Adjust/ADJAttributionHandler.h | 2 +- Adjust/ADJAttributionHandler.m | 22 +++-- 4 files changed, 106 insertions(+), 77 deletions(-) diff --git a/Adjust/ADJActivityHandler.h b/Adjust/ADJActivityHandler.h index 41ea4f073..de75667f4 100644 --- a/Adjust/ADJActivityHandler.h +++ b/Adjust/ADJActivityHandler.h @@ -19,8 +19,8 @@ - (void)trackEvent:(ADJEvent *)event; - (void)finishedTracking:(ADJResponseData *)responseData; -- (void)launchResponseTasks:(ADJResponseData *)responseData; -- (void)launchAttributionTasks:(ADJResponseData *)responseData; +- (void)launchAttributionChangedDelegateWithDeeplink:(ADJResponseData *)responseData; +- (void)launchAttributionChangedDelegate:(ADJResponseData *)responseData; - (void)setEnabled:(BOOL)enabled; - (BOOL)isEnabled; - (void)appWillOpenUrl:(NSURL*)url; @@ -30,7 +30,7 @@ - (void)setAttribution:(ADJAttribution*)attribution; - (void)setAskingAttribution:(BOOL)askingAttribution; -- (SEL)updateAttribution:(ADJAttribution *)attribution; +- (BOOL)updateAttribution:(ADJAttribution *)attribution; - (void)setIadDate:(NSDate*)iAdImpressionDate withPurchaseDate:(NSDate*)appPurchaseDate; - (void)setIadDetails:(NSDictionary *)attributionDetails error:(NSError *)error diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index f1b8a79a2..99f865dd8 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -112,31 +112,33 @@ - (void)trackEvent:(ADJEvent *)event - (void)finishedTracking:(ADJResponseData *)responseData { // redirect session responses to attribution handler to check for attribution information if (responseData.activityKind == ADJActivityKindSession) { - [self.attributionHandler checkResponse:responseData]; + [self.attributionHandler checkSessionResponse:responseData]; return; } - // no response json to check for attributes and no callback for failed package - if ([ADJUtil isNull:responseData.jsonResponse]) { - if (self.adjustDelegate == nil) { - return; - } - if (![self.adjustDelegate respondsToSelector:@selector(adjustTrackingFailed:)]) { - return; - } + // check if it's an event response tasks and there is a delegate + if (responseData.activityKind == ADJActivityKindEvent + && self.adjustDelegate != nil) + { + [self launchEventResponseDelegate:responseData]; + return; } +} - [self launchResponseTasks:responseData]; +- (void)launchEventResponseDelegate:(ADJResponseData *)responseData { + dispatch_async(self.internalQueue, ^{ + [self launchEventResponseTasksInternal:responseData]; + }); } -- (void)launchResponseTasks:(ADJResponseData *)responseData { +- (void)launchAttributionChangedDelegateWithDeeplink:(ADJResponseData *)responseData { dispatch_async(self.internalQueue, ^{ - [self launchResponseTasksInternal:responseData]; + [self launchAttributionChangedDelegateWithDeeplinkInternal:responseData]; }); } -- (void)launchAttributionTasks:(ADJResponseData *)responseData { +- (void)launchAttributionChangedDelegate:(ADJResponseData *)responseData { dispatch_async(self.internalQueue, ^{ - [self launchAttributionTasksInternal:responseData]; + [self launchAttributionChangedDelegateInternal:responseData]; }); } @@ -317,27 +319,6 @@ - (void)setIadDetails:(NSDictionary *)attributionDetails [self.packageHandler addPackage:clickPackage]; } -- (SEL)updateAttribution:(ADJAttribution *)attribution { - if (attribution == nil) { - return nil; - } - if ([attribution isEqual:self.attribution]) { - return nil; - } - self.attribution = attribution; - [self writeAttribution]; - - if (self.adjustDelegate == nil) { - return nil; - } - - if (![self.adjustDelegate respondsToSelector:@selector(adjustAttributionChanged:)]) { - return nil; - } - - return @selector(adjustAttributionChanged:); -} - - (void)setAskingAttribution:(BOOL)askingAttribution { self.activityState.askingAttribution = askingAttribution; [self writeActivityState]; @@ -508,59 +489,95 @@ - (void)eventInternal:(ADJEvent *)event [self writeActivityState]; } -- (void) launchResponseTasksInternal:(ADJResponseData *)responseData { +- (void) launchEventResponseTasksInternal:(ADJResponseData *)responseData { + // success callback + if (responseData.success + && [self.adjustDelegate respondsToSelector:@selector(adjustTrackingSucceeded:)]) + { + [self.logger debug:@"Launching success event tracking delegate"]; + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustTrackingSucceeded:) + withObject:[responseData successResponseData] + waitUntilDone:NO]; // non-blocking + return; + } + // failure callback + if (!responseData.success + && [self.adjustDelegate respondsToSelector:@selector(adjustTrackingFailed:)]) + { + [self.logger debug:@"Launching failed event tracking delegate"]; + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustTrackingFailed:) + withObject:[responseData failureResponseData] + waitUntilDone:NO]; // non-blocking + return; + } +} + +- (void) launchAttributionChangedDelegateWithDeeplinkInternal:(ADJResponseData *)responseData { + BOOL toLaunchAttributionDelegate = [self updateAttribution:responseData.attribution]; + + // Send tasks to background to avoid blocking the activity handler queue dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - // try to launch the finished activity listener - [self launchFinishedDelegate:responseData]; - // in last, try to launch the deeplink + // try to update and launch the attribution changed delegate blocking + if (toLaunchAttributionDelegate) { + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) + withObject:responseData.attribution + waitUntilDone:YES]; // blocking + } + // try to launch the deeplink after attribution changed delegate [self launchDeepLink:responseData.jsonResponse]; }); } -- (void) launchAttributionTasksInternal:(ADJResponseData *)responseData { - SEL updateAttributionSEL = [self updateAttribution:responseData.attribution]; +- (void) launchAttributionChangedDelegateInternal:(ADJResponseData *)responseData { + BOOL toLaunchAttributionDelegate = [self updateAttribution:responseData.attribution]; + + // try to update and launch the attribution changed delegate non-blocking + if (toLaunchAttributionDelegate) { + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) + withObject:responseData.attribution + waitUntilDone:NO]; // non-blocking + } +} + +- (void) launchAttributionChangedDelegate:(ADJResponseData *)responseData + tryDeeplink:(BOOL)tryDeeplink +{ + BOOL launchAttributionCallback = [self updateAttribution:responseData.attribution]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // try to update and launch the attribution changed listener - if (updateAttributionSEL != nil) { - [self.adjustDelegate performSelectorOnMainThread:updateAttributionSEL + if (launchAttributionCallback) { + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) withObject:responseData.attribution waitUntilDone:YES]; } - // in last, try to launch the deeplink - [self launchDeepLink:responseData.jsonResponse]; + // if possible, try to launch the deeplink + if (tryDeeplink) { + [self launchDeepLink:responseData.jsonResponse]; + } }); + } -- (void) launchFinishedDelegate:(ADJResponseData *)responseData { - // no event package - if (responseData.activityKind != ADJActivityKindEvent) { - return; +- (BOOL)updateAttribution:(ADJAttribution *)attribution { + if (attribution == nil) { + return NO; } + if ([attribution isEqual:self.attribution]) { + return NO; + } + self.attribution = attribution; + [self writeAttribution]; - // no response delegate if (self.adjustDelegate == nil) { - return; + return NO; } - // success callback - if (responseData.success - && [self.adjustDelegate respondsToSelector:@selector(adjustTrackingSucceeded:)]) - { - [self.adjustDelegate performSelectorOnMainThread:@selector(adjustTrackingSucceeded:) - withObject:[responseData successResponseData] - waitUntilDone:YES]; - return; - } - // failure callback - if (!responseData.success - && [self.adjustDelegate respondsToSelector:@selector(adjustTrackingFailed:)]) - { - [self.adjustDelegate performSelectorOnMainThread:@selector(adjustTrackingFailed:) - withObject:[responseData failureResponseData] - waitUntilDone:YES]; - return; + if (![self.adjustDelegate respondsToSelector:@selector(adjustAttributionChanged:)]) { + return NO; } + + return YES; } - (void) appWillOpenUrlInternal:(NSURL *)url { diff --git a/Adjust/ADJAttributionHandler.h b/Adjust/ADJAttributionHandler.h index 24015e113..0491d6966 100644 --- a/Adjust/ADJAttributionHandler.h +++ b/Adjust/ADJAttributionHandler.h @@ -17,7 +17,7 @@ startPaused:(BOOL)startPaused hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate; -- (void)checkResponse:(ADJResponseData *)responseData; +- (void)checkSessionResponse:(ADJResponseData *)responseData; - (void)getAttribution; diff --git a/Adjust/ADJAttributionHandler.m b/Adjust/ADJAttributionHandler.m index ba7bab7cb..4cc35a9b7 100644 --- a/Adjust/ADJAttributionHandler.m +++ b/Adjust/ADJAttributionHandler.m @@ -62,9 +62,15 @@ - (id)initWithActivityHandler:(id) activityHandler return self; } -- (void) checkResponse:(ADJResponseData *)responseData { +- (void) checkSessionResponse:(ADJResponseData *)responseData { dispatch_async(self.internalQueue, ^{ - [self checkResponseInternal:responseData]; + [self checkSessionResponseInternal:responseData]; + }); +} + +- (void) checkAttributionResponse:(ADJResponseData *)responseData { + dispatch_async(self.internalQueue, ^{ + [self checkAttributionResponseInternal:responseData]; }); } @@ -96,10 +102,16 @@ - (void) resumeSending { } #pragma mark - internal -- (void) checkResponseInternal:(ADJResponseData *)responseData { +- (void) checkSessionResponseInternal:(ADJResponseData *)responseData { + [self checkAttributionInternal:responseData]; + + [self.activityHandler launchAttributionChangedDelegateWithDeeplink:responseData]; +} + +- (void) checkAttributionResponseInternal:(ADJResponseData *)responseData { [self checkAttributionInternal:responseData]; - [self.activityHandler launchAttributionTasks:responseData]; + [self.activityHandler launchAttributionChangedDelegate:responseData]; } - (void) checkAttributionInternal:(ADJResponseData *)responseData { @@ -138,7 +150,7 @@ - (void) getAttributionInternal { activityPackage:self.attributionPackage responseDataHandler:^(ADJResponseData * responseData) { - [self checkResponse:responseData]; + [self checkAttributionResponse:responseData]; }]; } From 8bc9b842ad8fdab5f653c1d3c9cbc3687f376a02 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 1 Feb 2016 15:49:59 +0100 Subject: [PATCH 16/33] Change iad 3 logs --- Adjust/ADJActivityHandler.m | 6 +----- Adjust/ADJAdditions/UIDevice+ADJAdditions.m | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index 99f865dd8..82d76d0b4 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -285,14 +285,10 @@ - (void)setIadDetails:(NSDictionary *)attributionDetails [self.logger warn:@"Unable to read iAd details"]; if (retriesLeft < 0) { - [self.logger error:@"Reached limit number of retry for iAd"]; + [self.logger error:@"Limit number of retry for iAd v3 surpassed"]; return; } - if (retriesLeft == 0) { - [self.logger error:@"Reached limit number of retry for iAd, trying iAd v2"]; - } - if (error.code == AdjADClientErrorUnknown) { dispatch_time_t retryTime = dispatch_time(DISPATCH_TIME_NOW, kDelayRetryIad); dispatch_after(retryTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ diff --git a/Adjust/ADJAdditions/UIDevice+ADJAdditions.m b/Adjust/ADJAdditions/UIDevice+ADJAdditions.m index 29294d60b..31df68164 100644 --- a/Adjust/ADJAdditions/UIDevice+ADJAdditions.m +++ b/Adjust/ADJAdditions/UIDevice+ADJAdditions.m @@ -170,6 +170,7 @@ - (void) adjSetIad:(ADJActivityHandler *) activityHandler // if no tries for iad v3 left -> iad v2 if (triesV3Left == 0) { + [logger warn:@"Reached limit number of retry for iAd v3. Trying iAd v2"]; [self adjSetIadWithDates:activityHandler ADClientSharedClientInstance:ADClientSharedClientInstance]; return; } @@ -178,8 +179,9 @@ - (void) adjSetIad:(ADJActivityHandler *) activityHandler ADClientSharedClientInstance:ADClientSharedClientInstance retriesLeft:(triesV3Left - 1)]; - // if no tries for iad v3 left -> iad v2 + // if iad v3 not available -> iad v2 if (!isIadV3Avaliable) { + [logger warn:@"iAd v3 not available. Trying iAd v2"]; [self adjSetIadWithDates:activityHandler ADClientSharedClientInstance:ADClientSharedClientInstance]; } #pragma clang diagnostic pop From e727f7987326b15fcd1092904f650f1a2615c708 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 1 Feb 2016 15:50:17 +0100 Subject: [PATCH 17/33] Dealloc semaphore --- Adjust/ADJPackageHandler.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Adjust/ADJPackageHandler.m b/Adjust/ADJPackageHandler.m index be9f9345b..19c2c7797 100644 --- a/Adjust/ADJPackageHandler.m +++ b/Adjust/ADJPackageHandler.m @@ -182,4 +182,11 @@ - (NSString *)packageQueueFilename { return filename; } +-(void)dealloc { + //cleanup code + if (self.sendingSemaphore != nil) { + dispatch_semaphore_signal(self.sendingSemaphore); + } +} + @end From cef6fe1384c84408af092ab58c3c860b8cb2e52d Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 1 Feb 2016 15:50:35 +0100 Subject: [PATCH 18/33] Add response data log --- Adjust/ADJResponseData.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adjust/ADJResponseData.m b/Adjust/ADJResponseData.m index 9f3785c33..2c165d2f1 100644 --- a/Adjust/ADJResponseData.m +++ b/Adjust/ADJResponseData.m @@ -26,8 +26,8 @@ - (id)initWithActivityPackage:(ADJActivityPackage *)activityPackage { } - (NSString *)description { - return [NSString stringWithFormat:@"message:%@ timestamp:%@ json:%@", - self.message, self.timeStamp, self.jsonResponse]; + return [NSString stringWithFormat:@"message:%@ timestamp:%@ adid:%@ eventToken:%@ success:%d willRetry:%d attribution:%@ json:%@", + self.message, self.timeStamp, self.adid, self.eventToken, self.success, self.willRetry, self.attribution, self.jsonResponse]; } - (ADJSuccessResponseData *)successResponseData { From e109680fb018e3b75381dc5c0f740d1cea574acf Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 1 Feb 2016 15:51:37 +0100 Subject: [PATCH 19/33] Add tests --- Adjust.xcodeproj/project.pbxproj | 18 + AdjustTests/ADJActivityHandlerMock.h | 2 - AdjustTests/ADJActivityHandlerMock.m | 25 +- AdjustTests/ADJActivityHandlerTests.m | 375 +++++++++++++++++- AdjustTests/ADJAttributionHandlerMock.m | 8 +- AdjustTests/ADJAttributionHandlerTests.m | 99 +++-- AdjustTests/ADJPackageFields.h | 1 + AdjustTests/ADJPackageHandlerMock.m | 6 +- AdjustTests/ADJPackageHandlerTests.m | 61 ++- AdjustTests/ADJRequestHandlerMock.m | 2 +- AdjustTests/ADJTest.h | 3 + AdjustTests/ADJTestActivityPackage.m | 15 +- AdjustTests/ADJTrackingFailedDelegate.h | 14 + AdjustTests/ADJTrackingFailedDelegate.m | 38 ++ AdjustTests/ADJTrackingSucceededDelegate.h | 14 + AdjustTests/ADJTrackingSucceededDelegate.m | 38 ++ AdjustTests/AIRequestHandlerTests.m | 21 +- ...NSURLSession+NSURLDataWithRequestMocking.h | 36 ++ ...NSURLSession+NSURLDataWithRequestMocking.m | 98 +++++ 19 files changed, 738 insertions(+), 136 deletions(-) create mode 100644 AdjustTests/ADJTrackingFailedDelegate.h create mode 100644 AdjustTests/ADJTrackingFailedDelegate.m create mode 100644 AdjustTests/ADJTrackingSucceededDelegate.h create mode 100644 AdjustTests/ADJTrackingSucceededDelegate.m create mode 100644 AdjustTests/NSURLSession+NSURLDataWithRequestMocking.h create mode 100644 AdjustTests/NSURLSession+NSURLDataWithRequestMocking.m diff --git a/Adjust.xcodeproj/project.pbxproj b/Adjust.xcodeproj/project.pbxproj index 59230572c..07d70d400 100644 --- a/Adjust.xcodeproj/project.pbxproj +++ b/Adjust.xcodeproj/project.pbxproj @@ -76,6 +76,8 @@ 96C93DF61AC47FE000B53F56 /* NSData+ADJAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 96C93DF41AC47F2E00B53F56 /* NSData+ADJAdditions.m */; }; 96CD2BE01A13BFC600A40AFB /* NSString+ADJAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 96CD2BDD1A13BFC600A40AFB /* NSString+ADJAdditions.m */; }; 96CD2BE11A13BFC600A40AFB /* UIDevice+ADJAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 96CD2BDF1A13BFC600A40AFB /* UIDevice+ADJAdditions.m */; }; + 96DD62751C52810500DDF56A /* ADJTrackingSucceededDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 96DD62741C52810500DDF56A /* ADJTrackingSucceededDelegate.m */; }; + 96DD627A1C52818000DDF56A /* ADJTrackingFailedDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 96DD62791C52818000DDF56A /* ADJTrackingFailedDelegate.m */; }; 96E5E38118BBB48A008E7B30 /* Adjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 96E5E34D18BBB48A008E7B30 /* Adjust.m */; }; 96E5E38B18BBB48A008E7B30 /* ADJActivityHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 96E5E36318BBB48A008E7B30 /* ADJActivityHandler.m */; }; 96E5E38C18BBB48A008E7B30 /* ADJActivityKind.m in Sources */ = {isa = PBXBuildFile; fileRef = 96E5E36518BBB48A008E7B30 /* ADJActivityKind.m */; }; @@ -103,6 +105,7 @@ 96FCC53B1C186426007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5371C186426007BBFE1 /* ADJResponseData.m */; }; 96FCC5521C1865D3007BBFE1 /* ADJResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC54E1C1865D3007BBFE1 /* ADJResponseData.h */; }; 96FCC5531C1865D3007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC54F1C1865D3007BBFE1 /* ADJResponseData.m */; }; + 96FDD75E1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FDD75D1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.m */; }; 9D363AC31BDA50FA00B47FE9 /* ADJLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 96E5E37318BBB48A008E7B30 /* ADJLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9DE7C8FD1AE688DA001556E5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DE7C8FC1AE688DA001556E5 /* UIKit.framework */; }; 9DFA37B71C0F21D600782607 /* AdjustSdk.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37B51C0F21D600782607 /* AdjustSdk.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -235,6 +238,10 @@ 96CD2BDD1A13BFC600A40AFB /* NSString+ADJAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+ADJAdditions.m"; sourceTree = ""; }; 96CD2BDE1A13BFC600A40AFB /* UIDevice+ADJAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIDevice+ADJAdditions.h"; sourceTree = ""; }; 96CD2BDF1A13BFC600A40AFB /* UIDevice+ADJAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIDevice+ADJAdditions.m"; sourceTree = ""; }; + 96DD62731C52810500DDF56A /* ADJTrackingSucceededDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJTrackingSucceededDelegate.h; sourceTree = ""; }; + 96DD62741C52810500DDF56A /* ADJTrackingSucceededDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJTrackingSucceededDelegate.m; sourceTree = ""; }; + 96DD62781C52818000DDF56A /* ADJTrackingFailedDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJTrackingFailedDelegate.h; sourceTree = ""; }; + 96DD62791C52818000DDF56A /* ADJTrackingFailedDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJTrackingFailedDelegate.m; sourceTree = ""; }; 96E5E34C18BBB48A008E7B30 /* Adjust.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Adjust.h; sourceTree = ""; }; 96E5E34D18BBB48A008E7B30 /* Adjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Adjust.m; sourceTree = ""; }; 96E5E36218BBB48A008E7B30 /* ADJActivityHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJActivityHandler.h; sourceTree = ""; }; @@ -285,6 +292,8 @@ 96FCC54F1C1865D3007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJResponseData.m; path = Adjust/ADJResponseData.m; sourceTree = SOURCE_ROOT; }; 96FCC5501C1865D3007BBFE1 /* ADJResponseDataTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJResponseDataTasks.h; path = Adjust/ADJResponseDataTasks.h; sourceTree = SOURCE_ROOT; }; 96FCC5511C1865D3007BBFE1 /* ADJResponseDataTasks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJResponseDataTasks.m; path = Adjust/ADJResponseDataTasks.m; sourceTree = SOURCE_ROOT; }; + 96FDD75C1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSURLSession+NSURLDataWithRequestMocking.h"; sourceTree = ""; }; + 96FDD75D1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURLSession+NSURLDataWithRequestMocking.m"; sourceTree = ""; }; 9DE7C8FC1AE688DA001556E5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 9DFA37AD1C0F219400782607 /* AdjustSdk.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AdjustSdk.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9DFA37B51C0F21D600782607 /* AdjustSdk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdjustSdk.h; sourceTree = ""; }; @@ -516,6 +525,12 @@ 9620EA4D1B06401B009673F1 /* ADJTest.m */, 9620EA4F1B065177009673F1 /* ADJPackageFields.h */, 9620EA501B065177009673F1 /* ADJPackageFields.m */, + 96DD62731C52810500DDF56A /* ADJTrackingSucceededDelegate.h */, + 96DD62741C52810500DDF56A /* ADJTrackingSucceededDelegate.m */, + 96DD62781C52818000DDF56A /* ADJTrackingFailedDelegate.h */, + 96DD62791C52818000DDF56A /* ADJTrackingFailedDelegate.m */, + 96FDD75C1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.h */, + 96FDD75D1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.m */, ); path = AdjustTests; sourceTree = ""; @@ -876,9 +891,12 @@ 96E5E3B118BBB49E008E7B30 /* ADJLoggerMock.m in Sources */, 96E5E3AF18BBB49E008E7B30 /* ADJActivityHandlerMock.m in Sources */, 96E5E3B318BBB49E008E7B30 /* ADJPackageHandlerTests.m in Sources */, + 96DD627A1C52818000DDF56A /* ADJTrackingFailedDelegate.m in Sources */, 9620EA451B062D6F009673F1 /* ADJTestActivityPackage.m in Sources */, 96E5E3B618BBB49E008E7B30 /* ADJTestsUtil.m in Sources */, + 96DD62751C52810500DDF56A /* ADJTrackingSucceededDelegate.m in Sources */, 96CD2BE11A13BFC600A40AFB /* UIDevice+ADJAdditions.m in Sources */, + 96FDD75E1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.m in Sources */, 9620EA511B065177009673F1 /* ADJPackageFields.m in Sources */, 9620EA4E1B06401B009673F1 /* ADJTest.m in Sources */, 96E5E3B018BBB49E008E7B30 /* ADJActivityHandlerTests.m in Sources */, diff --git a/AdjustTests/ADJActivityHandlerMock.h b/AdjustTests/ADJActivityHandlerMock.h index d04e60590..1d0b915cf 100644 --- a/AdjustTests/ADJActivityHandlerMock.h +++ b/AdjustTests/ADJActivityHandlerMock.h @@ -13,6 +13,4 @@ @property (nonatomic, strong) ADJAttribution *attributionUpdated; -- (void) setUpdatedAttribution:(BOOL)updated; - @end diff --git a/AdjustTests/ADJActivityHandlerMock.m b/AdjustTests/ADJActivityHandlerMock.m index d4c521330..2d64869db 100644 --- a/AdjustTests/ADJActivityHandlerMock.m +++ b/AdjustTests/ADJActivityHandlerMock.m @@ -15,7 +15,7 @@ @interface ADJActivityHandlerMock() @property (nonatomic, strong) ADJLoggerMock *loggerMock; -@property (nonatomic, assign) BOOL updated; +@property (nonatomic, retain) ADJResponseData * lastResponseData; @end @@ -26,7 +26,6 @@ - (id)initWithConfig:(ADJConfig *)adjustConfig { if (self == nil) return nil; self.loggerMock = (ADJLoggerMock *) [ADJAdjustFactory logger]; - self.updated = NO; [self.loggerMock test:[prefix stringByAppendingFormat:@"initWithConfig"]]; @@ -45,8 +44,9 @@ - (void)trackEvent:(ADJEvent *)event { } -- (void)finishedTracking:(NSDictionary *)jsonDict { - [self.loggerMock test:[prefix stringByAppendingFormat:@"finishedTracking, %@", jsonDict]]; +- (void)finishedTracking:(ADJResponseData *)responseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"finishedTracking, %@", responseData]]; + self.lastResponseData = responseData; } - (void)setEnabled:(BOOL)enabled { @@ -82,7 +82,7 @@ - (void) setAskingAttribution:(BOOL)askingAttribution { - (BOOL) updateAttribution:(ADJAttribution*) attribution { [self.loggerMock test:[prefix stringByAppendingFormat:@"updateAttribution, %@", attribution]]; self.attributionUpdated = attribution; - return self.updated; + return NO; } - (void) setIadDate:(NSDate*)iAdImpressionDate withPurchaseDate:(NSDate*)appPurchaseDate { @@ -95,16 +95,19 @@ - (void)setIadDetails:(NSDictionary *)attributionDetails [self.loggerMock test:[prefix stringByAppendingFormat:@"setIadDetails, %@ error, %@", attributionDetails, error]]; } -- (void) launchAttributionDelegate { - [self.loggerMock test:[prefix stringByAppendingFormat:@"launchAttributionDelegate"]]; +- (void) launchAttributionChangedDelegateWithDeeplink:(ADJResponseData *)responseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"launchAttributionChangedDelegateWithDeeplink, %@", responseData]]; + self.lastResponseData = responseData; } -- (void) setOfflineMode:(BOOL)enabled { - [self.loggerMock test:[prefix stringByAppendingFormat:@"setOfflineMode"]]; +- (void) launchAttributionChangedDelegate:(ADJResponseData *)responseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"launchAttributionChangedDelegate, %@", responseData]]; + self.lastResponseData = responseData; } -- (void) setUpdatedAttribution:(BOOL)updated { - self.updated = updated; + +- (void) setOfflineMode:(BOOL)enabled { + [self.loggerMock test:[prefix stringByAppendingFormat:@"setOfflineMode"]]; } @end diff --git a/AdjustTests/ADJActivityHandlerTests.m b/AdjustTests/ADJActivityHandlerTests.m index 71f6eced8..f015c7d40 100644 --- a/AdjustTests/ADJActivityHandlerTests.m +++ b/AdjustTests/ADJActivityHandlerTests.m @@ -19,6 +19,8 @@ #import "ADJConfig.h" #import "ADJDelegateTest.h" #import "ADJTestActivityPackage.h" +#import "ADJTrackingSucceededDelegate.h" +#import "ADJTrackingFailedDelegate.h" @interface ADJActivityHandlerTests : ADJTestActivityPackage @@ -379,7 +381,7 @@ - (void)testChecks ADJTestsUtil * delegateNotImpl = [[ADJTestsUtil alloc] init]; [config setDelegate:delegateNotImpl]; - aError(@"Delegate does not implement AdjustDelegate"); + aError(@"Delegate does not implement any optional method"); // create handler and start the first session id activityHandler =[ADJActivityHandler handlerWithConfig:config]; @@ -862,7 +864,7 @@ - (void)testAppWillOpenUrl [self testClickPackage:mixedClickPackage fields:mixedClickFields source:@"deeplink"]; } -- (void)testIad +- (void)testIadDates { // reseting to make the test order independent [self reset]; @@ -905,7 +907,6 @@ - (void)testIad // didn't send click package anTest(@"PackageHandler addPackage"); - // 1 session aiEquals(1, (int)[self.packageHandlerMock.packageQueue count]); @@ -966,6 +967,93 @@ - (void)testIad [self testClickPackage:secondIadPackage fields:secondIadFields source:@"iad"]; } +- (void)testIadDetails +{ + // reseting to make the test order independent + [self reset]; + + // create the config to start the session + ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; + + // start activity handler with config + id activityHandler = [ADJActivityHandler handlerWithConfig:config]; + + // it's necessary to sleep the activity for a while after each handler call + // to let the internal queue act + [NSThread sleepForTimeInterval:2.0]; + + // test init values and first session + [self checkInitAndFirstSession]; + + // test iad details + // should be ignored + NSError * errorCode0 = [[NSError alloc] initWithDomain:@"adjust" code:0 userInfo:nil]; + NSError * errorCode1 = [[NSError alloc] initWithDomain:@"adjust" code:1 userInfo:nil]; + + [activityHandler setIadDetails:nil error:errorCode0 retriesLeft:-1]; + [NSThread sleepForTimeInterval:1]; + + aWarn(@"Unable to read iAd details"); + aError(@"Limit number of retry for iAd v3 surpassed"); + + [activityHandler setIadDetails:nil error:errorCode0 retriesLeft:0]; + [NSThread sleepForTimeInterval:4]; + + aWarn(@"Unable to read iAd details"); + anError(@"Limit number of retry for iAd v3 surpassed"); + + aDebug(@"iAd with 0 tries to read v3"); + aWarn(@"Reached limit number of retry for iAd v3. Trying iAd v2"); + + [activityHandler setIadDetails:nil error:errorCode0 retriesLeft:1]; + [NSThread sleepForTimeInterval:4]; + + aWarn(@"Unable to read iAd details"); + + aDebug(@"iAd with 1 tries to read v3"); + anWarn(@"Reached limit number of retry for iAd v3. Trying iAd v2"); + + [activityHandler setIadDetails:nil error:errorCode1 retriesLeft:1]; + [NSThread sleepForTimeInterval:4]; + + aWarn(@"Unable to read iAd details"); + anDebug(@"iAd with 1 tries to read v3"); + + [activityHandler setIadDetails:nil error:nil retriesLeft:1]; + [NSThread sleepForTimeInterval:4]; + + anWarn(@"Unable to read iAd details"); + aiEquals(1, (int)[self.packageHandlerMock.packageQueue count]); + + NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; + [dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'Z"]; + + NSDate * date1 = [NSDate date]; + NSString * date1String = [dateFormat stringFromDate:date1]; + + NSDictionary * attributionDetails = @{ @"iadVersion3" : @{ @"date" : date1 , + @"decimal" : [NSNumber numberWithDouble:0.1], + @"string" : @"value"} }; + + [activityHandler setIadDetails:attributionDetails error:nil retriesLeft:1]; + [NSThread sleepForTimeInterval:2]; + + // check the number of activity packages + // 1 session + 1 sdk_click + aiEquals(2, (int)[self.packageHandlerMock.packageQueue count]); + + // get the click package + ADJActivityPackage *clickPackage = (ADJActivityPackage *) self.packageHandlerMock.packageQueue[1]; + + // create activity package test + ADJPackageFields * clickPackageFields = [ADJPackageFields fields]; + + clickPackageFields.iadDetails = [NSString stringWithFormat:@"{\"iadVersion3\":{\"date\":\"%@\",\"decimal\":\"0.1\",\"string\":\"value\"}}", date1String]; + + // test first session + [self testClickPackage:clickPackage fields:clickPackageFields source:@"iad3"]; +} + - (void)testFinishedTracking { // reseting to make the test order independent @@ -981,10 +1069,14 @@ - (void)testFinishedTracking ADJDelegateTest * delegateTests = [[ADJDelegateTest alloc] init]; [config setDelegate:delegateTests]; + aDebug(@"Delegate implements adjustAttributionChanged"); + // create handler and start the first session id activityHandler = [ADJActivityHandler handlerWithConfig:config]; - [NSThread sleepForTimeInterval:2.0]; + [activityHandler trackEvent:[ADJEvent eventWithEventToken:@"abc123"]]; + + [NSThread sleepForTimeInterval:3.0]; // test init values [self checkInit:ADJEnvironmentProduction logLevel:@"6"]; @@ -992,6 +1084,169 @@ - (void)testFinishedTracking // test first session start [self checkFirstSession]; + // test session package to be checked for attribution + ADJActivityPackage * firstSessionPackage = self.packageHandlerMock.packageQueue[0]; + ADJResponseData * firstSessionResponseData = [ADJResponseData responseDataWithActivityPackage:firstSessionPackage]; + + [activityHandler finishedTracking:firstSessionResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + aTest(@"AttributionHandler checkSessionResponse"); + + // test event success response data + ADJActivityPackage * eventPackage = self.packageHandlerMock.packageQueue[1]; + ADJResponseData * eventResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; + eventResponseData.success = YES; + + [activityHandler finishedTracking:eventResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + anTest(@"AttributionHandler checkSessionResponse"); + anDebug(@"Delegate implements adjustTrackingSucceeded"); + anDebug(@"Delegate implements adjustTrackingFailed"); + + // test event failed response data + eventResponseData.success = NO; + + [activityHandler finishedTracking:eventResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + anTest(@"AttributionHandler checkSessionResponse"); + anDebug(@"Delegate implements adjustTrackingSucceeded"); + anDebug(@"Delegate implements adjustTrackingFailed"); +} + +- (void) testLaunchSuccessResponseTasks +{ + // reseting to make the test order independent + [self reset]; + + // create the config to start the session + ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; + + ADJTrackingSucceededDelegate * successDelegate = [[ADJTrackingSucceededDelegate alloc] init]; + [config setDelegate:successDelegate]; + + anDebug(@"Delegate implements adjustAttributionChanged"); + anDebug(@"Delegate implements adjustTrackingFailed"); + aDebug(@"Delegate implements adjustTrackingSucceeded"); + + // create handler and start the first session + id activityHandler = [ADJActivityHandler handlerWithConfig:config]; + + NSURL* attributions = [NSURL URLWithString:@"AdjustTests://example.com/path/inApp?adjust_tracker=trackerValue&other=stuff&adjust_campaign=campaignValue&adjust_adgroup=adgroupValue&adjust_creative=creativeValue"]; + + [activityHandler appWillOpenUrl:attributions]; + + [activityHandler trackEvent:[ADJEvent eventWithEventToken:@"abc123"]]; + + [NSThread sleepForTimeInterval:3.0]; + + [self checkInitAndFirstSession]; + + // test success event response data + ADJActivityPackage * eventPackage = self.packageHandlerMock.packageQueue[2]; + ADJResponseData * eventSuccessResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; + eventSuccessResponseData.success = YES; + + [activityHandler finishedTracking:eventSuccessResponseData]; + [NSThread sleepForTimeInterval:2.0]; + + anTest(@"AttributionHandler checkSessionResponse"); + anDebug(@"Launching failed event tracking delegate"); + aDebug(@"Launching success event tracking delegate"); + + // test success sdk_click response data + ADJActivityPackage * sdkClickPackage = self.packageHandlerMock.packageQueue[1]; + ADJResponseData * sdkClickResponseData = [ADJResponseData responseDataWithActivityPackage:sdkClickPackage]; + sdkClickResponseData.success = YES; + + [activityHandler finishedTracking:sdkClickResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + anTest(@"AttributionHandler checkSessionResponse"); + anDebug(@"Launching success event tracking delegate"); + anDebug(@"Launching failed event tracking delegate"); + + // test failed event response data + ADJResponseData * eventFailureResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; + eventFailureResponseData.success = NO; + + [activityHandler finishedTracking:eventFailureResponseData]; + [NSThread sleepForTimeInterval:2.0]; + + anTest(@"AttributionHandler checkSessionResponse"); + anDebug(@"Launching success event tracking delegate"); + // does not launch because delegate does not have failed callback + anDebug(@"Launching failed event tracking delegate"); +} + +- (void) testLaunchFailureResponseTasks +{ + // reseting to make the test order independent + [self reset]; + + // create the config to start the session + ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; + + ADJTrackingFailedDelegate * failureDelegate = [[ADJTrackingFailedDelegate alloc] init]; + [config setDelegate:failureDelegate]; + + anDebug(@"Delegate implements adjustAttributionChanged"); + anDebug(@"Delegate implements adjustTrackingSucceeded"); + aDebug(@"Delegate implements adjustTrackingFailed"); + + // create handler and start the first session + id activityHandler = [ADJActivityHandler handlerWithConfig:config]; + + NSURL* attributions = [NSURL URLWithString:@"AdjustTests://example.com/path/inApp?adjust_tracker=trackerValue&other=stuff&adjust_campaign=campaignValue&adjust_adgroup=adgroupValue&adjust_creative=creativeValue"]; + + [activityHandler appWillOpenUrl:attributions]; + + [activityHandler trackEvent:[ADJEvent eventWithEventToken:@"abc123"]]; + + [NSThread sleepForTimeInterval:3.0]; + + [self checkInitAndFirstSession]; + + // test failed event response data + ADJActivityPackage * eventPackage = self.packageHandlerMock.packageQueue[2]; + ADJResponseData * eventFailureResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; + eventFailureResponseData.success = NO; + + [activityHandler finishedTracking:eventFailureResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + anTest(@"AttributionHandler checkSessionResponse"); + anDebug(@"Launching success event tracking delegate"); + aDebug(@"Launching failed event tracking delegate"); + + // test success sdk_click response data + ADJActivityPackage * sdkClickPackage = self.packageHandlerMock.packageQueue[1]; + ADJResponseData * sdkClickResponseData = [ADJResponseData responseDataWithActivityPackage:sdkClickPackage]; + sdkClickResponseData.success = NO; + + [activityHandler finishedTracking:sdkClickResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + anTest(@"AttributionHandler checkSessionResponse"); + anDebug(@"Launching success event tracking delegate"); + anDebug(@"Launching failed event tracking delegate"); + + // test success event response data + ADJResponseData * eventSuccessResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; + eventSuccessResponseData.success = YES; + + [activityHandler finishedTracking:eventSuccessResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + anTest(@"AttributionHandler checkSessionResponse"); + anDebug(@"Launching failed event tracking delegate"); + anDebug(@"Launching success event tracking delegate"); +} + +/* + // test nil response [activityHandler finishedTracking:nil]; [NSThread sleepForTimeInterval:1.0]; @@ -1005,11 +1260,14 @@ - (void)testFinishedTracking NSString * deeplinkString = @"{\"deeplink\":\"wrongDeeplink://\"}"; NSData * deeplinkData = [deeplinkString dataUsingEncoding:NSUTF8StringEncoding]; - NSDictionary * deeplinkDictionary = [ADJUtil buildJsonDict:deeplinkData]; + NSError *error = nil; + NSException *exception = nil; + + NSDictionary * deeplinkDictionary = [ADJUtil buildJsonDict:deeplinkData exceptionPtr:&exception errorPtr:&error]; anNil(deeplinkDictionary); - [activityHandler finishedTracking:deeplinkDictionary]; + //[activityHandler finishedTracking:deeplinkDictionary]; [NSThread sleepForTimeInterval:1.0]; @@ -1035,6 +1293,67 @@ - (void)testFinishedTracking // set first session [self testPackageSession:activityPackage fields:fields sessionCount:@"1"]; } + */ + +- (void)testLaunchDeepLink +{ + // reseting to make the test order independent + [self reset]; + + // create the config + ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; + + // start the session + id activityHandler =[ADJActivityHandler handlerWithConfig:config]; + + NSURL* attributions = [NSURL URLWithString:@"AdjustTests://example.com/path/inApp?adjust_tracker=trackerValue&other=stuff&adjust_campaign=campaignValue&adjust_adgroup=adgroupValue&adjust_creative=creativeValue"]; + + [activityHandler appWillOpenUrl:attributions]; + + [activityHandler trackEvent:[ADJEvent eventWithEventToken:@"abc123"]]; + + [NSThread sleepForTimeInterval:3.0]; + + [self checkInitAndFirstSession]; + + // test success event response data + ADJActivityPackage * eventPackage = self.packageHandlerMock.packageQueue[2]; + ADJResponseData * eventSuccessResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; + eventSuccessResponseData.success = YES; + + NSString * deeplinkString = @"{\"deeplink\":\"wrongDeeplink://\"}"; + NSData * deeplinkData = [deeplinkString dataUsingEncoding:NSUTF8StringEncoding]; + NSError *error = nil; + NSException *exception = nil; + + NSDictionary * deeplinkDictionary = [ADJUtil buildJsonDict:deeplinkData exceptionPtr:&exception errorPtr:&error]; + + anNil(deeplinkDictionary); + + eventSuccessResponseData.jsonResponse = deeplinkDictionary; + + [activityHandler finishedTracking:eventSuccessResponseData]; + [NSThread sleepForTimeInterval:2.0]; + + // event response does not open deeplinks + anInfo(@"Open deep link (wrongDeeplink://)"); + + anError(@"Unable to open deep link (wrongDeeplink://)"); + + + // test success session response data + ADJActivityPackage * sessionPackage = self.packageHandlerMock.packageQueue[0]; + + ADJResponseData * sessionResponseData = [[ADJResponseData alloc] initWithActivityPackage:sessionPackage]; + sessionResponseData.jsonResponse = deeplinkDictionary; + + [activityHandler launchAttributionChangedDelegateWithDeeplink:sessionResponseData]; + [NSThread sleepForTimeInterval:2.0]; + + aInfo(@"Open deep link (wrongDeeplink://)"); + + aError(@"Unable to open deep link (wrongDeeplink://)"); +} - (void)testUpdateAttribution { @@ -1044,16 +1363,18 @@ - (void)testUpdateAttribution // create the config ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; + ADJDelegateTest * delegateTests = [[ADJDelegateTest alloc] init]; + [config setDelegate:delegateTests]; + + aDebug(@"Delegate implements adjustAttributionChanged"); + // start the session id activityHandler =[ADJActivityHandler handlerWithConfig:config]; - [NSThread sleepForTimeInterval:2]; + [NSThread sleepForTimeInterval:2.0]; // test init values - [self checkInit:ADJEnvironmentSandbox logLevel:@"3"]; - - // test first session start - [self checkFirstSession]; + [self checkInitAndFirstSession]; // check if Attribution is not created with nil ADJAttribution * nilAttribution = [[ADJAttribution alloc] initWithJsonDict:nil]; @@ -1092,7 +1413,6 @@ - (void)testUpdateAttribution config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; // set delegate to see attribution launched - ADJDelegateTest * delegateTests = [[ADJDelegateTest alloc] init]; [config setDelegate:delegateTests]; id restartActivityHandler = [ADJActivityHandler handlerWithConfig:config]; @@ -1109,7 +1429,7 @@ - (void)testUpdateAttribution [self checkSubsession:1 subSessionCount:2 timerAlreadyStarted:NO]; // check that it does not update the attribution after the restart - aFalse([restartActivityHandler updateAttribution:emptyAttribution]); + //aFalse([restartActivityHandler updateAttribution:emptyAttribution]); anDebug(@"Wrote Attribution"); // new attribution @@ -1123,7 +1443,10 @@ - (void)testUpdateAttribution "\"click_label\" : \"clValue\" }"; NSData * firstAttributionData = [firstAttributionString dataUsingEncoding:NSUTF8StringEncoding]; - NSDictionary * firstAttributionDictionary = [ADJUtil buildJsonDict:firstAttributionData]; + NSError *error = nil; + NSException *exception = nil; + + NSDictionary * firstAttributionDictionary = [ADJUtil buildJsonDict:firstAttributionData exceptionPtr:&exception errorPtr:&error]; anNil(firstAttributionDictionary); @@ -1179,7 +1502,7 @@ - (void)testUpdateAttribution "\"click_label\" : \"clValue2\" }"; NSData * secondAttributionData = [secondAttributionString dataUsingEncoding:NSUTF8StringEncoding]; - NSDictionary * secondAttributionDictionary = [ADJUtil buildJsonDict:secondAttributionData]; + NSDictionary * secondAttributionDictionary = [ADJUtil buildJsonDict:secondAttributionData exceptionPtr:&exception errorPtr:&error]; anNil(secondAttributionDictionary); @@ -1197,7 +1520,6 @@ - (void)testUpdateAttribution // check that it does not update the attribution aFalse([secondRestartActivityHandler updateAttribution:secondAttribution]); anDebug(@"Wrote Attribution"); - } - (void)testOfflineMode @@ -1393,7 +1715,9 @@ - (void)testGetAttribution "\"click_label\" : \"clValue\" }"; NSData * attributionData = [attributionString dataUsingEncoding:NSUTF8StringEncoding]; - NSDictionary * attributionDictionary = [ADJUtil buildJsonDict:attributionData]; + NSError *error = nil; + NSException *exception = nil; + NSDictionary * attributionDictionary = [ADJUtil buildJsonDict:attributionData exceptionPtr:&exception errorPtr:&error]; anNil(attributionDictionary); @@ -1615,7 +1939,6 @@ - (NSURL*)getUniversalLinkUrl:(NSString*)path stringWithFormat:@"https://[hash].ulink.adjust.com/ulink%@", path]]; } - - (NSURL*)getUniversalLinkUrl:(NSString*)path query:(NSString*)query fragment:(NSString*)fragment @@ -1624,6 +1947,10 @@ - (NSURL*)getUniversalLinkUrl:(NSString*)path stringWithFormat:@"https://[hash].ulink.adjust.com/ulink%@%@%@", path, query, fragment]]; } +- (void)checkInit { + [self checkInit:ADJEnvironmentSandbox logLevel:@"3"]; +} + - (void)checkInit:(NSString *)environment logLevel:(NSString *)logLevel { @@ -1652,10 +1979,10 @@ - (void)checkInit:(NSString *)environment [self checkReadFiles:readActivityState readAttribution:readAttribution]; // tries to read iad v3 - aDebug(@"iAd with 5 tries to read v3"); + aDebug(@"iAd with 2 tries to read v3"); - // iad is not disabled - anDebug(@"ADJUST_NO_IAD or TARGET_OS_TV set"); + // iad is enabled + aDebug(@"ADJUST_NO_IAD or TARGET_OS_TV not set"); } - (void)checkReadFiles:(NSString *)readActivityState @@ -1694,6 +2021,12 @@ - (void)checkFirstSession [self checkFirstSession:NO]; } +- (void)checkInitAndFirstSession +{ + [self checkInit]; + [self checkFirstSession]; +} + - (void)checkNewSession:(BOOL)paused sessionCount:(int)sessionCount eventCount:(int)eventCount diff --git a/AdjustTests/ADJAttributionHandlerMock.m b/AdjustTests/ADJAttributionHandlerMock.m index 18a3ba3c9..7dea09090 100644 --- a/AdjustTests/ADJAttributionHandlerMock.m +++ b/AdjustTests/ADJAttributionHandlerMock.m @@ -26,7 +26,7 @@ @implementation ADJAttributionHandlerMock - (id)initWithActivityHandler:(id) activityHandler withAttributionPackage:(ADJActivityPackage *) attributionPackage startPaused:(BOOL)startPaused - hasDelegate:(BOOL)hasDelegate +hasAttributionChangedDelegate:(BOOL)hasDelegate { self = [super init]; if (self == nil) return nil; @@ -36,13 +36,13 @@ - (id)initWithActivityHandler:(id) activityHandler self.loggerMock = (ADJLoggerMock *) [ADJAdjustFactory logger]; self.attributionPackage = attributionPackage; - [self.loggerMock test:[prefix stringByAppendingFormat:@"initWithActivityHandler"]]; + //[self.loggerMock test:[prefix stringByAppendingFormat:@"initWithActivityHandler"]]; return self; } -- (void)checkAttribution:(NSDictionary *)jsonDict { - [self.loggerMock test:[prefix stringByAppendingFormat:@"checkAttribution, jsonDict: %@", jsonDict]]; +- (void)checkSessionResponse:(ADJResponseData *)responseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"checkSessionResponse, responseData: %@", responseData]]; } - (void)getAttribution { diff --git a/AdjustTests/ADJAttributionHandlerTests.m b/AdjustTests/ADJAttributionHandlerTests.m index bc1c14c31..8a997694b 100644 --- a/AdjustTests/ADJAttributionHandlerTests.m +++ b/AdjustTests/ADJAttributionHandlerTests.m @@ -11,6 +11,7 @@ #import "ADJAdjustFactory.h" #import "ADJLoggerMock.h" #import "NSURLConnection+NSURLConnectionSynchronousLoadingMocking.h" +#import "NSURLSession+NSURLDataWithRequestMocking.h" #import "ADJTestsUtil.h" #import "ADJActivityHandlerMock.h" #import "ADJAttributionHandlerMock.h" @@ -23,6 +24,7 @@ @interface ADJAttributionHandlerTests : ADJTestActivityPackage @property (atomic,strong) ADJActivityHandlerMock *activityHandlerMock; @property (atomic,strong) ADJActivityPackage * attributionPackage; +@property (atomic,strong) ADJActivityPackage * firstSessionPackage; @end @@ -53,11 +55,11 @@ - (void)reset { ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; self.activityHandlerMock = [[ADJActivityHandlerMock alloc] initWithConfig:config]; - self.attributionPackage = [self getAttributionPackage:config]; + [self savePackages:config]; [NSURLConnection reset]; } -- (ADJActivityPackage *)getAttributionPackage:(ADJConfig *)config { +- (void)savePackages:(ADJConfig *)config { ADJAttributionHandlerMock * attributionHandlerMock = [ADJAttributionHandlerMock alloc]; [ADJAdjustFactory setAttributionHandler:attributionHandlerMock]; @@ -69,8 +71,11 @@ - (ADJActivityPackage *)getAttributionPackage:(ADJConfig *)config { [ADJAdjustFactory setTimerInterval:-1]; [ADJAdjustFactory setTimerStart:-1]; + [ADJTestsUtil deleteFile:@"AdjustIoActivityState" logger:self.loggerMock]; + [ADJTestsUtil deleteFile:@"AdjustIoAttribution" logger:self.loggerMock]; + [ADJActivityHandler handlerWithConfig:config]; - [NSThread sleepForTimeInterval:2.0]; + [NSThread sleepForTimeInterval:5.0]; ADJActivityPackage * attributionPackage = attributionHandlerMock.attributionPackage; @@ -78,9 +83,11 @@ - (ADJActivityPackage *)getAttributionPackage:(ADJConfig *)config { [self testAttributionPackage:attributionPackage fields:fields]; - [self.loggerMock reset]; + self.firstSessionPackage = packageHandlerMock.packageQueue[0]; + + self.attributionPackage = attributionPackage; - return attributionPackage; + [self.loggerMock reset]; } - (void)testGetAttribution @@ -88,10 +95,10 @@ - (void)testGetAttribution // reseting to make the test order independent [self reset]; - id attributionHandler = [ADJAttributionHandler handlerWithActivityHandler:self.activityHandlerMock withAttributionPackage:self.attributionPackage startPaused:NO hasDelegate:YES]; + id attributionHandler = [ADJAttributionHandler handlerWithActivityHandler:self.activityHandlerMock withAttributionPackage:self.attributionPackage startPaused:NO hasAttributionChangedDelegate:YES]; // test null response without error - [self checkGetAttributionResponse:attributionHandler responseType:ADJResponseTypeNil]; + [self checkGetAttributionResponse:attributionHandler responseType:ADJSessionResponseTypeNil]; // check empty error aError(@"Failed to get attribution (empty error)"); @@ -100,32 +107,32 @@ - (void)testGetAttribution anVerbose(@"Response"); // test client exception - [self checkGetAttributionResponse:attributionHandler responseType:ADJResponseTypeConnError]; + [self checkGetAttributionResponse:attributionHandler responseType:ADJSessionResponseTypeConnError]; // check the client error aError(@"Failed to get attribution (connection error)"); // test wrong json response - [self checkGetAttributionResponse:attributionHandler responseType:ADJResponseTypeWrongJson]; + [self checkGetAttributionResponse:attributionHandler responseType:ADJSessionResponseTypeWrongJson]; aVerbose(@"Response: not a json response"); aError(@"Failed to parse json response. (The data couldn’t be read because it isn’t in the correct format.)"); // test empty response - [self checkGetAttributionResponse:attributionHandler responseType:ADJResponseTypeEmptyJson]; + [self checkGetAttributionResponse:attributionHandler responseType:ADJSessionResponseTypeEmptyJson]; aVerbose(@"Response: { }"); aInfo(@"No message found"); - // check attribution was called without ask_in - aTest(@"ActivityHandler updateAttribution, (null)"); - aTest(@"ActivityHandler setAskingAttribution, 0"); + // check attribution was called without ask_in + aTest(@"ActivityHandler launchAttributionChangedDelegate, message:(null) timestamp:(null) adid:(null) eventToken:(null) success:1 willRetry:0 attribution:(null) json:{\n}"); + // test server error - [self checkGetAttributionResponse:attributionHandler responseType:ADJResponseTypeServerError]; + [self checkGetAttributionResponse:attributionHandler responseType:ADJSessionResponseTypeServerError]; // the response logged aVerbose(@"Response: { \"message\": \"testResponseError\"}"); @@ -133,23 +140,23 @@ - (void)testGetAttribution // the message in the response aError(@"testResponseError"); - // check attribution was called without ask_in - aTest(@"ActivityHandler updateAttribution, (null)"); - aTest(@"ActivityHandler setAskingAttribution, 0"); + // check attribution was called without ask_in + aTest(@"ActivityHandler launchAttributionChangedDelegate, message:testResponseError timestamp:(null) json:{\n message = testResponseError;\n}"); + // test ok response with message - [self checkGetAttributionResponse:attributionHandler responseType:ADJResponseTypeMessage]; + [self checkGetAttributionResponse:attributionHandler responseType:ADJSessionResponseTypeMessage]; [self checkOkMessageGetAttributionResponse]; } -- (void)testCheckAttribution +- (void)testCheckSessionResponse { // reseting to make the test order independent [self reset]; - id attributionHandler = [ADJAttributionHandler handlerWithActivityHandler:self.activityHandlerMock withAttributionPackage:self.attributionPackage startPaused:NO hasDelegate:YES]; + id attributionHandler = [ADJAttributionHandler handlerWithActivityHandler:self.activityHandlerMock withAttributionPackage:self.attributionPackage startPaused:NO hasAttributionChangedDelegate:YES]; NSMutableDictionary * attributionDictionary = [[NSMutableDictionary alloc] init]; [attributionDictionary setObject:@"ttValue" forKey:@"tracker_token"]; @@ -163,11 +170,11 @@ - (void)testCheckAttribution NSMutableDictionary * jsonDictionary = [[NSMutableDictionary alloc] init]; [jsonDictionary setObject:attributionDictionary forKey:@"attribution"]; - [attributionHandler checkAttribution:jsonDictionary]; - [NSThread sleepForTimeInterval:1.0]; + ADJResponseData * sessionResponseData = [[ADJResponseData alloc] initWithActivityPackage:self.firstSessionPackage]; + sessionResponseData.jsonResponse = jsonDictionary; - // check attribution was called without ask_in - aTest(@"ActivityHandler updateAttribution, tt:ttValue tn:tnValue net:nValue cam:cpValue adg:aValue cre:ctValue cl:clValue"); + [attributionHandler checkSessionResponse:sessionResponseData]; + [NSThread sleepForTimeInterval:2.0]; // updated set askingAttribution to false aTest(@"ActivityHandler setAskingAttribution, 0"); @@ -177,6 +184,9 @@ - (void)testCheckAttribution // and waiting for query anDebug(@"Waiting to query attribution"); + + // check attribution changed delegate was called + aTest(@"ActivityHandler launchAttributionChangedDelegateWithDeeplink, message:(null) timestamp:(null) adid:(null) eventToken:(null) success:0 willRetry:0 attribution:tt:ttValue tn:tnValue net:nValue cam:cpValue adg:aValue cre:ctValue cl:clValue"); } - (void)testAskIn @@ -184,15 +194,18 @@ - (void)testAskIn // reseting to make the test order independent [self reset]; - id attributionHandler = [ADJAttributionHandler handlerWithActivityHandler:self.activityHandlerMock withAttributionPackage:self.attributionPackage startPaused:NO hasDelegate:YES]; + id attributionHandler = [ADJAttributionHandler handlerWithActivityHandler:self.activityHandlerMock withAttributionPackage:self.attributionPackage startPaused:NO hasAttributionChangedDelegate:YES]; NSMutableDictionary * askIn4sDictionary = [[NSMutableDictionary alloc] init]; [askIn4sDictionary setObject:@"4000" forKey:@"ask_in"]; // set null response to avoid a cycle; - [NSURLConnection setResponseType:ADJResponseTypeMessage]; + [NSURLSession setResponseType:ADJSessionResponseTypeMessage]; + + ADJResponseData * sessionResponseData = [[ADJResponseData alloc] initWithActivityPackage:self.firstSessionPackage]; + sessionResponseData.jsonResponse = askIn4sDictionary; - [attributionHandler checkAttribution:askIn4sDictionary]; + [attributionHandler checkSessionResponse:sessionResponseData]; // sleep enough not to trigger the timer [NSThread sleepForTimeInterval:1.0]; @@ -212,7 +225,9 @@ - (void)testAskIn NSMutableDictionary * askIn5sDictionary = [[NSMutableDictionary alloc] init]; [askIn5sDictionary setObject:@"5000" forKey:@"ask_in"]; - [attributionHandler checkAttribution:askIn5sDictionary]; + sessionResponseData.jsonResponse = askIn5sDictionary; + + [attributionHandler checkSessionResponse:sessionResponseData]; // sleep enough not to trigger the old timer [NSThread sleepForTimeInterval:3.0]; @@ -225,13 +240,13 @@ - (void)testAskIn // it was been waiting for 1000 + 2000 + 3000 = 6 seconds // check that the mock http client was not called because the original clock was reseted - anTest(@"NSURLConnection sendSynchronousRequest"); + anTest(@"NSURLSession dataTaskWithRequest"); // check that it was finally called after 7 seconds after the second ask_in [NSThread sleepForTimeInterval:4.0]; // test ok response with message - aTest(@"NSURLConnection sendSynchronousRequest"); + aTest(@"NSURLSession dataTaskWithRequest"); [self checkOkMessageGetAttributionResponse]; @@ -243,9 +258,9 @@ - (void)testPause // reseting to make the test order independent [self reset]; - id attributionHandler = [ADJAttributionHandler handlerWithActivityHandler:self.activityHandlerMock withAttributionPackage:self.attributionPackage startPaused:YES hasDelegate:YES]; + id attributionHandler = [ADJAttributionHandler handlerWithActivityHandler:self.activityHandlerMock withAttributionPackage:self.attributionPackage startPaused:YES hasAttributionChangedDelegate:YES]; - [NSURLConnection setResponseType:ADJResponseTypeMessage]; + [NSURLSession setResponseType:ADJSessionResponseTypeMessage]; [attributionHandler getAttribution]; @@ -257,8 +272,7 @@ - (void)testPause // and it did not call the http client aNil([NSURLConnection getLastRequest]); - anTest(@"NSURLConnection sendSynchronousRequest"); - + anTest(@"NSURLSession dataTaskWithRequest"); } - (void)testWithoutListener @@ -266,7 +280,7 @@ - (void)testWithoutListener // reseting to make the test order independent [self reset]; - id attributionHandler = [ADJAttributionHandler handlerWithActivityHandler:self.activityHandlerMock withAttributionPackage:self.attributionPackage startPaused:NO hasDelegate:NO]; + id attributionHandler = [ADJAttributionHandler handlerWithActivityHandler:self.activityHandlerMock withAttributionPackage:self.attributionPackage startPaused:NO hasAttributionChangedDelegate:NO]; [NSURLConnection setResponseType:ADJResponseTypeMessage]; @@ -280,7 +294,7 @@ - (void)testWithoutListener // but it did not call the http client aNil([NSURLConnection getLastRequest]); - anTest(@"NSURLConnection sendSynchronousRequest"); + anTest(@"NSURLSession dataTaskWithRequest"); } - (void)checkOkMessageGetAttributionResponse @@ -292,24 +306,25 @@ - (void)checkOkMessageGetAttributionResponse aInfo(@"response OK"); // check attribution was called without ask_in - aTest(@"ActivityHandler updateAttribution, (null)"); - aTest(@"ActivityHandler setAskingAttribution, 0"); + + aTest(@"ActivityHandler launchAttributionChangedDelegate, message:response OK timestamp:(null) adid:(null) eventToken:(null) success:1 willRetry:0 attribution:(null) json:{\n message = \"response OK\";\n}"); } - (void)checkGetAttributionResponse:(id) attributionHandler - responseType:(ADJResponseType)responseType + responseType:(ADJSessionResponseType)responseType { - [NSURLConnection setResponseType:responseType]; + //[NSURLConnection setResponseType:responseType]; + [NSURLSession setResponseType:responseType]; [attributionHandler getAttribution]; - [NSThread sleepForTimeInterval:1.0]; + [NSThread sleepForTimeInterval:2.0]; // delay time is 0 anDebug(@"Waiting to query attribution"); // it tried to send the request - aTest(@"NSURLConnection sendSynchronousRequest"); + aTest(@"NSURLSession dataTaskWithRequest"); [self checkRequest:[NSURLConnection getLastRequest]]; } diff --git a/AdjustTests/ADJPackageFields.h b/AdjustTests/ADJPackageFields.h index 2c645370e..918f68d93 100644 --- a/AdjustTests/ADJPackageFields.h +++ b/AdjustTests/ADJPackageFields.h @@ -17,6 +17,7 @@ @property (nonatomic, copy) NSString* deepLinkParameters; @property (nonatomic, copy) NSString* purchaseTime; @property (nonatomic, copy) NSString* iadTime; +@property (nonatomic, copy) NSString* iadDetails; // ADJConfig @property (nonatomic, copy) NSString *appToken; @property (nonatomic, copy) NSString *environment; diff --git a/AdjustTests/ADJPackageHandlerMock.m b/AdjustTests/ADJPackageHandlerMock.m index f246841e2..d7aa9737e 100644 --- a/AdjustTests/ADJPackageHandlerMock.m +++ b/AdjustTests/ADJPackageHandlerMock.m @@ -41,7 +41,7 @@ - (id)initWithActivityHandler:(id)activityHandler self.loggerMock = (ADJLoggerMock *) ADJAdjustFactory.logger; self.packageQueue = [NSMutableArray array]; - [self.loggerMock test:[NSString stringWithFormat:@"%@initWithActivityHandler, paused: %d", prefix, startPaused]]; + [self.loggerMock test:[prefix stringByAppendingFormat:@"initWithActivityHandler, paused: %d", startPaused]]; return self; } @@ -55,11 +55,11 @@ - (void)sendFirstPackage { [self.loggerMock test:[prefix stringByAppendingString:@"sendFirstPackage"]]; } -- (void)sendNextPackage { +- (void)sendNextPackage:(ADJResponseData *)responseData { [self.loggerMock test:[prefix stringByAppendingString:@"sendNextPackage"]]; } -- (void)closeFirstPackage { +- (void)closeFirstPackage:(ADJResponseData *)responseData { [self.loggerMock test:[prefix stringByAppendingString:@"closeFirstPackage"]]; } diff --git a/AdjustTests/ADJPackageHandlerTests.m b/AdjustTests/ADJPackageHandlerTests.m index 215af568e..20687720c 100644 --- a/AdjustTests/ADJPackageHandlerTests.m +++ b/AdjustTests/ADJPackageHandlerTests.m @@ -65,7 +65,7 @@ - (void)testAddPackage [self reset]; // initialize Package Handler - id packageHandler = [self createPackageHandler]; + id packageHandler = [self createFirstPackageHandler]; ADJActivityPackage *firstClickPackage = [ADJTestsUtil getClickPackage:@"FirstPackage"]; @@ -75,7 +75,7 @@ - (void)testAddPackage [self checkAddPackage:1 packageString:@"clickFirstPackage"]; id secondPackageHandler = [self checkAddSecondPackage:nil]; - + ADJActivityPackage *secondClickPackage = [ADJTestsUtil getClickPackage:@"ThirdPackage"]; [secondPackageHandler addPackage:secondClickPackage]; @@ -90,13 +90,13 @@ - (void)testAddPackage aTest(@"RequestHandler sendPackage, clickFirstPackage"); // send the second click package/ third package - [secondPackageHandler sendNextPackage]; + [secondPackageHandler sendNextPackage:nil]; [NSThread sleepForTimeInterval:1.0]; aTest(@"RequestHandler sendPackage, clickThirdPackage"); // send the unknow package/ second package - [secondPackageHandler sendNextPackage]; + [secondPackageHandler sendNextPackage:nil]; [NSThread sleepForTimeInterval:1.0]; aTest(@"RequestHandler sendPackage, unknownSecondPackage"); @@ -108,7 +108,7 @@ - (void)testSendFirst [self reset]; // initialize Package Handler - id packageHandler = [self createPackageHandler]; + id packageHandler = [self createFirstPackageHandler]; [self checkSendFirst:ADJSendFirstEmptyQueue]; @@ -151,7 +151,7 @@ - (void)testSendNext [self reset]; // initialize Package Handler - id packageHandler = [self createPackageHandler]; + id packageHandler = [self createFirstPackageHandler]; // add and send the first package [self checkAddAndSendFirst:packageHandler]; @@ -166,7 +166,7 @@ - (void)testSendNext [self checkAddSecondPackage:packageHandler]; //send next package - [packageHandler sendNextPackage]; + [packageHandler sendNextPackage:nil]; [NSThread sleepForTimeInterval:2.0]; aDebug(@"Package handler wrote 1 packages"); @@ -181,7 +181,7 @@ - (void)testCloseFirstPackage [self reset]; // initialize Package Handler - id packageHandler = [self createPackageHandler]; + id packageHandler = [self createFirstPackageHandler]; [self checkAddAndSendFirst:packageHandler]; @@ -192,7 +192,7 @@ - (void)testCloseFirstPackage [self checkSendFirst:ADJSendFirstIsSending]; //send next package - [packageHandler closeFirstPackage]; + [packageHandler closeFirstPackage:nil]; [NSThread sleepForTimeInterval:2.0]; anDebug(@"Package handler wrote"); @@ -204,46 +204,39 @@ - (void)testCloseFirstPackage [self checkSendFirst:ADJSendFirstSend packageString:@"unknownFirstPackage"]; } -- (void)testCalls +- (id)createFirstPackageHandler { - // reseting to make the test order independent - [self reset]; + return [self createFirstPackageHandler:NO]; +} +- (id)createFirstPackageHandler:(BOOL)startPaused +{ // initialize Package Handler - id packageHandler = [self createPackageHandler:YES]; - - ADJActivityPackage *firstActivityPackage = [ADJTestsUtil getUnknowPackage:@"FirstPackage"]; - - [packageHandler addPackage:firstActivityPackage]; - [packageHandler sendFirstPackage]; + id packageHandler = [ADJAdjustFactory packageHandlerForActivityHandler:self.activityHandlerMock + startPaused:startPaused]; [NSThread sleepForTimeInterval:2.0]; - [self checkAddPackage:1 packageString:@"unknownFirstPackage"]; - - [self checkSendFirst:ADJSendFirstPaused]; - - [packageHandler finishedTracking:nil]; - - aTest(@"ActivityHandler finishedTracking, (null)"); -} + aVerbose(@"Package queue file not found"); -- (id)createPackageHandler -{ - return [self createPackageHandler:NO]; + return packageHandler; } -- (id)createPackageHandler:(BOOL)startPaused +- (id)checkAddSecondPackage { - // initialize Package Handler id packageHandler = [ADJAdjustFactory packageHandlerForActivityHandler:self.activityHandlerMock - startPaused:startPaused]; + startPaused:NO]; + [NSThread sleepForTimeInterval:2.0]; - aVerbose(@"Package queue file not found"); + ADJActivityPackage * secondActivityPackage = [ADJTestsUtil getUnknowPackage:@"SecondPackage"]; + + [packageHandler addPackage:secondActivityPackage]; + [NSThread sleepForTimeInterval:1.0]; return packageHandler; } + - (id)checkAddSecondPackage:(id)packageHandler { if (packageHandler == nil) { @@ -256,8 +249,8 @@ - (void)testCalls // check that it can read the previously saved package aDebug(@"Package handler read 1 packages"); - } + ADJActivityPackage * secondActivityPackage = [ADJTestsUtil getUnknowPackage:@"SecondPackage"]; [packageHandler addPackage:secondActivityPackage]; diff --git a/AdjustTests/ADJRequestHandlerMock.m b/AdjustTests/ADJRequestHandlerMock.m index f6325c905..2200a273d 100644 --- a/AdjustTests/ADJRequestHandlerMock.m +++ b/AdjustTests/ADJRequestHandlerMock.m @@ -15,7 +15,7 @@ @interface ADJRequestHandlerMock() @property (nonatomic, assign) id packageHandler; -@property (nonatomic, assign) ADJLoggerMock *loggerMock; +@property (nonatomic, strong) ADJLoggerMock *loggerMock; @end diff --git a/AdjustTests/ADJTest.h b/AdjustTests/ADJTest.h index 5b1f7b743..30fff214e 100644 --- a/AdjustTests/ADJTest.h +++ b/AdjustTests/ADJTest.h @@ -60,6 +60,9 @@ // assert not warn log #define anWarn(message) anLevel(message, ADJLogLevelWarn) +// assert not error log +#define anError(message) anLevel(message, ADJLogLevelError) + // assert not assert log #define anAssert(message) anLevel(message, ADJLogLevelAssert) diff --git a/AdjustTests/ADJTestActivityPackage.m b/AdjustTests/ADJTestActivityPackage.m index 2135d09c5..7445a96df 100644 --- a/AdjustTests/ADJTestActivityPackage.m +++ b/AdjustTests/ADJTestActivityPackage.m @@ -155,7 +155,7 @@ - (void)testClickPackage:(ADJActivityPackage *)package // click_time // TODO test click time - if (fields.iadTime == nil) { + if ([source isEqualToString:@"deeplink"]) { appnNil(@"click_time"); } else { apspEquals(@"click_time", fields.iadTime); @@ -185,6 +185,8 @@ - (void)testClickPackage:(ADJActivityPackage *)package apspEquals(@"creative", fields.attribution.creative); } + // details + apspEquals(@"details", fields.iadDetails); } - (void)testAttributionPackage:(ADJActivityPackage *)package @@ -285,9 +287,9 @@ - (void)testConfig:(ADJActivityPackage *)package apspEquals(@"environment", fields.environment); // needs_attribution_data if (fields.hasDelegate == nil) { - appnNil(@"needs_attribution_data"); + appnNil(@"needs_response_details"); } else { - apspEquals(@"needs_attribution_data", fields.hasDelegate); + apspEquals(@"needs_response_details", fields.hasDelegate); } } @@ -338,14 +340,17 @@ - (BOOL)assertJsonParameters:(ADJActivityPackage *)package // value not nil anlNil(value, package.extendedString); + NSError *error = nil; + NSException *exception = nil; + NSData * parameterData = [parameterValue dataUsingEncoding:NSUTF8StringEncoding]; - NSDictionary * parameterDictionary = [ADJUtil buildJsonDict:parameterData]; + NSDictionary * parameterDictionary = [ADJUtil buildJsonDict:parameterData exceptionPtr:&exception errorPtr:&error]; // check parameter parses from Json string anlNil(parameterDictionary, package.extendedString); NSData * valueData = [value dataUsingEncoding:NSUTF8StringEncoding]; - NSDictionary * valueDictionary = [ADJUtil buildJsonDict:valueData]; + NSDictionary * valueDictionary = [ADJUtil buildJsonDict:valueData exceptionPtr:&exception errorPtr:&error]; // check value parses from Json string anlNil(valueDictionary, package.extendedString); diff --git a/AdjustTests/ADJTrackingFailedDelegate.h b/AdjustTests/ADJTrackingFailedDelegate.h new file mode 100644 index 000000000..1287335a5 --- /dev/null +++ b/AdjustTests/ADJTrackingFailedDelegate.h @@ -0,0 +1,14 @@ +// +// ADJTrackingFailedDelegate.h +// adjust +// +// Created by Pedro Filipe on 22/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import +#import "Adjust.h" + +@interface ADJTrackingFailedDelegate : NSObject + +@end diff --git a/AdjustTests/ADJTrackingFailedDelegate.m b/AdjustTests/ADJTrackingFailedDelegate.m new file mode 100644 index 000000000..f199c3c3e --- /dev/null +++ b/AdjustTests/ADJTrackingFailedDelegate.m @@ -0,0 +1,38 @@ +// +// ADJTrackingFailedDelegate.m +// adjust +// +// Created by Pedro Filipe on 22/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import "ADJTrackingFailedDelegate.h" +#import "ADJLoggerMock.h" +#import "ADJAdjustFactory.h" + +static NSString * const prefix = @"ADJTrackingFailedDelegate "; + +@interface ADJTrackingFailedDelegate() + +@property (nonatomic, strong) ADJLoggerMock *loggerMock; + +@end + +@implementation ADJTrackingFailedDelegate + +- (id) init { + self = [super init]; + if (self == nil) return nil; + + self.loggerMock = (ADJLoggerMock *) [ADJAdjustFactory logger]; + + [self.loggerMock test:[prefix stringByAppendingFormat:@"init"]]; + + return self; +} + +- (void)adjustTrackingFailed:(ADJFailureResponseData *)failureResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"adjustTrackingFailed, %@", failureResponseData]]; +} + +@end diff --git a/AdjustTests/ADJTrackingSucceededDelegate.h b/AdjustTests/ADJTrackingSucceededDelegate.h new file mode 100644 index 000000000..0fd1d3098 --- /dev/null +++ b/AdjustTests/ADJTrackingSucceededDelegate.h @@ -0,0 +1,14 @@ +// +// ADJTrackingSucceededDelegate.h +// adjust +// +// Created by Pedro Filipe on 22/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import +#import "Adjust.h" + +@interface ADJTrackingSucceededDelegate : NSObject + +@end diff --git a/AdjustTests/ADJTrackingSucceededDelegate.m b/AdjustTests/ADJTrackingSucceededDelegate.m new file mode 100644 index 000000000..ef32d1817 --- /dev/null +++ b/AdjustTests/ADJTrackingSucceededDelegate.m @@ -0,0 +1,38 @@ +// +// ADJTrackingSucceededDelegate.m +// adjust +// +// Created by Pedro Filipe on 22/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import "ADJTrackingSucceededDelegate.h" +#import "ADJLoggerMock.h" +#import "ADJAdjustFactory.h" + +static NSString * const prefix = @"ADJTrackingSucceededDelegate "; + +@interface ADJTrackingSucceededDelegate() + +@property (nonatomic, strong) ADJLoggerMock *loggerMock; + +@end + +@implementation ADJTrackingSucceededDelegate + +- (id) init { + self = [super init]; + if (self == nil) return nil; + + self.loggerMock = (ADJLoggerMock *) [ADJAdjustFactory logger]; + + [self.loggerMock test:[prefix stringByAppendingFormat:@"init"]]; + + return self; +} + +- (void)adjustTrackingSucceeded:(ADJSuccessResponseData *)successResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"adjustTrackingSucceeded, %@", successResponseData]]; +} + +@end diff --git a/AdjustTests/AIRequestHandlerTests.m b/AdjustTests/AIRequestHandlerTests.m index e01d0136a..263431b97 100644 --- a/AdjustTests/AIRequestHandlerTests.m +++ b/AdjustTests/AIRequestHandlerTests.m @@ -10,6 +10,7 @@ #import "ADJAdjustFactory.h" #import "ADJLoggerMock.h" #import "NSURLConnection+NSURLConnectionSynchronousLoadingMocking.h" +#import "NSURLSession+NSURLDataWithRequestMocking.h" #import "ADJPackageHandlerMock.h" #import "ADJRequestHandlerMock.h" #import "ADJTestsUtil.h" @@ -55,14 +56,14 @@ - (void)reset { - (void)testSend { // null response - [NSURLConnection setResponseType:ADJResponseTypeNil]; + [NSURLSession setResponseType:ADJSessionResponseTypeNil]; [self checkSendPackage]; aTest(@"PackageHandler closeFirstPackage"); // client exception - [NSURLConnection setResponseType:ADJResponseTypeConnError]; + [NSURLSession setResponseType:ADJSessionResponseTypeConnError]; [self checkSendPackage]; @@ -71,7 +72,7 @@ - (void)testSend aTest(@"PackageHandler closeFirstPackage"); // server error - [NSURLConnection setResponseType:ADJResponseTypeServerError]; + [NSURLSession setResponseType:ADJSessionResponseTypeServerError]; [self checkSendPackage]; @@ -79,12 +80,10 @@ - (void)testSend aError(@"testResponseError"); - aTest(@"PackageHandler finishedTracking, \"message\" = \"testResponseError\";"); - aTest(@"PackageHandler sendNextPackage"); // wrong json - [NSURLConnection setResponseType:ADJResponseTypeWrongJson]; + [NSURLSession setResponseType:ADJSessionResponseTypeWrongJson]; [self checkSendPackage]; @@ -95,7 +94,7 @@ - (void)testSend aTest(@"PackageHandler closeFirstPackage"); // empty json - [NSURLConnection setResponseType:ADJResponseTypeEmptyJson]; + [NSURLSession setResponseType:ADJSessionResponseTypeEmptyJson]; [self checkSendPackage]; @@ -103,12 +102,10 @@ - (void)testSend aInfo(@"No message found"); - aTest(@"PackageHandler finishedTracking, "); - aTest(@"PackageHandler sendNextPackage"); // message response - [NSURLConnection setResponseType:ADJResponseTypeMessage]; + [NSURLSession setResponseType:ADJSessionResponseTypeMessage]; [self checkSendPackage]; @@ -116,8 +113,6 @@ - (void)testSend aInfo(@"response OK"); - aTest(@"PackageHandler finishedTracking, \"message\" = \"response OK\";"); - aTest(@"PackageHandler sendNextPackage"); } @@ -127,7 +122,7 @@ - (void)checkSendPackage [NSThread sleepForTimeInterval:1.0]; - aTest(@"NSURLConnection sendSynchronousRequest"); + aTest(@"NSURLSession dataTaskWithRequest"); } @end diff --git a/AdjustTests/NSURLSession+NSURLDataWithRequestMocking.h b/AdjustTests/NSURLSession+NSURLDataWithRequestMocking.h new file mode 100644 index 000000000..cc72b9422 --- /dev/null +++ b/AdjustTests/NSURLSession+NSURLDataWithRequestMocking.h @@ -0,0 +1,36 @@ +// +// NSURLSession+NSURLDataWithRequestMocking.h +// adjust +// +// Created by Pedro Filipe on 25/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import + +typedef enum { + ADJSessionResponseTypeNil = 0, + ADJSessionResponseTypeConnError = 1, + ADJSessionResponseTypeWrongJson = 2, + ADJSessionResponseTypeEmptyJson = 3, + ADJSessionResponseTypeServerError = 4, + ADJSessionResponseTypeMessage = 5, +} ADJSessionResponseType; + +@interface NSURLSession(NSURLDataWithRequestMocking) + +/* Creates a data task with the given request. The request may have a body stream. */ +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSData * data, NSURLResponse * response, NSError * error))completionHandler; + ++ (void)setResponseType:(ADJSessionResponseType)responseType; ++ (NSURLResponse *)getLastRequest; ++ (void)reset; + +@end + +@interface NSURLSessionDataTask(NSURLResume) + +- (void)resume; + +@end \ No newline at end of file diff --git a/AdjustTests/NSURLSession+NSURLDataWithRequestMocking.m b/AdjustTests/NSURLSession+NSURLDataWithRequestMocking.m new file mode 100644 index 000000000..2496aa4dd --- /dev/null +++ b/AdjustTests/NSURLSession+NSURLDataWithRequestMocking.m @@ -0,0 +1,98 @@ +// +// NSURLSession+NSURLDataWithRequestMocking.m +// adjust +// +// Created by Pedro Filipe on 25/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import "NSURLSession+NSURLDataWithRequestMocking.h" +#import "ADJAdjustFactory.h" +#import "ADJLoggerMock.h" + +static ADJSessionResponseType sessionResponseTypeInternal; +static NSURLRequest * lastRequest = nil; + +static NSData * completionData = nil; +static NSURLResponse * completionResponse = nil; +static NSError * completionError = nil; + +static void (^completionDelegate) (NSData * data, NSURLResponse * response, NSError * error) = nil; + +@implementation NSURLSession(NSURLDataWithRequestMocking) + +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSData * data, NSURLResponse * response, NSError * error))completionHandler +{ + ADJLoggerMock *loggerMock =(ADJLoggerMock *)ADJAdjustFactory.logger; + [loggerMock test:@"NSURLSession dataTaskWithRequest"]; + + lastRequest = request; + NSInteger statusCode = -1; + NSString * sResponse = nil; + completionDelegate = completionHandler; + + completionResponse = nil; + completionData = nil; + completionError = nil; + + if (sessionResponseTypeInternal == ADJSessionResponseTypeNil) { + + } else if (sessionResponseTypeInternal == ADJSessionResponseTypeConnError) { + NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: NSLocalizedString(@"connection error", nil) }; + completionError = [NSError errorWithDomain:@"Adjust" + code:-57 + userInfo:userInfo]; + } else if (sessionResponseTypeInternal == ADJSessionResponseTypeServerError) { + statusCode = 500; + sResponse = @"{ \"message\": \"testResponseError\"}"; + } else if (sessionResponseTypeInternal == ADJSessionResponseTypeWrongJson) { + statusCode = 200; + sResponse = @"not a json response"; + } else if (sessionResponseTypeInternal == ADJSessionResponseTypeEmptyJson) { + statusCode = 200; + sResponse = @"{ }"; + } else if (sessionResponseTypeInternal == ADJSessionResponseTypeMessage) { + statusCode = 200; + sResponse = @"{ \"message\" : \"response OK\"}"; + } + + // build response + if (statusCode != -1) { + completionResponse = [[NSHTTPURLResponse alloc] initWithURL:[[NSURL alloc] init] statusCode:statusCode HTTPVersion:@"" headerFields:nil]; + } + + if (sResponse != nil) { + completionData = [sResponse dataUsingEncoding:NSUTF8StringEncoding]; + } + + return [[NSURLSessionDataTask alloc] init]; +} + ++ (void)setResponseType:(ADJSessionResponseType)responseType { + sessionResponseTypeInternal = responseType; +} + ++ (NSURLRequest *)getLastRequest +{ + return lastRequest; +} + ++ (void)reset { + sessionResponseTypeInternal = ADJSessionResponseTypeNil; + lastRequest = nil; +} + +@end + +@implementation NSURLSessionDataTask(NSURLResume) + +- (void)resume +{ + ADJLoggerMock *loggerMock =(ADJLoggerMock *)ADJAdjustFactory.logger; + [loggerMock test:@"NSURLSessionDataTask resume"]; + + completionDelegate(completionData, completionResponse, completionError); +} + +@end From 0fb328b2c0e777e4564b3d7a9909f7485e6f8170 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 16 Feb 2016 17:02:32 +0100 Subject: [PATCH 20/33] Send click package --- Adjust/ADJActivityHandler.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index 82d76d0b4..2200c3c7d 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -275,6 +275,7 @@ - (void)setIadDate:(NSDate *)iAdImpressionDate withPurchaseDate:(NSDate *)appPur ADJActivityPackage *clickPackage = [clickBuilder buildClickPackage:@"iad"]; [self.packageHandler addPackage:clickPackage]; + [self.packageHandler sendFirstPackage]; } - (void)setIadDetails:(NSDictionary *)attributionDetails @@ -313,6 +314,7 @@ - (void)setIadDetails:(NSDictionary *)attributionDetails ADJActivityPackage *clickPackage = [clickBuilder buildClickPackage:@"iad3"]; [self.packageHandler addPackage:clickPackage]; + [self.packageHandler sendFirstPackage]; } - (void)setAskingAttribution:(BOOL)askingAttribution { @@ -612,6 +614,7 @@ - (void) appWillOpenUrlInternal:(NSURL *)url { ADJActivityPackage *clickPackage = [clickBuilder buildClickPackage:@"deeplink"]; [self.packageHandler addPackage:clickPackage]; + [self.packageHandler sendFirstPackage]; } - (BOOL) readDeeplinkQueryString:(NSString *)queryString From 5c4e91a35a8f5031dda572eef238101b7e92d192 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 16 Feb 2016 17:02:48 +0100 Subject: [PATCH 21/33] Remove unused function --- Adjust/ADJActivityHandler.m | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index 2200c3c7d..48933f439 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -537,26 +537,6 @@ - (void) launchAttributionChangedDelegateInternal:(ADJResponseData *)responseDat } } -- (void) launchAttributionChangedDelegate:(ADJResponseData *)responseData - tryDeeplink:(BOOL)tryDeeplink -{ - BOOL launchAttributionCallback = [self updateAttribution:responseData.attribution]; - - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - // try to update and launch the attribution changed listener - if (launchAttributionCallback) { - [self.adjustDelegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) - withObject:responseData.attribution - waitUntilDone:YES]; - } - // if possible, try to launch the deeplink - if (tryDeeplink) { - [self launchDeepLink:responseData.jsonResponse]; - } - }); - -} - - (BOOL)updateAttribution:(ADJAttribution *)attribution { if (attribution == nil) { return NO; From 4941df6b60b1ba04c8e66995b5356828b4d81493 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 17 Feb 2016 17:17:12 +0100 Subject: [PATCH 22/33] Add Session delegate --- Adjust.xcodeproj/project.pbxproj | 56 ++--- Adjust/ADJActivityHandler.h | 5 +- Adjust/ADJActivityHandler.m | 82 +++++--- Adjust/ADJAttributionHandler.h | 4 +- Adjust/ADJAttributionHandler.m | 24 ++- Adjust/ADJConfig.h | 28 ++- Adjust/ADJConfig.m | 20 +- Adjust/ADJEventFailure.h | 37 ++++ ...ailureResponseData.m => ADJEventFailure.m} | 14 +- Adjust/ADJEventSuccess.h | 34 +++ ...uccessResponseData.m => ADJEventSuccess.m} | 14 +- Adjust/ADJResponseData.h | 42 +++- Adjust/ADJResponseData.m | 193 +++++++++++++++--- ...lureResponseData.h => ADJSessionFailure.h} | 7 +- Adjust/ADJSessionFailure.m | 54 +++++ ...cessResponseData.h => ADJSessionSuccess.h} | 7 +- Adjust/ADJSessionSuccess.m | 52 +++++ Adjust/ADJUtil.m | 2 +- .../project.pbxproj | 36 ++-- .../AdjustExample-iOS/AppDelegate.m | 26 ++- .../project.pbxproj | 24 +-- .../AdjustExample-tvOS/AppDelegate.m | 30 ++- 22 files changed, 613 insertions(+), 178 deletions(-) create mode 100644 Adjust/ADJEventFailure.h rename Adjust/{ADJFailureResponseData.m => ADJEventFailure.m} (77%) create mode 100644 Adjust/ADJEventSuccess.h rename Adjust/{ADJSuccessResponseData.m => ADJEventSuccess.m} (76%) rename Adjust/{ADJFailureResponseData.h => ADJSessionFailure.h} (80%) create mode 100644 Adjust/ADJSessionFailure.m rename Adjust/{ADJSuccessResponseData.h => ADJSessionSuccess.h} (77%) create mode 100644 Adjust/ADJSessionSuccess.m diff --git a/Adjust.xcodeproj/project.pbxproj b/Adjust.xcodeproj/project.pbxproj index 07d70d400..af9ac4232 100644 --- a/Adjust.xcodeproj/project.pbxproj +++ b/Adjust.xcodeproj/project.pbxproj @@ -24,6 +24,10 @@ /* Begin PBXBuildFile section */ 9601C1A01A31DD8900A9AE21 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9601C19C1A31DD7F00A9AE21 /* CoreTelephony.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 9601C1A31A31DE0D00A9AE21 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9601C1A11A31DE0300A9AE21 /* SystemConfiguration.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + 9601CAE41C74B70600670879 /* ADJEventSuccess.h in Headers */ = {isa = PBXBuildFile; fileRef = 9601CAE21C74B70600670879 /* ADJEventSuccess.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9601CAE51C74B70600670879 /* ADJEventSuccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 9601CAE31C74B70600670879 /* ADJEventSuccess.m */; }; + 9601CAE81C74BAAE00670879 /* ADJEventFailure.h in Headers */ = {isa = PBXBuildFile; fileRef = 9601CAE61C74BAAE00670879 /* ADJEventFailure.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9601CAE91C74BAAE00670879 /* ADJEventFailure.m in Sources */ = {isa = PBXBuildFile; fileRef = 9601CAE71C74BAAE00670879 /* ADJEventFailure.m */; }; 9609BC6A19EEA55800E02303 /* ADJEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 9609BC6919EEA55800E02303 /* ADJEvent.m */; }; 960A8BB91A029A8000F2BB95 /* ADJConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 960A8BB81A029A8000F2BB95 /* ADJConfig.m */; }; 9620EA451B062D6F009673F1 /* ADJTestActivityPackage.m in Sources */ = {isa = PBXBuildFile; fileRef = 9620EA441B062D6F009673F1 /* ADJTestActivityPackage.m */; }; @@ -38,20 +42,16 @@ 9679921118BBAE2800394606 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679921018BBAE2800394606 /* Foundation.framework */; }; 9679922018BBAE2800394606 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679921018BBAE2800394606 /* Foundation.framework */; }; 9679922518BBAE2800394606 /* libAdjust.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679920D18BBAE2800394606 /* libAdjust.a */; }; - 968173831C3C2D07002AE1DE /* ADJSuccessResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 968173811C3C2D07002AE1DE /* ADJSuccessResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 968173841C3C2D07002AE1DE /* ADJSuccessResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 968173821C3C2D07002AE1DE /* ADJSuccessResponseData.m */; }; - 968173871C3C2D36002AE1DE /* ADJFailureResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 968173851C3C2D36002AE1DE /* ADJFailureResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 968173881C3C2D36002AE1DE /* ADJFailureResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 968173861C3C2D36002AE1DE /* ADJFailureResponseData.m */; }; + 968173831C3C2D07002AE1DE /* ADJSessionSuccess.h in Headers */ = {isa = PBXBuildFile; fileRef = 968173811C3C2D07002AE1DE /* ADJSessionSuccess.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 968173841C3C2D07002AE1DE /* ADJSessionSuccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 968173821C3C2D07002AE1DE /* ADJSessionSuccess.m */; }; + 968173871C3C2D36002AE1DE /* ADJSessionFailure.h in Headers */ = {isa = PBXBuildFile; fileRef = 968173851C3C2D36002AE1DE /* ADJSessionFailure.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 968173881C3C2D36002AE1DE /* ADJSessionFailure.m in Sources */ = {isa = PBXBuildFile; fileRef = 968173861C3C2D36002AE1DE /* ADJSessionFailure.m */; }; 96854A591B1F2779002B2874 /* ADJTimerOnce.h in Headers */ = {isa = PBXBuildFile; fileRef = 96854A571B1F2779002B2874 /* ADJTimerOnce.h */; }; 96854A5A1B1F2779002B2874 /* ADJTimerOnce.m in Sources */ = {isa = PBXBuildFile; fileRef = 96854A581B1F2779002B2874 /* ADJTimerOnce.m */; }; 96854A5F1B1F278C002B2874 /* ADJTimerCycle.h in Headers */ = {isa = PBXBuildFile; fileRef = 96854A5D1B1F278C002B2874 /* ADJTimerCycle.h */; }; 96854A601B1F278C002B2874 /* ADJTimerCycle.m in Sources */ = {isa = PBXBuildFile; fileRef = 96854A5E1B1F278C002B2874 /* ADJTimerCycle.m */; }; 969952CF1A012F5300928462 /* ADJAttributionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 969952CE1A012F5300928462 /* ADJAttributionHandler.m */; }; 969952D21A01309200928462 /* ADJAttribution.m in Sources */ = {isa = PBXBuildFile; fileRef = 969952D11A01309200928462 /* ADJAttribution.m */; }; - 96BA93FB1C3D56D900C96245 /* ADJSuccessResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 968173811C3C2D07002AE1DE /* ADJSuccessResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 96BA93FC1C3D56F400C96245 /* ADJFailureResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 968173851C3C2D36002AE1DE /* ADJFailureResponseData.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 96BA93FD1C3D574F00C96245 /* ADJSuccessResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 968173821C3C2D07002AE1DE /* ADJSuccessResponseData.m */; }; - 96BA93FE1C3D575D00C96245 /* ADJFailureResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 968173861C3C2D36002AE1DE /* ADJFailureResponseData.m */; }; 96BCFBCD1AC99231005A65C5 /* Adjust.h in Headers */ = {isa = PBXBuildFile; fileRef = 96E5E34C18BBB48A008E7B30 /* Adjust.h */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCFBCE1AC99235005A65C5 /* ADJEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 9609BC6819EEA55800E02303 /* ADJEvent.h */; settings = {ATTRIBUTES = (Public, ); }; }; 96BCFBD01AC9923F005A65C5 /* ADJConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 960A8BB71A029A8000F2BB95 /* ADJConfig.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -200,6 +200,10 @@ /* Begin PBXFileReference section */ 9601C19C1A31DD7F00A9AE21 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; }; 9601C1A11A31DE0300A9AE21 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + 9601CAE21C74B70600670879 /* ADJEventSuccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJEventSuccess.h; sourceTree = ""; }; + 9601CAE31C74B70600670879 /* ADJEventSuccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJEventSuccess.m; sourceTree = ""; }; + 9601CAE61C74BAAE00670879 /* ADJEventFailure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJEventFailure.h; sourceTree = ""; }; + 9601CAE71C74BAAE00670879 /* ADJEventFailure.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJEventFailure.m; sourceTree = ""; }; 9609BC6819EEA55800E02303 /* ADJEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJEvent.h; sourceTree = ""; }; 9609BC6919EEA55800E02303 /* ADJEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJEvent.m; sourceTree = ""; }; 960A8BB71A029A8000F2BB95 /* ADJConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJConfig.h; sourceTree = ""; }; @@ -220,10 +224,10 @@ 9679920D18BBAE2800394606 /* libAdjust.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAdjust.a; sourceTree = BUILT_PRODUCTS_DIR; }; 9679921018BBAE2800394606 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 9679921D18BBAE2800394606 /* AdjustTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AdjustTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 968173811C3C2D07002AE1DE /* ADJSuccessResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSuccessResponseData.h; sourceTree = ""; }; - 968173821C3C2D07002AE1DE /* ADJSuccessResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSuccessResponseData.m; sourceTree = ""; }; - 968173851C3C2D36002AE1DE /* ADJFailureResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJFailureResponseData.h; sourceTree = ""; }; - 968173861C3C2D36002AE1DE /* ADJFailureResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJFailureResponseData.m; sourceTree = ""; }; + 968173811C3C2D07002AE1DE /* ADJSessionSuccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSessionSuccess.h; sourceTree = ""; }; + 968173821C3C2D07002AE1DE /* ADJSessionSuccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSessionSuccess.m; sourceTree = ""; }; + 968173851C3C2D36002AE1DE /* ADJSessionFailure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSessionFailure.h; sourceTree = ""; }; + 968173861C3C2D36002AE1DE /* ADJSessionFailure.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSessionFailure.m; sourceTree = ""; }; 96854A571B1F2779002B2874 /* ADJTimerOnce.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJTimerOnce.h; sourceTree = ""; }; 96854A581B1F2779002B2874 /* ADJTimerOnce.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJTimerOnce.m; sourceTree = ""; }; 96854A5D1B1F278C002B2874 /* ADJTimerCycle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJTimerCycle.h; sourceTree = ""; }; @@ -485,10 +489,14 @@ 96854A5E1B1F278C002B2874 /* ADJTimerCycle.m */, 96FCC5361C186426007BBFE1 /* ADJResponseData.h */, 96FCC5371C186426007BBFE1 /* ADJResponseData.m */, - 968173811C3C2D07002AE1DE /* ADJSuccessResponseData.h */, - 968173821C3C2D07002AE1DE /* ADJSuccessResponseData.m */, - 968173851C3C2D36002AE1DE /* ADJFailureResponseData.h */, - 968173861C3C2D36002AE1DE /* ADJFailureResponseData.m */, + 968173811C3C2D07002AE1DE /* ADJSessionSuccess.h */, + 968173821C3C2D07002AE1DE /* ADJSessionSuccess.m */, + 968173851C3C2D36002AE1DE /* ADJSessionFailure.h */, + 968173861C3C2D36002AE1DE /* ADJSessionFailure.m */, + 9601CAE21C74B70600670879 /* ADJEventSuccess.h */, + 9601CAE31C74B70600670879 /* ADJEventSuccess.m */, + 9601CAE61C74BAAE00670879 /* ADJEventFailure.h */, + 9601CAE71C74BAAE00670879 /* ADJEventFailure.m */, ); path = Adjust; sourceTree = ""; @@ -612,8 +620,10 @@ 96BCFBD01AC9923F005A65C5 /* ADJConfig.h in Headers */, 9D363AC31BDA50FA00B47FE9 /* ADJLogger.h in Headers */, 96BCFBD11AC99246005A65C5 /* ADJAttribution.h in Headers */, - 968173831C3C2D07002AE1DE /* ADJSuccessResponseData.h in Headers */, - 968173871C3C2D36002AE1DE /* ADJFailureResponseData.h in Headers */, + 9601CAE81C74BAAE00670879 /* ADJEventFailure.h in Headers */, + 9601CAE41C74B70600670879 /* ADJEventSuccess.h in Headers */, + 968173831C3C2D07002AE1DE /* ADJSessionSuccess.h in Headers */, + 968173871C3C2D36002AE1DE /* ADJSessionFailure.h in Headers */, 96BCFBD91AC9934E005A65C5 /* ADJAdjustFactory.h in Headers */, 96BCFBD81AC9934B005A65C5 /* ADJActivityState.h in Headers */, 96BCFBD61AC99345005A65C5 /* ADJActivityKind.h in Headers */, @@ -643,8 +653,6 @@ 9DFA37ED1C0F220200782607 /* ADJConfig.h in Headers */, 9DFA37F31C0F220200782607 /* ADJLogger.h in Headers */, 9DFA37E91C0F220200782607 /* ADJAttribution.h in Headers */, - 96BA93FB1C3D56D900C96245 /* ADJSuccessResponseData.h in Headers */, - 96BA93FC1C3D56F400C96245 /* ADJFailureResponseData.h in Headers */, 9DFA38011C0F220200782607 /* ADJUtil.h in Headers */, 9DFA37EF1C0F220200782607 /* ADJDeviceInfo.h in Headers */, 9DFA380C1C0F220D00782607 /* NSString+ADJAdditions.h in Headers */, @@ -867,19 +875,21 @@ 96E5E38C18BBB48A008E7B30 /* ADJActivityKind.m in Sources */, 96C93DF51AC47F2E00B53F56 /* NSData+ADJAdditions.m in Sources */, 96E5E38D18BBB48A008E7B30 /* ADJActivityPackage.m in Sources */, - 968173881C3C2D36002AE1DE /* ADJFailureResponseData.m in Sources */, + 968173881C3C2D36002AE1DE /* ADJSessionFailure.m in Sources */, 965307F61A000DA400107FF9 /* ADJDeviceInfo.m in Sources */, 969952D21A01309200928462 /* ADJAttribution.m in Sources */, 969952CF1A012F5300928462 /* ADJAttributionHandler.m in Sources */, + 9601CAE51C74B70600670879 /* ADJEventSuccess.m in Sources */, 96E5E38E18BBB48A008E7B30 /* ADJActivityState.m in Sources */, 9609BC6A19EEA55800E02303 /* ADJEvent.m in Sources */, 96E5E39518BBB48A008E7B30 /* ADJPackageHandler.m in Sources */, 96854A5A1B1F2779002B2874 /* ADJTimerOnce.m in Sources */, - 968173841C3C2D07002AE1DE /* ADJSuccessResponseData.m in Sources */, + 968173841C3C2D07002AE1DE /* ADJSessionSuccess.m in Sources */, 96E5E39318BBB48A008E7B30 /* ADJLogger.m in Sources */, 96E5E39418BBB48A008E7B30 /* ADJPackageBuilder.m in Sources */, 960A8BB91A029A8000F2BB95 /* ADJConfig.m in Sources */, 96E5E39218BBB48A008E7B30 /* ADJAdjustFactory.m in Sources */, + 9601CAE91C74BAAE00670879 /* ADJEventFailure.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -915,8 +925,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 96BA93FE1C3D575D00C96245 /* ADJFailureResponseData.m in Sources */, - 96BA93FD1C3D574F00C96245 /* ADJSuccessResponseData.m in Sources */, 9DFA37E81C0F220200782607 /* ADJAdjustFactory.m in Sources */, 9DFA37E21C0F220200782607 /* ADJActivityKind.m in Sources */, 9DFA37FA1C0F220200782607 /* ADJRequestHandler.m in Sources */, diff --git a/Adjust/ADJActivityHandler.h b/Adjust/ADJActivityHandler.h index de75667f4..469156829 100644 --- a/Adjust/ADJActivityHandler.h +++ b/Adjust/ADJActivityHandler.h @@ -19,8 +19,9 @@ - (void)trackEvent:(ADJEvent *)event; - (void)finishedTracking:(ADJResponseData *)responseData; -- (void)launchAttributionChangedDelegateWithDeeplink:(ADJResponseData *)responseData; -- (void)launchAttributionChangedDelegate:(ADJResponseData *)responseData; +- (void)launchEventResponseTasks:(ADJEventResponseData *)eventResponseData; +- (void)launchSessionResponseTasks:(ADJSessionResponseData *)sessionResponseData; +- (void)launchAttributionResponseTasks:(ADJAttributionResponseData *)attributionResponseData; - (void)setEnabled:(BOOL)enabled; - (BOOL)isEnabled; - (void)appWillOpenUrl:(NSURL*)url; diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index 48933f439..0f9d50bc1 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -111,34 +111,33 @@ - (void)trackEvent:(ADJEvent *)event - (void)finishedTracking:(ADJResponseData *)responseData { // redirect session responses to attribution handler to check for attribution information - if (responseData.activityKind == ADJActivityKindSession) { - [self.attributionHandler checkSessionResponse:responseData]; + if ([responseData isKindOfClass:[ADJSessionResponseData class]]) { + [self.attributionHandler checkSessionResponse:(ADJSessionResponseData*)responseData]; return; } - // check if it's an event response tasks and there is a delegate - if (responseData.activityKind == ADJActivityKindEvent - && self.adjustDelegate != nil) - { - [self launchEventResponseDelegate:responseData]; + + // check if it's an event response + if ([responseData isKindOfClass:[ADJEventResponseData class]]) { + [self launchEventResponseTasks:(ADJEventResponseData*)responseData]; return; } } -- (void)launchEventResponseDelegate:(ADJResponseData *)responseData { +- (void)launchEventResponseTasks:(ADJEventResponseData *)eventResponseData { dispatch_async(self.internalQueue, ^{ - [self launchEventResponseTasksInternal:responseData]; + [self launchEventResponseTasksInternal:eventResponseData]; }); } -- (void)launchAttributionChangedDelegateWithDeeplink:(ADJResponseData *)responseData { +- (void)launchSessionResponseTasks:(ADJSessionResponseData *)sessionResponseData { dispatch_async(self.internalQueue, ^{ - [self launchAttributionChangedDelegateWithDeeplinkInternal:responseData]; + [self launchSessionResponseTasksInternal:sessionResponseData]; }); } -- (void)launchAttributionChangedDelegate:(ADJResponseData *)responseData { +- (void)launchAttributionResponseTasks:(ADJAttributionResponseData *)attributionResponseData { dispatch_async(self.internalQueue, ^{ - [self launchAttributionChangedDelegateInternal:responseData]; + [self launchAttributionResponseTasksInternal:attributionResponseData]; }); } @@ -487,52 +486,73 @@ - (void)eventInternal:(ADJEvent *)event [self writeActivityState]; } -- (void) launchEventResponseTasksInternal:(ADJResponseData *)responseData { - // success callback - if (responseData.success - && [self.adjustDelegate respondsToSelector:@selector(adjustTrackingSucceeded:)]) +- (void) launchEventResponseTasksInternal:(ADJEventResponseData *)eventResponseData { + // event success callback + if (eventResponseData.success + && [self.adjustDelegate respondsToSelector:@selector(adjustEventTrackingSucceeded:)]) { [self.logger debug:@"Launching success event tracking delegate"]; - [self.adjustDelegate performSelectorOnMainThread:@selector(adjustTrackingSucceeded:) - withObject:[responseData successResponseData] + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustEventTrackingSucceeded:) + withObject:[eventResponseData successResponseData] waitUntilDone:NO]; // non-blocking return; } - // failure callback - if (!responseData.success - && [self.adjustDelegate respondsToSelector:@selector(adjustTrackingFailed:)]) + // event failure callback + if (!eventResponseData.success + && [self.adjustDelegate respondsToSelector:@selector(adjustEventTrackingFailed:)]) { [self.logger debug:@"Launching failed event tracking delegate"]; - [self.adjustDelegate performSelectorOnMainThread:@selector(adjustTrackingFailed:) - withObject:[responseData failureResponseData] + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustEventTrackingFailed:) + withObject:[eventResponseData failureResponseData] waitUntilDone:NO]; // non-blocking return; } } -- (void) launchAttributionChangedDelegateWithDeeplinkInternal:(ADJResponseData *)responseData { - BOOL toLaunchAttributionDelegate = [self updateAttribution:responseData.attribution]; +- (void) launchSessionResponseTasksInternal:(ADJSessionResponseData *)sessionResponseData { + BOOL toLaunchAttributionDelegate = [self updateAttribution:sessionResponseData.attribution]; // Send tasks to background to avoid blocking the activity handler queue dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + // session success callback + if (sessionResponseData.success + && [self.adjustDelegate respondsToSelector:@selector(adjustSessionTrackingSucceeded:)]) + { + [self.logger debug:@"Launching success session tracking delegate"]; + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustSessionTrackingSucceeded:) + withObject:[sessionResponseData successResponseData] + waitUntilDone:YES]; // blocking + } + // session failure callback + if (!sessionResponseData.success + && [self.adjustDelegate respondsToSelector:@selector(adjustSessionTrackingFailed:)]) + { + [self.logger debug:@"Launching failed session tracking delegate"]; + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustSessionTrackingFailed:) + withObject:[sessionResponseData failureResponseData] + waitUntilDone:NO]; // blocking + } + // try to update and launch the attribution changed delegate blocking if (toLaunchAttributionDelegate) { + [self.logger debug:@"Launching attribution changed delegate"]; [self.adjustDelegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) - withObject:responseData.attribution + withObject:sessionResponseData.attribution waitUntilDone:YES]; // blocking } // try to launch the deeplink after attribution changed delegate - [self launchDeepLink:responseData.jsonResponse]; + [self launchDeepLink:sessionResponseData.jsonResponse]; }); } -- (void) launchAttributionChangedDelegateInternal:(ADJResponseData *)responseData { - BOOL toLaunchAttributionDelegate = [self updateAttribution:responseData.attribution]; +- (void) launchAttributionResponseTasksInternal:(ADJAttributionResponseData *)attributionResponseData { + BOOL toLaunchAttributionDelegate = [self updateAttribution:attributionResponseData.attribution]; // try to update and launch the attribution changed delegate non-blocking if (toLaunchAttributionDelegate) { + [self.logger debug:@"Launching attribution changed delegate"]; [self.adjustDelegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) - withObject:responseData.attribution + withObject:attributionResponseData.attribution waitUntilDone:NO]; // non-blocking } } diff --git a/Adjust/ADJAttributionHandler.h b/Adjust/ADJAttributionHandler.h index 0491d6966..594a80d5c 100644 --- a/Adjust/ADJAttributionHandler.h +++ b/Adjust/ADJAttributionHandler.h @@ -17,7 +17,9 @@ startPaused:(BOOL)startPaused hasAttributionChangedDelegate:(BOOL)hasAttributionChangedDelegate; -- (void)checkSessionResponse:(ADJResponseData *)responseData; +- (void)checkSessionResponse:(ADJSessionResponseData *)sessionResponseData; + +- (void)checkAttributionResponse:(ADJAttributionResponseData *)attributionResponseData; - (void)getAttribution; diff --git a/Adjust/ADJAttributionHandler.m b/Adjust/ADJAttributionHandler.m index 4cc35a9b7..696d2e534 100644 --- a/Adjust/ADJAttributionHandler.m +++ b/Adjust/ADJAttributionHandler.m @@ -62,15 +62,15 @@ - (id)initWithActivityHandler:(id) activityHandler return self; } -- (void) checkSessionResponse:(ADJResponseData *)responseData { +- (void) checkSessionResponse:(ADJSessionResponseData *)sessionResponseData { dispatch_async(self.internalQueue, ^{ - [self checkSessionResponseInternal:responseData]; + [self checkSessionResponseInternal:sessionResponseData]; }); } -- (void) checkAttributionResponse:(ADJResponseData *)responseData { +- (void) checkAttributionResponse:(ADJAttributionResponseData *)attributionResponseData { dispatch_async(self.internalQueue, ^{ - [self checkAttributionResponseInternal:responseData]; + [self checkAttributionResponseInternal:attributionResponseData]; }); } @@ -102,16 +102,16 @@ - (void) resumeSending { } #pragma mark - internal -- (void) checkSessionResponseInternal:(ADJResponseData *)responseData { - [self checkAttributionInternal:responseData]; +- (void) checkSessionResponseInternal:(ADJSessionResponseData *)sessionResponseData { + [self checkAttributionInternal:sessionResponseData]; - [self.activityHandler launchAttributionChangedDelegateWithDeeplink:responseData]; + [self.activityHandler launchSessionResponseTasks:sessionResponseData]; } -- (void) checkAttributionResponseInternal:(ADJResponseData *)responseData { - [self checkAttributionInternal:responseData]; +- (void) checkAttributionResponseInternal:(ADJAttributionResponseData *)attributionResponseData { + [self checkAttributionInternal:attributionResponseData]; - [self.activityHandler launchAttributionChangedDelegate:responseData]; + [self.activityHandler launchAttributionResponseTasks:attributionResponseData]; } - (void) checkAttributionInternal:(ADJResponseData *)responseData { @@ -150,7 +150,9 @@ - (void) getAttributionInternal { activityPackage:self.attributionPackage responseDataHandler:^(ADJResponseData * responseData) { - [self checkAttributionResponse:responseData]; + if ([responseData isKindOfClass:[ADJAttributionResponseData class]]) { + [self checkAttributionResponse:(ADJAttributionResponseData*)responseData]; + } }]; } diff --git a/Adjust/ADJConfig.h b/Adjust/ADJConfig.h index 94de3bcd0..89f51cc50 100644 --- a/Adjust/ADJConfig.h +++ b/Adjust/ADJConfig.h @@ -9,8 +9,10 @@ #import #import "ADJLogger.h" #import "ADJAttribution.h" -#import "ADJSuccessResponseData.h" -#import "ADJFailureResponseData.h" +#import "ADJSessionSuccess.h" +#import "ADJSessionFailure.h" +#import "ADJEventSuccess.h" +#import "ADJEventFailure.h" /** * Optional delegate that will get informed about tracking results @@ -28,16 +30,30 @@ /** * Optional delegate method that gets called when an event is tracked with success * - * @param successResponseData The response information from tracking with success. See ADJSuccessResponseData for details. + * @param eventSuccessResponseData The response information from tracking with success. See ADJEventSuccess for details. */ -- (void)adjustTrackingSucceeded:(ADJSuccessResponseData *)successResponseData; +- (void)adjustEventTrackingSucceeded:(ADJEventSuccess *)eventSuccessResponseData; /** * Optional delegate method that gets called when an event is tracked with failure * - * @param failureResponseData The response information from tracking with failure. See ADJFailureResponseData for details. + * @param eventFailureResponseData The response information from tracking with failure. See ADJEventFailure for details. */ -- (void)adjustTrackingFailed:(ADJFailureResponseData *)failureResponseData; +- (void)adjustEventTrackingFailed:(ADJEventFailure *)eventFailureResponseData; + +/** + * Optional delegate method that gets called when an session is tracked with success + * + * @param sessionSuccessResponseData The response information from tracking with success. See ADJSessionSuccess for details. + */ +- (void)adjustSessionTrackingSucceeded:(ADJSessionSuccess *)sessionSuccessResponseData; + +/** + * Optional delegate method that gets called when an session is tracked with failure + * + * @param sessionFailureResponseData The response information from tracking with failure. See ADJSessionFailure for details. + */ +- (void)adjustSessionTrackingFailed:(ADJSessionFailure *)sessionFailureResponseData; @end diff --git a/Adjust/ADJConfig.m b/Adjust/ADJConfig.m index 03da8837b..e7e9af7bc 100644 --- a/Adjust/ADJConfig.m +++ b/Adjust/ADJConfig.m @@ -68,14 +68,26 @@ - (void) setDelegate:(NSObject *)delegate { self.hasAttributionChangedDelegate = YES; } - if ([delegate respondsToSelector:@selector(adjustTrackingSucceeded:)]) { - [logger debug:@"Delegate implements adjustTrackingSucceeded:"]; + if ([delegate respondsToSelector:@selector(adjustEventTrackingSucceeded:)]) { + [logger debug:@"Delegate implements adjustEventTrackingSucceeded:"]; self.hasDelegate = YES; } - if ([delegate respondsToSelector:@selector(adjustTrackingFailed:)]) { - [logger debug:@"Delegate implements adjustTrackingFailed:"]; + if ([delegate respondsToSelector:@selector(adjustEventTrackingFailed:)]) { + [logger debug:@"Delegate implements adjustEventTrackingFailed:"]; + + self.hasDelegate = YES; + } + + if ([delegate respondsToSelector:@selector(adjustSessionTrackingSucceeded:)]) { + [logger debug:@"Delegate implements adjustSessionTrackingSucceeded:"]; + + self.hasDelegate = YES; + } + + if ([delegate respondsToSelector:@selector(adjustSessionTrackingFailed:)]) { + [logger debug:@"Delegate implements adjustSessionTrackingFailed:"]; self.hasDelegate = YES; } diff --git a/Adjust/ADJEventFailure.h b/Adjust/ADJEventFailure.h new file mode 100644 index 000000000..9b28d005f --- /dev/null +++ b/Adjust/ADJEventFailure.h @@ -0,0 +1,37 @@ +// +// ADJEventFailure.h +// adjust +// +// Created by Pedro Filipe on 17/02/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import + +@interface ADJEventFailure : NSObject + +// activity type of the tracked package. For now only "event" is tracked. +@property (nonatomic, copy) NSString * activityKindString; + +// error message from the server or the sdk. +@property (nonatomic, copy) NSString * message; + +// timeStamp from the server. +@property (nonatomic, copy) NSString * timeStamp; + +// adid of the device. +@property (nonatomic, copy) NSString * adid; + +// event token of the tracked event. +@property (nonatomic, copy) NSString * eventToken; + +// indicates if the package will be retried to be send later +@property (nonatomic, assign) BOOL willRetry; + +// the server response in json format +@property (nonatomic, retain) NSDictionary *jsonResponse; + ++ (ADJEventFailure *)eventFailureResponseData; +- (id)init; + +@end diff --git a/Adjust/ADJFailureResponseData.m b/Adjust/ADJEventFailure.m similarity index 77% rename from Adjust/ADJFailureResponseData.m rename to Adjust/ADJEventFailure.m index df63a0c31..8e1510b8b 100644 --- a/Adjust/ADJFailureResponseData.m +++ b/Adjust/ADJEventFailure.m @@ -1,17 +1,17 @@ // -// ADJFailureResponseData.m +// ADJEventFailure.m // adjust // -// Created by Pedro Filipe on 05/01/16. +// Created by Pedro Filipe on 17/02/16. // Copyright © 2016 adjust GmbH. All rights reserved. // -#import "ADJFailureResponseData.h" +#import "ADJEventFailure.h" -@implementation ADJFailureResponseData +@implementation ADJEventFailure -+ (ADJFailureResponseData *)failureResponseData { - return [[ADJFailureResponseData alloc] init]; ++ (ADJEventFailure *)eventFailureResponseData { + return [[ADJEventFailure alloc] init]; } - (id)init { @@ -25,7 +25,7 @@ - (id)init { -(id)copyWithZone:(NSZone *)zone { - ADJFailureResponseData* copy = [[[self class] allocWithZone:zone] init]; + ADJEventFailure* copy = [[[self class] allocWithZone:zone] init]; if (copy) { copy.activityKindString = [self.activityKindString copyWithZone:zone]; diff --git a/Adjust/ADJEventSuccess.h b/Adjust/ADJEventSuccess.h new file mode 100644 index 000000000..f77d0ca0e --- /dev/null +++ b/Adjust/ADJEventSuccess.h @@ -0,0 +1,34 @@ +// +// ADJEventSuccess.h +// adjust +// +// Created by Pedro Filipe on 17/02/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import + +@interface ADJEventSuccess : NSObject + +// activity type of the tracked package. For now only "event" is tracked. +@property (nonatomic, copy) NSString * activityKindString; + +// message from the server. +@property (nonatomic, copy) NSString * message; + +// timeStamp from the server. +@property (nonatomic, copy) NSString * timeStamp; + +// adid of the device. +@property (nonatomic, copy) NSString * adid; + +// event token of the tracked event. +@property (nonatomic, copy) NSString * eventToken; + +// the server response in json format +@property (nonatomic, retain) NSDictionary *jsonResponse; + ++ (ADJEventSuccess *)eventSuccessResponseData; +- (id)init; + +@end diff --git a/Adjust/ADJSuccessResponseData.m b/Adjust/ADJEventSuccess.m similarity index 76% rename from Adjust/ADJSuccessResponseData.m rename to Adjust/ADJEventSuccess.m index e82105d6b..4db17ebb2 100644 --- a/Adjust/ADJSuccessResponseData.m +++ b/Adjust/ADJEventSuccess.m @@ -1,17 +1,17 @@ // -// ADJSuccessResponseData.m +// ADJEventSuccess.m // adjust // -// Created by Pedro Filipe on 05/01/16. +// Created by Pedro Filipe on 17/02/16. // Copyright © 2016 adjust GmbH. All rights reserved. // -#import "ADJSuccessResponseData.h" +#import "ADJEventSuccess.h" -@implementation ADJSuccessResponseData +@implementation ADJEventSuccess -+ (ADJSuccessResponseData *)successResponseData { - return [[ADJSuccessResponseData alloc] init]; ++ (ADJEventSuccess *)eventSuccessResponseData { + return [[ADJEventSuccess alloc] init]; } - (id)init { @@ -25,7 +25,7 @@ - (id)init { -(id)copyWithZone:(NSZone *)zone { - ADJSuccessResponseData* copy = [[[self class] allocWithZone:zone] init]; + ADJEventSuccess* copy = [[[self class] allocWithZone:zone] init]; if (copy) { copy.activityKindString = [self.activityKindString copyWithZone:zone]; diff --git a/Adjust/ADJResponseData.h b/Adjust/ADJResponseData.h index 80bbd6c48..9e9453a54 100644 --- a/Adjust/ADJResponseData.h +++ b/Adjust/ADJResponseData.h @@ -9,8 +9,10 @@ #import #import "ADJActivityPackage.h" #import "ADJAttribution.h" -#import "ADJSuccessResponseData.h" -#import "ADJFailureResponseData.h" +#import "ADJSessionSuccess.h" +#import "ADJSessionFailure.h" +#import "ADJEventSuccess.h" +#import "ADJEventFailure.h" @interface ADJResponseData : NSObject @@ -22,8 +24,6 @@ @property (nonatomic, copy) NSString * adid; -@property (nonatomic, copy) NSString * eventToken; - @property (nonatomic, assign) BOOL success; @property (nonatomic, assign) BOOL willRetry; @@ -32,10 +32,40 @@ @property (nonatomic, copy) ADJAttribution *attribution; ++ (ADJResponseData *)responseData; +- (id)init; + ++ (id)buildResponseData:(ADJActivityPackage *)activityPackage; + +@end + +@interface ADJSessionResponseData : ADJResponseData + +- (ADJSessionSuccess *)successResponseData; +- (ADJSessionFailure *)failureResponseData; + +@end + +@interface ADJEventResponseData : ADJResponseData + +@property (nonatomic, copy) NSString * eventToken; + +- (ADJEventSuccess *)successResponseData; +- (ADJEventFailure *)failureResponseData; + + (ADJResponseData *)responseDataWithActivityPackage:(ADJActivityPackage *)activityPackage; - (id)initWithActivityPackage:(ADJActivityPackage *)activityPackage; -- (ADJSuccessResponseData *)successResponseData; -- (ADJFailureResponseData *)failureResponseData; +@end + +@interface ADJAttributionResponseData : ADJResponseData @end + +@interface ADJClickResponseData : ADJResponseData + +@end + +@interface ADJUnknowResponseData : ADJResponseData + +@end \ No newline at end of file diff --git a/Adjust/ADJResponseData.m b/Adjust/ADJResponseData.m index 2c165d2f1..2d625440a 100644 --- a/Adjust/ADJResponseData.m +++ b/Adjust/ADJResponseData.m @@ -11,28 +11,128 @@ @implementation ADJResponseData -+ (ADJResponseData *)responseDataWithActivityPackage:(ADJActivityPackage *)activityPackage { - return [[ADJResponseData alloc] initWithActivityPackage:activityPackage]; ++ (ADJResponseData *)responseData { + return [[ADJResponseData alloc] init]; } -- (id)initWithActivityPackage:(ADJActivityPackage *)activityPackage { +- (id)init { self = [super init]; if (self == nil) return nil; - self.activityKind = activityPackage.activityKind; - self.eventToken = [activityPackage.parameters objectForKey:@"event_token"]; - return self; } ++ (id)buildResponseData:(ADJActivityPackage *)activityPackage { + if (activityPackage == nil) { + return [[ADJUnknowResponseData alloc] init]; + } + + ADJResponseData * responseData = nil; + + switch (activityPackage.activityKind) { + case ADJActivityKindSession: + responseData = [[ADJSessionResponseData alloc] init]; + break; + case ADJActivityKindEvent: + responseData = [[ADJEventResponseData alloc] initWithActivityPackage:activityPackage]; + break; + case ADJActivityKindClick: + responseData = [[ADJClickResponseData alloc] init]; + break; + case ADJActivityKindAttribution: + responseData = [[ADJAttributionResponseData alloc] init]; + break; + default: + responseData = [[ADJUnknowResponseData alloc] init]; + break; + } + + responseData.activityKind = activityPackage.activityKind; + + return responseData; +} + - (NSString *)description { - return [NSString stringWithFormat:@"message:%@ timestamp:%@ adid:%@ eventToken:%@ success:%d willRetry:%d attribution:%@ json:%@", - self.message, self.timeStamp, self.adid, self.eventToken, self.success, self.willRetry, self.attribution, self.jsonResponse]; + return [NSString stringWithFormat:@"message:%@ timestamp:%@ adid:%@ success:%d willRetry:%d attribution:%@ json:%@", + self.message, self.timeStamp, self.adid, self.success, self.willRetry, self.attribution, self.jsonResponse]; +} + +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone +{ + ADJResponseData* copy = [[[self class] allocWithZone:zone] init]; + + if (copy) { + copy.message = [self.message copyWithZone:zone]; + copy.timeStamp = [self.timeStamp copyWithZone:zone]; + copy.adid = [self.adid copyWithZone:zone]; + copy.success = self.success; + copy.willRetry = self.willRetry; + copy.jsonResponse = [self.jsonResponse copyWithZone:zone]; + copy.attribution = [self.attribution copyWithZone:zone]; + } + + return copy; +} + +@end + +@implementation ADJSessionResponseData + +- (id)initWithActivityPackage:(ADJActivityPackage *)activityPackage { + self = [super init]; + if (self == nil) return nil; + + return self; +} + +- (ADJSessionSuccess *)successResponseData { + ADJSessionSuccess * successResponseData = [ADJSessionSuccess sessionSuccessResponseData]; + successResponseData.message = self.message; + successResponseData.timeStamp = self.timeStamp; + successResponseData.adid = self.adid; + successResponseData.jsonResponse = self.jsonResponse; + + return successResponseData; +} + +- (ADJSessionFailure *)failureResponseData { + ADJSessionFailure * failureResponseData = [ADJSessionFailure sessionFailureResponseData]; + failureResponseData.message = self.message; + failureResponseData.timeStamp = self.timeStamp; + failureResponseData.adid = self.adid; + failureResponseData.willRetry = self.willRetry; + failureResponseData.jsonResponse = self.jsonResponse; + + return failureResponseData; +} + +-(id)copyWithZone:(NSZone *)zone +{ + ADJSessionResponseData* copy = [super copyWithZone:zone]; + return copy; +} + +@end + +@implementation ADJEventResponseData + ++ (ADJEventResponseData *)responseDataWithActivityPackage:(ADJActivityPackage *)activityPackage { + return [[ADJEventResponseData alloc] initWithActivityPackage:activityPackage]; } -- (ADJSuccessResponseData *)successResponseData { - ADJSuccessResponseData * successResponseData = [ADJSuccessResponseData successResponseData]; - successResponseData.activityKindString = [ADJActivityKindUtil activityKindToString:self.activityKind]; +- (id)initWithActivityPackage:(ADJActivityPackage *)activityPackage { + self = [super init]; + if (self == nil) return nil; + + self.eventToken = [activityPackage.parameters objectForKey:@"event_token"]; + + return self; +} + +- (ADJEventSuccess *)successResponseData { + ADJEventSuccess * successResponseData = [ADJEventSuccess eventSuccessResponseData]; successResponseData.message = self.message; successResponseData.timeStamp = self.timeStamp; successResponseData.adid = self.adid; @@ -42,9 +142,8 @@ - (ADJSuccessResponseData *)successResponseData { return successResponseData; } -- (ADJFailureResponseData *)failureResponseData { - ADJFailureResponseData * failureResponseData = [ADJFailureResponseData failureResponseData]; - failureResponseData.activityKindString = [ADJActivityKindUtil activityKindToString:self.activityKind]; +- (ADJEventFailure *)failureResponseData { + ADJEventFailure * failureResponseData = [ADJEventFailure eventFailureResponseData]; failureResponseData.message = self.message; failureResponseData.timeStamp = self.timeStamp; failureResponseData.adid = self.adid; @@ -55,25 +154,71 @@ - (ADJFailureResponseData *)failureResponseData { return failureResponseData; } -#pragma mark - NSCopying +- (NSString *)description { + return [NSString stringWithFormat:@"message:%@ timestamp:%@ adid:%@ eventToken:%@ success:%d willRetry:%d attribution:%@ json:%@", + self.message, self.timeStamp, self.adid, self.eventToken, self.success, self.willRetry, self.attribution, self.jsonResponse]; +} -(id)copyWithZone:(NSZone *)zone { - ADJResponseData* copy = [[[self class] allocWithZone:zone] init]; + ADJEventResponseData* copy = [super copyWithZone:zone]; if (copy) { - copy.activityKind = self.activityKind; - copy.message = [self.message copyWithZone:zone]; - copy.timeStamp = [self.timeStamp copyWithZone:zone]; - copy.adid = [self.adid copyWithZone:zone]; copy.eventToken = [self.eventToken copyWithZone:zone]; - copy.success = self.success; - copy.willRetry = self.willRetry; - copy.jsonResponse = [self.jsonResponse copyWithZone:zone]; - copy.attribution = [self.attribution copyWithZone:zone]; } return copy; } +@end + +@implementation ADJAttributionResponseData + +- (id)initWithActivityPackage:(ADJActivityPackage *)activityPackage { + self = [super init]; + if (self == nil) return nil; + + return self; +} + +-(id)copyWithZone:(NSZone *)zone +{ + ADJAttributionResponseData* copy = [super copyWithZone:zone]; + return copy; +} + +@end + +@implementation ADJClickResponseData + +- (id)initWithActivityPackage:(ADJActivityPackage *)activityPackage { + self = [super init]; + if (self == nil) return nil; + + return self; +} + +-(id)copyWithZone:(NSZone *)zone +{ + ADJClickResponseData* copy = [super copyWithZone:zone]; + return copy; +} + +@end + +@implementation ADJUnknowResponseData + +- (id)initWithActivityPackage:(ADJActivityPackage *)activityPackage { + self = [super init]; + if (self == nil) return nil; + + return self; +} + +-(id)copyWithZone:(NSZone *)zone +{ + ADJUnknowResponseData* copy = [super copyWithZone:zone]; + return copy; +} + @end \ No newline at end of file diff --git a/Adjust/ADJFailureResponseData.h b/Adjust/ADJSessionFailure.h similarity index 80% rename from Adjust/ADJFailureResponseData.h rename to Adjust/ADJSessionFailure.h index 2911b4fae..8b8de867e 100644 --- a/Adjust/ADJFailureResponseData.h +++ b/Adjust/ADJSessionFailure.h @@ -9,7 +9,7 @@ #import #import "ADJActivityKind.h" -@interface ADJFailureResponseData : NSObject +@interface ADJSessionFailure : NSObject // activity type of the tracked package. For now only "event" is tracked. @property (nonatomic, copy) NSString * activityKindString; @@ -23,16 +23,13 @@ // adid of the device. @property (nonatomic, copy) NSString * adid; -// event token of the tracked event. -@property (nonatomic, copy) NSString * eventToken; - // indicates if the package will be retried to be send later @property (nonatomic, assign) BOOL willRetry; // the server response in json format @property (nonatomic, retain) NSDictionary *jsonResponse; -+ (ADJFailureResponseData *)failureResponseData; ++ (ADJSessionFailure *)sessionFailureResponseData; - (id)init; @end diff --git a/Adjust/ADJSessionFailure.m b/Adjust/ADJSessionFailure.m new file mode 100644 index 000000000..65626cf03 --- /dev/null +++ b/Adjust/ADJSessionFailure.m @@ -0,0 +1,54 @@ +// +// ADJFailureResponseData.m +// adjust +// +// Created by Pedro Filipe on 05/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import "ADJSessionFailure.h" + +@implementation ADJSessionFailure + ++ (ADJSessionFailure *)sessionFailureResponseData { + return [[ADJSessionFailure alloc] init]; +} + +- (id)init { + self = [super init]; + if (self == nil) return nil; + + return self; +} + +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone +{ + ADJSessionFailure* copy = [[[self class] allocWithZone:zone] init]; + + if (copy) { + copy.activityKindString = [self.activityKindString copyWithZone:zone]; + copy.message = [self.message copyWithZone:zone]; + copy.timeStamp = [self.timeStamp copyWithZone:zone]; + copy.adid = [self.adid copyWithZone:zone]; + copy.willRetry = self.willRetry; + copy.jsonResponse = [self.jsonResponse copyWithZone:zone]; + } + + return copy; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat: @"%@ msg:%@ time:%@ adid:%@ retry:%@ json:%@", + self.activityKindString, + self.message, + self.timeStamp, + self.adid, + self.willRetry ? @"YES" : @"NO", + self.jsonResponse]; +} + +@end diff --git a/Adjust/ADJSuccessResponseData.h b/Adjust/ADJSessionSuccess.h similarity index 77% rename from Adjust/ADJSuccessResponseData.h rename to Adjust/ADJSessionSuccess.h index e0151f9f6..e92a4d5f5 100644 --- a/Adjust/ADJSuccessResponseData.h +++ b/Adjust/ADJSessionSuccess.h @@ -9,7 +9,7 @@ #import #import "ADJActivityKind.h" -@interface ADJSuccessResponseData : NSObject +@interface ADJSessionSuccess : NSObject // activity type of the tracked package. For now only "event" is tracked. @property (nonatomic, copy) NSString * activityKindString; @@ -23,13 +23,10 @@ // adid of the device. @property (nonatomic, copy) NSString * adid; -// event token of the tracked event. -@property (nonatomic, copy) NSString * eventToken; - // the server response in json format @property (nonatomic, retain) NSDictionary *jsonResponse; -+ (ADJSuccessResponseData *)successResponseData; ++ (ADJSessionSuccess *)sessionSuccessResponseData; - (id)init; @end diff --git a/Adjust/ADJSessionSuccess.m b/Adjust/ADJSessionSuccess.m new file mode 100644 index 000000000..cde0f813c --- /dev/null +++ b/Adjust/ADJSessionSuccess.m @@ -0,0 +1,52 @@ +// +// ADJSuccessResponseData.m +// adjust +// +// Created by Pedro Filipe on 05/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import "ADJSessionSuccess.h" + +@implementation ADJSessionSuccess + ++ (ADJSessionSuccess *)sessionSuccessResponseData { + return [[ADJSessionSuccess alloc] init]; +} + +- (id)init { + self = [super init]; + if (self == nil) return nil; + + return self; +} + +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone +{ + ADJSessionSuccess* copy = [[[self class] allocWithZone:zone] init]; + + if (copy) { + copy.activityKindString = [self.activityKindString copyWithZone:zone]; + copy.message = [self.message copyWithZone:zone]; + copy.timeStamp = [self.timeStamp copyWithZone:zone]; + copy.adid = [self.adid copyWithZone:zone]; + copy.jsonResponse = [self.jsonResponse copyWithZone:zone]; + } + + return copy; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat: @"%@ msg:%@ time:%@ adid:%@ json:%@", + self.activityKindString, + self.message, + self.timeStamp, + self.adid, + self.jsonResponse]; +} + +@end diff --git a/Adjust/ADJUtil.m b/Adjust/ADJUtil.m index 276c305fe..dc2bfa878 100644 --- a/Adjust/ADJUtil.m +++ b/Adjust/ADJUtil.m @@ -332,7 +332,7 @@ + (ADJResponseData *)completionHandler:(NSData *)data suffixErrorMessage:(NSString *)suffixErrorMessage activityPackage:(ADJActivityPackage *)activityPackage { - ADJResponseData * responseData = [ADJResponseData responseDataWithActivityPackage:activityPackage]; + ADJResponseData * responseData = [ADJResponseData buildResponseData:activityPackage]; // connection error if (responseError != nil) { diff --git a/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj b/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj index bd563e135..10811be4b 100644 --- a/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj +++ b/examples/AdjustExample-iOS/AdjustExample-iOS.xcodeproj/project.pbxproj @@ -35,8 +35,10 @@ 963909A61BCBFF8D00A2E8A4 /* ADJTimerOnce.m in Sources */ = {isa = PBXBuildFile; fileRef = 9639098F1BCBFF8D00A2E8A4 /* ADJTimerOnce.m */; }; 963909A71BCBFF8D00A2E8A4 /* Adjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909911BCBFF8D00A2E8A4 /* Adjust.m */; }; 963909A81BCBFF8D00A2E8A4 /* ADJUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909931BCBFF8D00A2E8A4 /* ADJUtil.m */; }; - 96BA940B1C3D57FD00C96245 /* ADJFailureResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA94091C3D57FD00C96245 /* ADJFailureResponseData.m */; }; - 96BA940C1C3D57FD00C96245 /* ADJSuccessResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA940A1C3D57FD00C96245 /* ADJSuccessResponseData.m */; }; + 96BA940B1C3D57FD00C96245 /* ADJSessionFailure.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA94091C3D57FD00C96245 /* ADJSessionFailure.m */; }; + 96BA940C1C3D57FD00C96245 /* ADJSessionSuccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA940A1C3D57FD00C96245 /* ADJSessionSuccess.m */; }; + 96E423CA1C85F3B50006729A /* ADJEventFailure.m in Sources */ = {isa = PBXBuildFile; fileRef = 96E423C71C85F3B50006729A /* ADJEventFailure.m */; }; + 96E423CB1C85F3B50006729A /* ADJEventSuccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 96E423C91C85F3B50006729A /* ADJEventSuccess.m */; }; 96FCC5441C18643E007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5411C18643E007BBFE1 /* ADJResponseData.m */; }; 9DAC2DEB1C0F611300AC9D97 /* URLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DAC2DEA1C0F611300AC9D97 /* URLRequest.m */; }; 9DC95F261C104CEF00138E4B /* ViewControlleriOS.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F251C104CEF00138E4B /* ViewControlleriOS.m */; }; @@ -96,10 +98,14 @@ 963909911BCBFF8D00A2E8A4 /* Adjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Adjust.m; sourceTree = ""; }; 963909921BCBFF8D00A2E8A4 /* ADJUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJUtil.h; sourceTree = ""; }; 963909931BCBFF8D00A2E8A4 /* ADJUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJUtil.m; sourceTree = ""; }; - 96BA94071C3D57FD00C96245 /* ADJSuccessResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSuccessResponseData.h; sourceTree = ""; }; - 96BA94081C3D57FD00C96245 /* ADJFailureResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJFailureResponseData.h; sourceTree = ""; }; - 96BA94091C3D57FD00C96245 /* ADJFailureResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJFailureResponseData.m; sourceTree = ""; }; - 96BA940A1C3D57FD00C96245 /* ADJSuccessResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSuccessResponseData.m; sourceTree = ""; }; + 96BA94071C3D57FD00C96245 /* ADJSessionSuccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSessionSuccess.h; sourceTree = ""; }; + 96BA94081C3D57FD00C96245 /* ADJSessionFailure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSessionFailure.h; sourceTree = ""; }; + 96BA94091C3D57FD00C96245 /* ADJSessionFailure.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSessionFailure.m; sourceTree = ""; }; + 96BA940A1C3D57FD00C96245 /* ADJSessionSuccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSessionSuccess.m; sourceTree = ""; }; + 96E423C61C85F3B50006729A /* ADJEventFailure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJEventFailure.h; sourceTree = ""; }; + 96E423C71C85F3B50006729A /* ADJEventFailure.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJEventFailure.m; sourceTree = ""; }; + 96E423C81C85F3B50006729A /* ADJEventSuccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJEventSuccess.h; sourceTree = ""; }; + 96E423C91C85F3B50006729A /* ADJEventSuccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJEventSuccess.m; sourceTree = ""; }; 96FCC5401C18643E007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseData.h; sourceTree = ""; }; 96FCC5411C18643E007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseData.m; sourceTree = ""; }; 9DAC2DE91C0F611300AC9D97 /* URLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLRequest.h; sourceTree = ""; }; @@ -173,10 +179,14 @@ 963909681BCBFF8D00A2E8A4 /* Adjust */ = { isa = PBXGroup; children = ( - 96BA94071C3D57FD00C96245 /* ADJSuccessResponseData.h */, - 96BA94081C3D57FD00C96245 /* ADJFailureResponseData.h */, - 96BA94091C3D57FD00C96245 /* ADJFailureResponseData.m */, - 96BA940A1C3D57FD00C96245 /* ADJSuccessResponseData.m */, + 96E423C61C85F3B50006729A /* ADJEventFailure.h */, + 96E423C71C85F3B50006729A /* ADJEventFailure.m */, + 96E423C81C85F3B50006729A /* ADJEventSuccess.h */, + 96E423C91C85F3B50006729A /* ADJEventSuccess.m */, + 96BA94071C3D57FD00C96245 /* ADJSessionSuccess.h */, + 96BA94081C3D57FD00C96245 /* ADJSessionFailure.h */, + 96BA94091C3D57FD00C96245 /* ADJSessionFailure.m */, + 96BA940A1C3D57FD00C96245 /* ADJSessionSuccess.m */, 96FCC5401C18643E007BBFE1 /* ADJResponseData.h */, 96FCC5411C18643E007BBFE1 /* ADJResponseData.m */, 963909691BCBFF8D00A2E8A4 /* ADJActivityHandler.h */, @@ -307,7 +317,7 @@ 9639099F1BCBFF8D00A2E8A4 /* ADJDeviceInfo.m in Sources */, 963909A81BCBFF8D00A2E8A4 /* ADJUtil.m in Sources */, 9DAC2DEB1C0F611300AC9D97 /* URLRequest.m in Sources */, - 96BA940B1C3D57FD00C96245 /* ADJFailureResponseData.m in Sources */, + 96BA940B1C3D57FD00C96245 /* ADJSessionFailure.m in Sources */, 9639099D1BCBFF8D00A2E8A4 /* ADJAttributionHandler.m in Sources */, 963909A21BCBFF8D00A2E8A4 /* ADJPackageBuilder.m in Sources */, 963909A51BCBFF8D00A2E8A4 /* ADJTimerCycle.m in Sources */, @@ -316,9 +326,10 @@ 963909951BCBFF8D00A2E8A4 /* ADJActivityKind.m in Sources */, 9639099A1BCBFF8D00A2E8A4 /* UIDevice+ADJAdditions.m in Sources */, 963909971BCBFF8D00A2E8A4 /* ADJActivityState.m in Sources */, - 96BA940C1C3D57FD00C96245 /* ADJSuccessResponseData.m in Sources */, + 96BA940C1C3D57FD00C96245 /* ADJSessionSuccess.m in Sources */, 963909A11BCBFF8D00A2E8A4 /* ADJLogger.m in Sources */, 963909961BCBFF8D00A2E8A4 /* ADJActivityPackage.m in Sources */, + 96E423CA1C85F3B50006729A /* ADJEventFailure.m in Sources */, 96FCC5441C18643E007BBFE1 /* ADJResponseData.m in Sources */, 963909A01BCBFF8D00A2E8A4 /* ADJEvent.m in Sources */, 963909A31BCBFF8D00A2E8A4 /* ADJPackageHandler.m in Sources */, @@ -331,6 +342,7 @@ 963909441BCBFCF300A2E8A4 /* AppDelegate.m in Sources */, 9639099B1BCBFF8D00A2E8A4 /* ADJAdjustFactory.m in Sources */, 963909411BCBFCF300A2E8A4 /* main.m in Sources */, + 96E423CB1C85F3B50006729A /* ADJEventSuccess.m in Sources */, 9639099C1BCBFF8D00A2E8A4 /* ADJAttribution.m in Sources */, 9DC95F261C104CEF00138E4B /* ViewControlleriOS.m in Sources */, ); diff --git a/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m b/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m index 49e5b05d3..0d82e37f0 100644 --- a/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m +++ b/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m @@ -36,16 +36,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // set an attribution delegate [adjustConfig setDelegate:self]; - // set finished success tracking delegate - [adjustConfig setSuccessDelegate:^(ADJSuccessResponseData *successResponseData) { - NSLog(@"adjust successResponseData %@", successResponseData); - }]; - - // set finished failure tracking delegate - [adjustConfig setFailureDelegate:^(ADJFailureResponseData *failureResponseData) { - NSLog(@"adjust failureResponseData %@", failureResponseData); - }]; - [Adjust appDidLaunch:adjustConfig]; // put the SDK in offline mode @@ -67,6 +57,22 @@ - (void)adjustAttributionChanged:(ADJAttribution *)attribution { NSLog(@"adjust attribution %@", attribution); } +- (void)adjustEventTrackingSucceeded:(ADJEventSuccess *)eventSuccessResponseData { + NSLog(@"adjust event success %@", eventSuccessResponseData); +} + +- (void)adjustEventTrackingFailed:(ADJEventFailure *)eventFailureResponseData { + NSLog(@"adjust event failure %@", eventFailureResponseData); +} + +- (void)adjustSessionTrackingSucceeded:(ADJSessionSuccess *)sessionSuccessResponseData { + NSLog(@"adjust session success %@", sessionSuccessResponseData); +} + +- (void)adjustSessionTrackingFailed:(ADJSessionFailure *)sessionFailureResponseData { + NSLog(@"adjust session failure %@", sessionFailureResponseData); +} + - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. diff --git a/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj b/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj index c8187e027..df899735d 100644 --- a/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj +++ b/examples/AdjustExample-tvOS/AdjustExample-tvOS.xcodeproj/project.pbxproj @@ -34,8 +34,8 @@ 96390A0F1BCC0DF100A2E8A4 /* ADJTimerOnce.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909F81BCC0DF100A2E8A4 /* ADJTimerOnce.m */; }; 96390A101BCC0DF100A2E8A4 /* Adjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909FA1BCC0DF100A2E8A4 /* Adjust.m */; }; 96390A111BCC0DF100A2E8A4 /* ADJUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 963909FC1BCC0DF100A2E8A4 /* ADJUtil.m */; }; - 96BA94051C3D57ED00C96245 /* ADJFailureResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA94031C3D57ED00C96245 /* ADJFailureResponseData.m */; }; - 96BA94061C3D57ED00C96245 /* ADJSuccessResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA94041C3D57ED00C96245 /* ADJSuccessResponseData.m */; }; + 96BA94051C3D57ED00C96245 /* ADJSessionFailure.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA94031C3D57ED00C96245 /* ADJSessionFailure.m */; }; + 96BA94061C3D57ED00C96245 /* ADJSessionSuccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 96BA94041C3D57ED00C96245 /* ADJSessionSuccess.m */; }; 96FCC54A1C186458007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5471C186458007BBFE1 /* ADJResponseData.m */; }; 9DC95F2F1C10596500138E4B /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F2E1C10596500138E4B /* Constants.m */; }; 9DC95F321C105B4C00138E4B /* URLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DC95F311C105B4C00138E4B /* URLRequest.m */; }; @@ -94,10 +94,10 @@ 963909FA1BCC0DF100A2E8A4 /* Adjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Adjust.m; sourceTree = ""; }; 963909FB1BCC0DF100A2E8A4 /* ADJUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJUtil.h; sourceTree = ""; }; 963909FC1BCC0DF100A2E8A4 /* ADJUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJUtil.m; sourceTree = ""; }; - 96BA94011C3D57ED00C96245 /* ADJSuccessResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSuccessResponseData.h; sourceTree = ""; }; - 96BA94021C3D57ED00C96245 /* ADJFailureResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJFailureResponseData.h; sourceTree = ""; }; - 96BA94031C3D57ED00C96245 /* ADJFailureResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJFailureResponseData.m; sourceTree = ""; }; - 96BA94041C3D57ED00C96245 /* ADJSuccessResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSuccessResponseData.m; sourceTree = ""; }; + 96BA94011C3D57ED00C96245 /* ADJSessionSuccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSessionSuccess.h; sourceTree = ""; }; + 96BA94021C3D57ED00C96245 /* ADJSessionFailure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSessionFailure.h; sourceTree = ""; }; + 96BA94031C3D57ED00C96245 /* ADJSessionFailure.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSessionFailure.m; sourceTree = ""; }; + 96BA94041C3D57ED00C96245 /* ADJSessionSuccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSessionSuccess.m; sourceTree = ""; }; 96FCC5461C186458007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseData.h; sourceTree = ""; }; 96FCC5471C186458007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseData.m; sourceTree = ""; }; 9DC95F2D1C10596500138E4B /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constants.h; sourceTree = ""; }; @@ -166,10 +166,10 @@ 963909D11BCC0DF100A2E8A4 /* Adjust */ = { isa = PBXGroup; children = ( - 96BA94011C3D57ED00C96245 /* ADJSuccessResponseData.h */, - 96BA94021C3D57ED00C96245 /* ADJFailureResponseData.h */, - 96BA94031C3D57ED00C96245 /* ADJFailureResponseData.m */, - 96BA94041C3D57ED00C96245 /* ADJSuccessResponseData.m */, + 96BA94011C3D57ED00C96245 /* ADJSessionSuccess.h */, + 96BA94021C3D57ED00C96245 /* ADJSessionFailure.h */, + 96BA94031C3D57ED00C96245 /* ADJSessionFailure.m */, + 96BA94041C3D57ED00C96245 /* ADJSessionSuccess.m */, 96FCC5461C186458007BBFE1 /* ADJResponseData.h */, 96FCC5471C186458007BBFE1 /* ADJResponseData.m */, 963909D21BCC0DF100A2E8A4 /* ADJActivityHandler.h */, @@ -299,7 +299,7 @@ 96390A081BCC0DF100A2E8A4 /* ADJDeviceInfo.m in Sources */, 96390A111BCC0DF100A2E8A4 /* ADJUtil.m in Sources */, 96390A061BCC0DF100A2E8A4 /* ADJAttributionHandler.m in Sources */, - 96BA94051C3D57ED00C96245 /* ADJFailureResponseData.m in Sources */, + 96BA94051C3D57ED00C96245 /* ADJSessionFailure.m in Sources */, 96390A0B1BCC0DF100A2E8A4 /* ADJPackageBuilder.m in Sources */, 96390A0E1BCC0DF100A2E8A4 /* ADJTimerCycle.m in Sources */, 9DC95F2F1C10596500138E4B /* Constants.m in Sources */, @@ -308,7 +308,7 @@ 96390A031BCC0DF100A2E8A4 /* UIDevice+ADJAdditions.m in Sources */, 96390A001BCC0DF100A2E8A4 /* ADJActivityState.m in Sources */, 96390A0A1BCC0DF100A2E8A4 /* ADJLogger.m in Sources */, - 96BA94061C3D57ED00C96245 /* ADJSuccessResponseData.m in Sources */, + 96BA94061C3D57ED00C96245 /* ADJSessionSuccess.m in Sources */, 963909FF1BCC0DF100A2E8A4 /* ADJActivityPackage.m in Sources */, 96390A091BCC0DF100A2E8A4 /* ADJEvent.m in Sources */, 96FCC54A1C186458007BBFE1 /* ADJResponseData.m in Sources */, diff --git a/examples/AdjustExample-tvOS/AdjustExample-tvOS/AppDelegate.m b/examples/AdjustExample-tvOS/AdjustExample-tvOS/AppDelegate.m index 825e5940d..5bc063f00 100644 --- a/examples/AdjustExample-tvOS/AdjustExample-tvOS/AppDelegate.m +++ b/examples/AdjustExample-tvOS/AdjustExample-tvOS/AppDelegate.m @@ -40,16 +40,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // set an attribution delegate [adjustConfig setDelegate:self]; - // set finished success tracking delegate - [adjustConfig setSuccessDelegate:^(ADJSuccessResponseData *successResponseData) { - NSLog(@"adjust successResponseData %@", successResponseData); - }]; - - // set finished failure tracking delegate - [adjustConfig setFailureDelegate:^(ADJFailureResponseData *failureResponseData) { - NSLog(@"adjust failureResponseData %@", failureResponseData); - }]; - [Adjust appDidLaunch:adjustConfig]; // put the SDK in offline mode @@ -61,6 +51,26 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( return YES; } +- (void)adjustAttributionChanged:(ADJAttribution *)attribution { + NSLog(@"adjust attribution %@", attribution); +} + +- (void)adjustEventTrackingSucceeded:(ADJEventSuccess *)eventSuccessResponseData { + NSLog(@"adjust event success %@", eventSuccessResponseData); +} + +- (void)adjustEventTrackingFailed:(ADJEventFailure *)eventFailureResponseData { + NSLog(@"adjust event failure %@", eventFailureResponseData); +} + +- (void)adjustSessionTrackingSucceeded:(ADJSessionSuccess *)sessionSuccessResponseData { + NSLog(@"adjust session success %@", sessionSuccessResponseData); +} + +- (void)adjustSessionTrackingFailed:(ADJSessionFailure *)sessionFailureResponseData { + NSLog(@"adjust session failure %@", sessionFailureResponseData); +} + - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { [Adjust appWillOpenUrl:url]; From d709b0aef1321450effa91004242f6c65b4d59d7 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 19 Feb 2016 15:25:41 +0100 Subject: [PATCH 23/33] Update tests for session delegate --- AdjustTests/ADJActivityHandlerMock.m | 16 +- AdjustTests/ADJActivityHandlerTests.m | 452 ++++++++++----------- AdjustTests/ADJAttributionHandlerMock.m | 10 +- AdjustTests/ADJAttributionHandlerTests.m | 12 +- AdjustTests/ADJTrackingFailedDelegate.m | 8 +- AdjustTests/ADJTrackingSucceededDelegate.m | 7 +- 6 files changed, 249 insertions(+), 256 deletions(-) diff --git a/AdjustTests/ADJActivityHandlerMock.m b/AdjustTests/ADJActivityHandlerMock.m index 2d64869db..f350cfb68 100644 --- a/AdjustTests/ADJActivityHandlerMock.m +++ b/AdjustTests/ADJActivityHandlerMock.m @@ -95,16 +95,20 @@ - (void)setIadDetails:(NSDictionary *)attributionDetails [self.loggerMock test:[prefix stringByAppendingFormat:@"setIadDetails, %@ error, %@", attributionDetails, error]]; } -- (void) launchAttributionChangedDelegateWithDeeplink:(ADJResponseData *)responseData { - [self.loggerMock test:[prefix stringByAppendingFormat:@"launchAttributionChangedDelegateWithDeeplink, %@", responseData]]; - self.lastResponseData = responseData; +- (void)launchEventResponseTasks:(ADJEventResponseData *)eventResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"launchEventResponseTasks, %@", eventResponseData]]; + self.lastResponseData = eventResponseData; } -- (void) launchAttributionChangedDelegate:(ADJResponseData *)responseData { - [self.loggerMock test:[prefix stringByAppendingFormat:@"launchAttributionChangedDelegate, %@", responseData]]; - self.lastResponseData = responseData; +- (void)launchSessionResponseTasks:(ADJSessionResponseData *)sessionResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"launchSessionResponseTasks, %@", sessionResponseData]]; + self.lastResponseData = sessionResponseData; } +- (void)launchAttributionResponseTasks:(ADJAttributionResponseData *)attributionResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"launchAttributionResponseTasks, %@", attributionResponseData]]; + self.lastResponseData = attributionResponseData; +} - (void) setOfflineMode:(BOOL)enabled { [self.loggerMock test:[prefix stringByAppendingFormat:@"setOfflineMode"]]; diff --git a/AdjustTests/ADJActivityHandlerTests.m b/AdjustTests/ADJActivityHandlerTests.m index f015c7d40..2e1a36098 100644 --- a/AdjustTests/ADJActivityHandlerTests.m +++ b/AdjustTests/ADJActivityHandlerTests.m @@ -1054,254 +1054,63 @@ - (void)testIadDetails [self testClickPackage:clickPackage fields:clickPackageFields source:@"iad3"]; } -- (void)testFinishedTracking +- (void)testAttributionDelegate { // reseting to make the test order independent [self reset]; - // create the config to start the session - ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentProduction]; - - // set verbose log level - config.logLevel = ADJLogLevelDebug; - - // set delegate ADJDelegateTest * delegateTests = [[ADJDelegateTest alloc] init]; - [config setDelegate:delegateTests]; - - aDebug(@"Delegate implements adjustAttributionChanged"); - - // create handler and start the first session - id activityHandler = [ADJActivityHandler handlerWithConfig:config]; - - [activityHandler trackEvent:[ADJEvent eventWithEventToken:@"abc123"]]; - - [NSThread sleepForTimeInterval:3.0]; - - // test init values - [self checkInit:ADJEnvironmentProduction logLevel:@"6"]; - - // test first session start - [self checkFirstSession]; - - // test session package to be checked for attribution - ADJActivityPackage * firstSessionPackage = self.packageHandlerMock.packageQueue[0]; - ADJResponseData * firstSessionResponseData = [ADJResponseData responseDataWithActivityPackage:firstSessionPackage]; - - [activityHandler finishedTracking:firstSessionResponseData]; - [NSThread sleepForTimeInterval:1.0]; - - aTest(@"AttributionHandler checkSessionResponse"); - - // test event success response data - ADJActivityPackage * eventPackage = self.packageHandlerMock.packageQueue[1]; - ADJResponseData * eventResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; - eventResponseData.success = YES; - - [activityHandler finishedTracking:eventResponseData]; - [NSThread sleepForTimeInterval:1.0]; - - anTest(@"AttributionHandler checkSessionResponse"); - anDebug(@"Delegate implements adjustTrackingSucceeded"); - anDebug(@"Delegate implements adjustTrackingFailed"); - // test event failed response data - eventResponseData.success = NO; + [self checkFinishTasks:delegateTests +attributionDelegatePresent:YES +eventSuccessDelegatePresent:NO +eventFailureDelegatePresent:NO +sessionSuccessDelegatePresent:NO +sessionFailureDelegatePresent:NO]; - [activityHandler finishedTracking:eventResponseData]; - [NSThread sleepForTimeInterval:1.0]; - - anTest(@"AttributionHandler checkSessionResponse"); - anDebug(@"Delegate implements adjustTrackingSucceeded"); - anDebug(@"Delegate implements adjustTrackingFailed"); } -- (void) testLaunchSuccessResponseTasks +- (void)testSuccessDelegates { // reseting to make the test order independent [self reset]; - // create the config to start the session - ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; - ADJTrackingSucceededDelegate * successDelegate = [[ADJTrackingSucceededDelegate alloc] init]; - [config setDelegate:successDelegate]; - - anDebug(@"Delegate implements adjustAttributionChanged"); - anDebug(@"Delegate implements adjustTrackingFailed"); - aDebug(@"Delegate implements adjustTrackingSucceeded"); - - // create handler and start the first session - id activityHandler = [ADJActivityHandler handlerWithConfig:config]; - - NSURL* attributions = [NSURL URLWithString:@"AdjustTests://example.com/path/inApp?adjust_tracker=trackerValue&other=stuff&adjust_campaign=campaignValue&adjust_adgroup=adgroupValue&adjust_creative=creativeValue"]; - - [activityHandler appWillOpenUrl:attributions]; - - [activityHandler trackEvent:[ADJEvent eventWithEventToken:@"abc123"]]; - - [NSThread sleepForTimeInterval:3.0]; - - [self checkInitAndFirstSession]; - - // test success event response data - ADJActivityPackage * eventPackage = self.packageHandlerMock.packageQueue[2]; - ADJResponseData * eventSuccessResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; - eventSuccessResponseData.success = YES; - - [activityHandler finishedTracking:eventSuccessResponseData]; - [NSThread sleepForTimeInterval:2.0]; - - anTest(@"AttributionHandler checkSessionResponse"); - anDebug(@"Launching failed event tracking delegate"); - aDebug(@"Launching success event tracking delegate"); - - // test success sdk_click response data - ADJActivityPackage * sdkClickPackage = self.packageHandlerMock.packageQueue[1]; - ADJResponseData * sdkClickResponseData = [ADJResponseData responseDataWithActivityPackage:sdkClickPackage]; - sdkClickResponseData.success = YES; - - [activityHandler finishedTracking:sdkClickResponseData]; - [NSThread sleepForTimeInterval:1.0]; - anTest(@"AttributionHandler checkSessionResponse"); - anDebug(@"Launching success event tracking delegate"); - anDebug(@"Launching failed event tracking delegate"); - - // test failed event response data - ADJResponseData * eventFailureResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; - eventFailureResponseData.success = NO; + [self checkFinishTasks:successDelegate +attributionDelegatePresent:NO +eventSuccessDelegatePresent:YES +eventFailureDelegatePresent:NO +sessionSuccessDelegatePresent:YES +sessionFailureDelegatePresent:NO]; - [activityHandler finishedTracking:eventFailureResponseData]; - [NSThread sleepForTimeInterval:2.0]; - - anTest(@"AttributionHandler checkSessionResponse"); - anDebug(@"Launching success event tracking delegate"); - // does not launch because delegate does not have failed callback - anDebug(@"Launching failed event tracking delegate"); } -- (void) testLaunchFailureResponseTasks +- (void)testFailureDelegates { // reseting to make the test order independent [self reset]; - // create the config to start the session - ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; - ADJTrackingFailedDelegate * failureDelegate = [[ADJTrackingFailedDelegate alloc] init]; - [config setDelegate:failureDelegate]; - - anDebug(@"Delegate implements adjustAttributionChanged"); - anDebug(@"Delegate implements adjustTrackingSucceeded"); - aDebug(@"Delegate implements adjustTrackingFailed"); - - // create handler and start the first session - id activityHandler = [ADJActivityHandler handlerWithConfig:config]; - NSURL* attributions = [NSURL URLWithString:@"AdjustTests://example.com/path/inApp?adjust_tracker=trackerValue&other=stuff&adjust_campaign=campaignValue&adjust_adgroup=adgroupValue&adjust_creative=creativeValue"]; - - [activityHandler appWillOpenUrl:attributions]; - - [activityHandler trackEvent:[ADJEvent eventWithEventToken:@"abc123"]]; - - [NSThread sleepForTimeInterval:3.0]; - - [self checkInitAndFirstSession]; - - // test failed event response data - ADJActivityPackage * eventPackage = self.packageHandlerMock.packageQueue[2]; - ADJResponseData * eventFailureResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; - eventFailureResponseData.success = NO; - - [activityHandler finishedTracking:eventFailureResponseData]; - [NSThread sleepForTimeInterval:1.0]; - - anTest(@"AttributionHandler checkSessionResponse"); - anDebug(@"Launching success event tracking delegate"); - aDebug(@"Launching failed event tracking delegate"); - - // test success sdk_click response data - ADJActivityPackage * sdkClickPackage = self.packageHandlerMock.packageQueue[1]; - ADJResponseData * sdkClickResponseData = [ADJResponseData responseDataWithActivityPackage:sdkClickPackage]; - sdkClickResponseData.success = NO; - - [activityHandler finishedTracking:sdkClickResponseData]; - [NSThread sleepForTimeInterval:1.0]; - - anTest(@"AttributionHandler checkSessionResponse"); - anDebug(@"Launching success event tracking delegate"); - anDebug(@"Launching failed event tracking delegate"); - - // test success event response data - ADJResponseData * eventSuccessResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; - eventSuccessResponseData.success = YES; - - [activityHandler finishedTracking:eventSuccessResponseData]; - [NSThread sleepForTimeInterval:1.0]; - - anTest(@"AttributionHandler checkSessionResponse"); - anDebug(@"Launching failed event tracking delegate"); - anDebug(@"Launching success event tracking delegate"); + [self checkFinishTasks:failureDelegate +attributionDelegatePresent:NO +eventSuccessDelegatePresent:NO +eventFailureDelegatePresent:YES +sessionSuccessDelegatePresent:NO +sessionFailureDelegatePresent:YES]; } -/* - - // test nil response - [activityHandler finishedTracking:nil]; - [NSThread sleepForTimeInterval:1.0]; - - // if the response is null - anTest(@"AttributionHandler checkAttribution"); - anTest(@"Unable to open deep link"); - anTest(@"Open deep link"); - - // set package handler to respond with a valid attribution - - NSString * deeplinkString = @"{\"deeplink\":\"wrongDeeplink://\"}"; - NSData * deeplinkData = [deeplinkString dataUsingEncoding:NSUTF8StringEncoding]; - NSError *error = nil; - NSException *exception = nil; - - NSDictionary * deeplinkDictionary = [ADJUtil buildJsonDict:deeplinkData exceptionPtr:&exception errorPtr:&error]; - - anNil(deeplinkDictionary); - - //[activityHandler finishedTracking:deeplinkDictionary]; - - [NSThread sleepForTimeInterval:1.0]; - - // check that it was unable to open the url - aError(@"Unable to open deep link (wrongDeeplink://)"); - - // and it check the attribution - aTest(@"AttributionHandler checkAttribution"); - // TODO add test that opens url - - // checking the default values of the first session package - // should only have one package - aiEquals(1, (int)[self.packageHandlerMock.packageQueue count]); - - ADJActivityPackage *activityPackage = (ADJActivityPackage *) self.packageHandlerMock.packageQueue[0]; - - // create activity package test - ADJPackageFields * fields = [ADJPackageFields fields]; - - fields.hasDelegate = @"1"; - fields.environment = @"production"; - - // set first session - [self testPackageSession:activityPackage fields:fields sessionCount:@"1"]; -} - */ - - (void)testLaunchDeepLink { // reseting to make the test order independent [self reset]; - // create the config - ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; + // create the config to start the session + ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentProduction]; + + // set verbose log level + config.logLevel = ADJLogLevelDebug; // start the session id activityHandler =[ADJActivityHandler handlerWithConfig:config]; @@ -1314,11 +1123,15 @@ - (void)testLaunchDeepLink [NSThread sleepForTimeInterval:3.0]; - [self checkInitAndFirstSession]; + // test init values + [self checkInit:ADJEnvironmentProduction logLevel:@"6"]; + + // test first session start + [self checkFirstSession]; // test success event response data ADJActivityPackage * eventPackage = self.packageHandlerMock.packageQueue[2]; - ADJResponseData * eventSuccessResponseData = [ADJResponseData responseDataWithActivityPackage:eventPackage]; + ADJEventResponseData * eventSuccessResponseData = [ADJResponseData buildResponseData:eventPackage]; eventSuccessResponseData.success = YES; NSString * deeplinkString = @"{\"deeplink\":\"wrongDeeplink://\"}"; @@ -1330,24 +1143,13 @@ - (void)testLaunchDeepLink anNil(deeplinkDictionary); - eventSuccessResponseData.jsonResponse = deeplinkDictionary; - - [activityHandler finishedTracking:eventSuccessResponseData]; - [NSThread sleepForTimeInterval:2.0]; - - // event response does not open deeplinks - anInfo(@"Open deep link (wrongDeeplink://)"); - - anError(@"Unable to open deep link (wrongDeeplink://)"); - - // test success session response data ADJActivityPackage * sessionPackage = self.packageHandlerMock.packageQueue[0]; - ADJResponseData * sessionResponseData = [[ADJResponseData alloc] initWithActivityPackage:sessionPackage]; + ADJSessionResponseData * sessionResponseData = [ADJResponseData buildResponseData:sessionPackage]; sessionResponseData.jsonResponse = deeplinkDictionary; - [activityHandler launchAttributionChangedDelegateWithDeeplink:sessionResponseData]; + [activityHandler launchSessionResponseTasks:sessionResponseData]; [NSThread sleepForTimeInterval:2.0]; aInfo(@"Open deep link (wrongDeeplink://)"); @@ -1399,8 +1201,16 @@ - (void)testUpdateAttribution emptyAttribution = [[ADJAttribution alloc] initWithJsonDict:emptyJsonDictionary]; + // test first session package + ADJActivityPackage * firstSessionPackage = self.packageHandlerMock.packageQueue[0]; + // simulate a session response with attribution data + ADJSessionResponseData * sessionResponseDataWithAttribution = [ADJResponseData buildResponseData:firstSessionPackage]; + + sessionResponseDataWithAttribution.attribution = emptyAttribution; // check that it does not update the attribution - aFalse([activityHandler updateAttribution:emptyAttribution]); + [activityHandler launchSessionResponseTasks:sessionResponseDataWithAttribution]; + [NSThread sleepForTimeInterval:1]; + anDebug(@"Wrote Attribution"); // end session @@ -1429,7 +1239,7 @@ - (void)testUpdateAttribution [self checkSubsession:1 subSessionCount:2 timerAlreadyStarted:NO]; // check that it does not update the attribution after the restart - //aFalse([restartActivityHandler updateAttribution:emptyAttribution]); + aFalse([restartActivityHandler updateAttribution:emptyAttribution]); anDebug(@"Wrote Attribution"); // new attribution @@ -1452,8 +1262,11 @@ - (void)testUpdateAttribution ADJAttribution * firstAttribution = [[ADJAttribution alloc] initWithJsonDict:firstAttributionDictionary]; + sessionResponseDataWithAttribution.attribution = firstAttribution; //check that it updates - aTrue([restartActivityHandler updateAttribution:firstAttribution]); + [restartActivityHandler launchSessionResponseTasks:sessionResponseDataWithAttribution]; + [NSThread sleepForTimeInterval:1]; + aDebug(@"Wrote Attribution: tt:ttValue tn:tnValue net:nValue cam:cpValue adg:aValue cre:ctValue cl:clValue"); // check that it launch the saved attribute @@ -1461,8 +1274,16 @@ - (void)testUpdateAttribution //[NSThread sleepForTimeInterval:2]; //aTest(@"ADJDelegateTest adjustAttributionChanged, tt:null tn:null net:null cam:null adg:null cre:null cl:null"); + // test first session package + ADJActivityPackage * attributionPackage = self.attributionHandlerMock.attributionPackage; + // simulate a session response with attribution data + ADJAttributionResponseData * attributionResponseDataWithAttribution = [ADJResponseData buildResponseData:attributionPackage]; + + attributionResponseDataWithAttribution.attribution = firstAttribution; // check that it does not update the attribution - aFalse([restartActivityHandler updateAttribution:firstAttribution]); + [restartActivityHandler launchAttributionResponseTasks:attributionResponseDataWithAttribution]; + [NSThread sleepForTimeInterval:1]; + anDebug(@"Wrote Attribution"); // end session @@ -1509,7 +1330,11 @@ - (void)testUpdateAttribution ADJAttribution * secondAttribution = [[ADJAttribution alloc] initWithJsonDict:secondAttributionDictionary]; //check that it updates - aTrue([secondRestartActivityHandler updateAttribution:secondAttribution]); + attributionResponseDataWithAttribution.attribution = secondAttribution; + + [secondRestartActivityHandler launchAttributionResponseTasks:attributionResponseDataWithAttribution]; + [NSThread sleepForTimeInterval:1]; + aDebug(@"Wrote Attribution: tt:ttValue2 tn:tnValue2 net:nValue2 cam:cpValue2 adg:aValue2 cre:ctValue2 cl:clValue2"); // check that it launch the saved attribute @@ -2127,4 +1952,157 @@ - (void)checkTimerIsFired:(BOOL)timerFired } } + +- (void)checkFinishTasks:(NSObject *)delegateTest +attributionDelegatePresent:(BOOL)attributionDelegatePresent +eventSuccessDelegatePresent:(BOOL)eventSuccessDelegatePresent +eventFailureDelegatePresent:(BOOL)eventFailureDelegatePresent +sessionSuccessDelegatePresent:(BOOL)sessionSuccessDelegatePresent +sessionFailureDelegatePresent:(BOOL)sessionFailureDelegatePresent +{ + // create the config to start the session + ADJConfig * config = [ADJConfig configWithAppToken:@"123456789012" environment:ADJEnvironmentSandbox]; + + // set delegate + [config setDelegate:delegateTest]; + + if (attributionDelegatePresent) { + aDebug(@"Delegate implements adjustAttributionChanged"); + } else { + anDebug(@"Delegate implements adjustAttributionChanged"); + } + if (eventSuccessDelegatePresent) { + aDebug(@"Delegate implements adjustEventTrackingSucceeded"); + } else { + anDebug(@"Delegate implements adjustEventTrackingSucceeded"); + } + if (eventFailureDelegatePresent) { + aDebug(@"Delegate implements adjustEventTrackingFailed"); + } else { + anDebug(@"Delegate implements adjustEventTrackingFailed"); + } + if (sessionSuccessDelegatePresent) { + aDebug(@"Delegate implements adjustSessionTrackingSucceeded"); + } else { + anDebug(@"Delegate implements adjustSessionTrackingSucceeded"); + } + if (sessionFailureDelegatePresent) { + aDebug(@"Delegate implements adjustSessionTrackingFailed"); + } else { + anDebug(@"Delegate implements adjustSessionTrackingFailed"); + } + + // create handler and start the first session + id activityHandler = [ADJActivityHandler handlerWithConfig:config]; + + [NSThread sleepForTimeInterval:2.0]; + + [self checkInitAndFirstSession]; + + // test first session package + ADJActivityPackage * firstSessionPackage = self.packageHandlerMock.packageQueue[0]; + // simulate a successful session + ADJSessionResponseData * successSessionResponseData = [ADJResponseData buildResponseData:firstSessionPackage]; + successSessionResponseData.success = YES; + + [activityHandler finishedTracking:successSessionResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + // attribution handler should always receive the session response + aTest(@"AttributionHandler checkSessionResponse"); + // the first session does not trigger the event response delegate + anDebug(@"Launching success event tracking delegate"); + anDebug(@"Launching failed event tracking delegate"); + + [activityHandler launchSessionResponseTasks:successSessionResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + // if present, the first session triggers the success session delegate + if (sessionSuccessDelegatePresent) { + aDebug(@"Launching success session tracking delegate"); + } else { + anDebug(@"Launching success session tracking delegate"); + } + // it doesn't trigger the failure session delegate + anDebug(@"Launching failed session tracking delegate"); + + // simulate a failure session + ADJSessionResponseData * failureSessionResponseData = [ADJResponseData buildResponseData:firstSessionPackage]; + failureSessionResponseData.success = NO; + + [activityHandler launchSessionResponseTasks:failureSessionResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + // it doesn't trigger the success session delegate + anDebug(@"Launching success session tracking delegate"); + + // if present, the first session triggers the failure session delegate + if (sessionFailureDelegatePresent) { + aDebug(@"Launching failed session tracking delegate"); + } else { + anDebug(@"Launching failed session tracking delegate"); + } + + // test success event response data + [activityHandler trackEvent:[ADJEvent eventWithEventToken:@"abc123"]]; + [NSThread sleepForTimeInterval:1.0]; + + ADJActivityPackage * eventPackage = self.packageHandlerMock.packageQueue[1]; + ADJEventResponseData * eventSuccessResponseData = [ADJResponseData buildResponseData:eventPackage]; + eventSuccessResponseData.success = YES; + + [activityHandler finishedTracking:eventSuccessResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + // attribution handler should never receive the event response + anTest(@"AttributionHandler checkSessionResponse"); + + // if present, the success event triggers the success event delegate + if (eventSuccessDelegatePresent) { + aDebug(@"Launching success event tracking delegate"); + } else { + anDebug(@"Launching success event tracking delegate"); + } + // it doesn't trigger the failure event delegate + anDebug(@"Launching failed event tracking delegate"); + + // test failure event response data + ADJEventResponseData * eventFailureResponseData = [ADJResponseData buildResponseData:eventPackage]; + eventFailureResponseData.success = NO; + + [activityHandler finishedTracking:eventFailureResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + // attribution handler should never receive the event response + anTest(@"AttributionHandler checkSessionResponse"); + + // if present, the failure event triggers the failure event delegate + if (eventFailureDelegatePresent) { + aDebug(@"Launching failed event tracking delegate"); + } else { + anDebug(@"Launching failed event tracking delegate"); + } + // it doesn't trigger the success event delegate + anDebug(@"Launching success event tracking delegate"); + + // test click + NSURL* attributions = [NSURL URLWithString:@"AdjustTests://example.com/path/inApp?adjust_tracker=trackerValue&other=stuff&adjust_campaign=campaignValue&adjust_adgroup=adgroupValue&adjust_creative=creativeValue"]; + + [activityHandler appWillOpenUrl:attributions]; + + [NSThread sleepForTimeInterval:1.0]; + + // test sdk_click response data + ADJActivityPackage * sdkClickPackage = self.packageHandlerMock.packageQueue[2]; + ADJClickResponseData * sdkClickResponseData = [ADJResponseData buildResponseData:sdkClickPackage]; + + [activityHandler finishedTracking:sdkClickResponseData]; + [NSThread sleepForTimeInterval:1.0]; + + // attribution handler should never receive the click response + anTest(@"AttributionHandler checkSessionResponse"); + // it doesn't trigger the any event delegate + anDebug(@"Launching success event tracking delegate"); + anDebug(@"Launching failed event tracking delegate"); +} @end diff --git a/AdjustTests/ADJAttributionHandlerMock.m b/AdjustTests/ADJAttributionHandlerMock.m index 7dea09090..6d1adf586 100644 --- a/AdjustTests/ADJAttributionHandlerMock.m +++ b/AdjustTests/ADJAttributionHandlerMock.m @@ -36,13 +36,17 @@ - (id)initWithActivityHandler:(id) activityHandler self.loggerMock = (ADJLoggerMock *) [ADJAdjustFactory logger]; self.attributionPackage = attributionPackage; - //[self.loggerMock test:[prefix stringByAppendingFormat:@"initWithActivityHandler"]]; + [self.loggerMock test:[prefix stringByAppendingFormat:@"initWithActivityHandler"]]; return self; } -- (void)checkSessionResponse:(ADJResponseData *)responseData { - [self.loggerMock test:[prefix stringByAppendingFormat:@"checkSessionResponse, responseData: %@", responseData]]; +- (void)checkSessionResponse:(ADJSessionResponseData *)sessionResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"checkSessionResponse, responseData: %@", sessionResponseData]]; +} + +- (void)checkAttributionResponse:(ADJAttributionResponseData *)attributionResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"checkAttributionResponse, responseData: %@", attributionResponseData]]; } - (void)getAttribution { diff --git a/AdjustTests/ADJAttributionHandlerTests.m b/AdjustTests/ADJAttributionHandlerTests.m index 8a997694b..3ca7ea470 100644 --- a/AdjustTests/ADJAttributionHandlerTests.m +++ b/AdjustTests/ADJAttributionHandlerTests.m @@ -129,7 +129,7 @@ - (void)testGetAttribution aTest(@"ActivityHandler setAskingAttribution, 0"); // check attribution was called without ask_in - aTest(@"ActivityHandler launchAttributionChangedDelegate, message:(null) timestamp:(null) adid:(null) eventToken:(null) success:1 willRetry:0 attribution:(null) json:{\n}"); + aTest(@"ActivityHandler launchAttributionResponseTasks, message:(null) timestamp:(null) adid:(null) success:1 willRetry:0 attribution:(null) json:{\n}"); // test server error [self checkGetAttributionResponse:attributionHandler responseType:ADJSessionResponseTypeServerError]; @@ -143,7 +143,7 @@ - (void)testGetAttribution aTest(@"ActivityHandler setAskingAttribution, 0"); // check attribution was called without ask_in - aTest(@"ActivityHandler launchAttributionChangedDelegate, message:testResponseError timestamp:(null) json:{\n message = testResponseError;\n}"); + aTest(@"ActivityHandler launchAttributionResponseTasks, message:testResponseError timestamp:(null) adid:(null) success:0 willRetry:0 attribution:(null) json:{\n message = testResponseError;\n}"); // test ok response with message [self checkGetAttributionResponse:attributionHandler responseType:ADJSessionResponseTypeMessage]; @@ -170,7 +170,7 @@ - (void)testCheckSessionResponse NSMutableDictionary * jsonDictionary = [[NSMutableDictionary alloc] init]; [jsonDictionary setObject:attributionDictionary forKey:@"attribution"]; - ADJResponseData * sessionResponseData = [[ADJResponseData alloc] initWithActivityPackage:self.firstSessionPackage]; + ADJSessionResponseData * sessionResponseData = [ADJResponseData buildResponseData:self.firstSessionPackage]; sessionResponseData.jsonResponse = jsonDictionary; [attributionHandler checkSessionResponse:sessionResponseData]; @@ -186,7 +186,7 @@ - (void)testCheckSessionResponse anDebug(@"Waiting to query attribution"); // check attribution changed delegate was called - aTest(@"ActivityHandler launchAttributionChangedDelegateWithDeeplink, message:(null) timestamp:(null) adid:(null) eventToken:(null) success:0 willRetry:0 attribution:tt:ttValue tn:tnValue net:nValue cam:cpValue adg:aValue cre:ctValue cl:clValue"); + aTest(@"ActivityHandler launchSessionResponseTasks, message:(null) timestamp:(null) adid:(null) success:0 willRetry:0 attribution:tt:ttValue tn:tnValue net:nValue cam:cpValue adg:aValue cre:ctValue cl:clValue"); } - (void)testAskIn @@ -202,7 +202,7 @@ - (void)testAskIn // set null response to avoid a cycle; [NSURLSession setResponseType:ADJSessionResponseTypeMessage]; - ADJResponseData * sessionResponseData = [[ADJResponseData alloc] initWithActivityPackage:self.firstSessionPackage]; + ADJSessionResponseData * sessionResponseData = [ADJResponseData buildResponseData:self.firstSessionPackage]; sessionResponseData.jsonResponse = askIn4sDictionary; [attributionHandler checkSessionResponse:sessionResponseData]; @@ -308,7 +308,7 @@ - (void)checkOkMessageGetAttributionResponse // check attribution was called without ask_in aTest(@"ActivityHandler setAskingAttribution, 0"); - aTest(@"ActivityHandler launchAttributionChangedDelegate, message:response OK timestamp:(null) adid:(null) eventToken:(null) success:1 willRetry:0 attribution:(null) json:{\n message = \"response OK\";\n}"); + aTest(@"ActivityHandler launchAttributionResponseTasks, message:response OK timestamp:(null) adid:(null) success:1 willRetry:0 attribution:(null) json:{\n message = \"response OK\";\n}"); } - (void)checkGetAttributionResponse:(id) attributionHandler diff --git a/AdjustTests/ADJTrackingFailedDelegate.m b/AdjustTests/ADJTrackingFailedDelegate.m index f199c3c3e..d9fdf1d83 100644 --- a/AdjustTests/ADJTrackingFailedDelegate.m +++ b/AdjustTests/ADJTrackingFailedDelegate.m @@ -31,8 +31,12 @@ - (id) init { return self; } -- (void)adjustTrackingFailed:(ADJFailureResponseData *)failureResponseData { - [self.loggerMock test:[prefix stringByAppendingFormat:@"adjustTrackingFailed, %@", failureResponseData]]; +- (void)adjustSessionTrackingFailed:(ADJSessionFailure *)sessionFailureResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"adjustSessionTrackingFailed, %@", sessionFailureResponseData]]; +} + +- (void)adjustEventTrackingFailed:(ADJEventFailure *)eventFailureResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"adjustEventTrackingFailed, %@", eventFailureResponseData]]; } @end diff --git a/AdjustTests/ADJTrackingSucceededDelegate.m b/AdjustTests/ADJTrackingSucceededDelegate.m index ef32d1817..65bacd53f 100644 --- a/AdjustTests/ADJTrackingSucceededDelegate.m +++ b/AdjustTests/ADJTrackingSucceededDelegate.m @@ -31,8 +31,11 @@ - (id) init { return self; } -- (void)adjustTrackingSucceeded:(ADJSuccessResponseData *)successResponseData { - [self.loggerMock test:[prefix stringByAppendingFormat:@"adjustTrackingSucceeded, %@", successResponseData]]; +- (void)adjustSessionTrackingSucceeded:(ADJSessionSuccess *)sessionSuccessResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"adjustSessionTrackingSucceeded, %@", sessionSuccessResponseData]]; } +- (void)adjustEventTrackingSucceeded:(ADJEventSuccess *)eventSuccessResponseData { + [self.loggerMock test:[prefix stringByAppendingFormat:@"adjustEventTrackingSucceeded, %@", eventSuccessResponseData]]; +} @end From c8e11f62949da7e550f1a62e374bf17aac0eec8f Mon Sep 17 00:00:00 2001 From: Pedro Filipe Date: Mon, 29 Feb 2016 15:46:34 +0100 Subject: [PATCH 24/33] Update README.md --- README.md | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d3958286a..53576ff5d 100644 --- a/README.md +++ b/README.md @@ -441,34 +441,50 @@ Here is a quick summary of its properties: - `NSString creative` the creative grouping level of the current install. - `NSString clickLabel` the click label of the current install. -### 10. Implement callbacks for tracked events +### 10. Implement callbacks for tracked events and sessions -You can register a delegate callback to be notified of successful and failed tracked events. +You can register a delegate callback to be notified of successful and failed tracked events and/or sessions. The same optional protocol `AdjustDelegate` used for the attribution changed callback [here](#9-implement-the-attribution-callback) is used. Follow the same steps and implement the following delegate callback function for successful tracked events: ```objc -- (void)adjustTrackingSucceeded:(ADJSuccessResponseData *)successResponseData { +- (void)adjustEventTrackingSucceeded:(ADJEventSuccess *)eventSuccessResponseData { } ``` -And the following delegate callback function for failed tracked events: +The following delegate callback function for failed tracked events: ```objc -- (void)adjustTrackingFailed:(ADJFailureResponseData *)failureResponseData { +- (void)adjustEventTrackingFailed:(ADJEventFailure *)eventFailureResponseData { } ``` -The delegate function will be called after the SDK tries to send a package to the server. Within the delegate callback you have access to the `successResponseData` or `failureResponseData` object. Here is a quick summary of its common properties: +For successful tracked sessions: +```objc +adjustSessionTrackingSucceeded:(ADJSessionSuccess *)sessionSuccessResponseData { +} +``` + +And for failed tracked sessions: +```objc +adjustSessionTrackingFailed:(ADJSessionFailure *)sessionFailureResponseData { +} +``` + +The delegate functions will be called after the SDK tries to send a package to the server. Within the delegate callback you have access to a response data object specific for the delegate callback. Here is a quick summary of the session response data properties: -- `NSString activityKindString` the type of package send, for now only `"event"`. - `NSString message` the message from the server or the error logged by the SDK. -- `NSString timestamp` timestamp from the server. +- `NSString timeStamp` timestamp from the server. - `NSString adid` a unique device identifier provided by adjust. -- `NSString eventToken` the event token, if the package tracked was an event. - `NSDictionary jsonResponse` the json object with the reponse from the server. -The extra parameter in `failureResponseData` is currently only `BOOL willRetry` and it indicates whether the package will try to be send again to the server. +Both event response data objects contain: + +- `NSString eventToken` the event token, if the package tracked was an event. + +And both event and session failed objects also contain: + +- `BOOL willRetry` indicates if the package will be retried to be send later ### 11. Disable tracking From 919abfd35facb34c35a8e481d280690917fb2483 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 29 Feb 2016 15:54:31 +0100 Subject: [PATCH 25/33] Remove activity kind string --- Adjust/ADJEventFailure.h | 3 --- Adjust/ADJEventFailure.m | 4 +--- Adjust/ADJEventSuccess.h | 3 --- Adjust/ADJEventSuccess.m | 4 +--- Adjust/ADJSessionFailure.h | 3 --- Adjust/ADJSessionFailure.m | 4 +--- Adjust/ADJSessionSuccess.h | 3 --- Adjust/ADJSessionSuccess.m | 4 +--- 8 files changed, 4 insertions(+), 24 deletions(-) diff --git a/Adjust/ADJEventFailure.h b/Adjust/ADJEventFailure.h index 9b28d005f..8bec40a6d 100644 --- a/Adjust/ADJEventFailure.h +++ b/Adjust/ADJEventFailure.h @@ -10,9 +10,6 @@ @interface ADJEventFailure : NSObject -// activity type of the tracked package. For now only "event" is tracked. -@property (nonatomic, copy) NSString * activityKindString; - // error message from the server or the sdk. @property (nonatomic, copy) NSString * message; diff --git a/Adjust/ADJEventFailure.m b/Adjust/ADJEventFailure.m index 8e1510b8b..e57c83ce0 100644 --- a/Adjust/ADJEventFailure.m +++ b/Adjust/ADJEventFailure.m @@ -28,7 +28,6 @@ -(id)copyWithZone:(NSZone *)zone ADJEventFailure* copy = [[[self class] allocWithZone:zone] init]; if (copy) { - copy.activityKindString = [self.activityKindString copyWithZone:zone]; copy.message = [self.message copyWithZone:zone]; copy.timeStamp = [self.timeStamp copyWithZone:zone]; copy.adid = [self.adid copyWithZone:zone]; @@ -43,8 +42,7 @@ -(id)copyWithZone:(NSZone *)zone #pragma mark - NSObject - (NSString *)description { - return [NSString stringWithFormat: @"%@ msg:%@ time:%@ adid:%@ event:%@ retry:%@ json:%@", - self.activityKindString, + return [NSString stringWithFormat: @"Event Failure msg:%@ time:%@ adid:%@ event:%@ retry:%@ json:%@", self.message, self.timeStamp, self.adid, diff --git a/Adjust/ADJEventSuccess.h b/Adjust/ADJEventSuccess.h index f77d0ca0e..f1efd0494 100644 --- a/Adjust/ADJEventSuccess.h +++ b/Adjust/ADJEventSuccess.h @@ -10,9 +10,6 @@ @interface ADJEventSuccess : NSObject -// activity type of the tracked package. For now only "event" is tracked. -@property (nonatomic, copy) NSString * activityKindString; - // message from the server. @property (nonatomic, copy) NSString * message; diff --git a/Adjust/ADJEventSuccess.m b/Adjust/ADJEventSuccess.m index 4db17ebb2..d1a21153d 100644 --- a/Adjust/ADJEventSuccess.m +++ b/Adjust/ADJEventSuccess.m @@ -28,7 +28,6 @@ -(id)copyWithZone:(NSZone *)zone ADJEventSuccess* copy = [[[self class] allocWithZone:zone] init]; if (copy) { - copy.activityKindString = [self.activityKindString copyWithZone:zone]; copy.message = [self.message copyWithZone:zone]; copy.timeStamp = [self.timeStamp copyWithZone:zone]; copy.adid = [self.adid copyWithZone:zone]; @@ -42,8 +41,7 @@ -(id)copyWithZone:(NSZone *)zone #pragma mark - NSObject - (NSString *)description { - return [NSString stringWithFormat: @"%@ msg:%@ time:%@ adid:%@ event:%@ json:%@", - self.activityKindString, + return [NSString stringWithFormat: @"Event Success msg:%@ time:%@ adid:%@ event:%@ json:%@", self.message, self.timeStamp, self.adid, diff --git a/Adjust/ADJSessionFailure.h b/Adjust/ADJSessionFailure.h index 8b8de867e..74b64ebe5 100644 --- a/Adjust/ADJSessionFailure.h +++ b/Adjust/ADJSessionFailure.h @@ -11,9 +11,6 @@ @interface ADJSessionFailure : NSObject -// activity type of the tracked package. For now only "event" is tracked. -@property (nonatomic, copy) NSString * activityKindString; - // error message from the server or the sdk. @property (nonatomic, copy) NSString * message; diff --git a/Adjust/ADJSessionFailure.m b/Adjust/ADJSessionFailure.m index 65626cf03..6cdb1dde9 100644 --- a/Adjust/ADJSessionFailure.m +++ b/Adjust/ADJSessionFailure.m @@ -28,7 +28,6 @@ -(id)copyWithZone:(NSZone *)zone ADJSessionFailure* copy = [[[self class] allocWithZone:zone] init]; if (copy) { - copy.activityKindString = [self.activityKindString copyWithZone:zone]; copy.message = [self.message copyWithZone:zone]; copy.timeStamp = [self.timeStamp copyWithZone:zone]; copy.adid = [self.adid copyWithZone:zone]; @@ -42,8 +41,7 @@ -(id)copyWithZone:(NSZone *)zone #pragma mark - NSObject - (NSString *)description { - return [NSString stringWithFormat: @"%@ msg:%@ time:%@ adid:%@ retry:%@ json:%@", - self.activityKindString, + return [NSString stringWithFormat: @"Session Failure msg:%@ time:%@ adid:%@ retry:%@ json:%@", self.message, self.timeStamp, self.adid, diff --git a/Adjust/ADJSessionSuccess.h b/Adjust/ADJSessionSuccess.h index e92a4d5f5..3012ae144 100644 --- a/Adjust/ADJSessionSuccess.h +++ b/Adjust/ADJSessionSuccess.h @@ -11,9 +11,6 @@ @interface ADJSessionSuccess : NSObject -// activity type of the tracked package. For now only "event" is tracked. -@property (nonatomic, copy) NSString * activityKindString; - // message from the server. @property (nonatomic, copy) NSString * message; diff --git a/Adjust/ADJSessionSuccess.m b/Adjust/ADJSessionSuccess.m index cde0f813c..14f97c574 100644 --- a/Adjust/ADJSessionSuccess.m +++ b/Adjust/ADJSessionSuccess.m @@ -28,7 +28,6 @@ -(id)copyWithZone:(NSZone *)zone ADJSessionSuccess* copy = [[[self class] allocWithZone:zone] init]; if (copy) { - copy.activityKindString = [self.activityKindString copyWithZone:zone]; copy.message = [self.message copyWithZone:zone]; copy.timeStamp = [self.timeStamp copyWithZone:zone]; copy.adid = [self.adid copyWithZone:zone]; @@ -41,8 +40,7 @@ -(id)copyWithZone:(NSZone *)zone #pragma mark - NSObject - (NSString *)description { - return [NSString stringWithFormat: @"%@ msg:%@ time:%@ adid:%@ json:%@", - self.activityKindString, + return [NSString stringWithFormat: @"Session Success msg:%@ time:%@ adid:%@ json:%@", self.message, self.timeStamp, self.adid, From 276a7515ee06d26a9c89d0769bfa769b09862d41 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 11 Mar 2016 15:38:17 +0100 Subject: [PATCH 26/33] Launch deeplink from main thread --- Adjust/ADJActivityHandler.m | 77 ++++++++++++++++++++----------------- Adjust/ADJConfig.h | 2 +- 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index 0f9d50bc1..2275fa3ba 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -141,16 +141,11 @@ - (void)launchAttributionResponseTasks:(ADJAttributionResponseData *)attribution }); } -- (void)launchDeepLink:(NSDictionary *)jsonDict{ - if ([ADJUtil isNull:jsonDict]) return; - - NSString *deepLink = [jsonDict objectForKey:@"deeplink"]; +- (void)launchDeepLink:(NSString *)deepLink{ if (deepLink == nil) return; NSURL* deepLinkUrl = [NSURL URLWithString:deepLink]; - [self.logger info:@"Open deep link (%@)", deepLink]; - BOOL success = [[UIApplication sharedApplication] openURL:deepLinkUrl]; if (!success) { @@ -512,37 +507,47 @@ - (void) launchEventResponseTasksInternal:(ADJEventResponseData *)eventResponseD - (void) launchSessionResponseTasksInternal:(ADJSessionResponseData *)sessionResponseData { BOOL toLaunchAttributionDelegate = [self updateAttribution:sessionResponseData.attribution]; - // Send tasks to background to avoid blocking the activity handler queue - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - // session success callback - if (sessionResponseData.success - && [self.adjustDelegate respondsToSelector:@selector(adjustSessionTrackingSucceeded:)]) - { - [self.logger debug:@"Launching success session tracking delegate"]; - [self.adjustDelegate performSelectorOnMainThread:@selector(adjustSessionTrackingSucceeded:) - withObject:[sessionResponseData successResponseData] - waitUntilDone:YES]; // blocking - } - // session failure callback - if (!sessionResponseData.success - && [self.adjustDelegate respondsToSelector:@selector(adjustSessionTrackingFailed:)]) - { - [self.logger debug:@"Launching failed session tracking delegate"]; - [self.adjustDelegate performSelectorOnMainThread:@selector(adjustSessionTrackingFailed:) - withObject:[sessionResponseData failureResponseData] - waitUntilDone:NO]; // blocking - } + // session success callback + if (sessionResponseData.success + && [self.adjustDelegate respondsToSelector:@selector(adjustSessionTrackingSucceeded:)]) + { + [self.logger debug:@"Launching success session tracking delegate"]; + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustSessionTrackingSucceeded:) + withObject:[sessionResponseData successResponseData] + waitUntilDone:NO]; // non-blocking + } + // session failure callback + if (!sessionResponseData.success + && [self.adjustDelegate respondsToSelector:@selector(adjustSessionTrackingFailed:)]) + { + [self.logger debug:@"Launching failed session tracking delegate"]; + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustSessionTrackingFailed:) + withObject:[sessionResponseData failureResponseData] + waitUntilDone:NO]; // non-blocking + } - // try to update and launch the attribution changed delegate blocking - if (toLaunchAttributionDelegate) { - [self.logger debug:@"Launching attribution changed delegate"]; - [self.adjustDelegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) - withObject:sessionResponseData.attribution - waitUntilDone:YES]; // blocking - } - // try to launch the deeplink after attribution changed delegate - [self launchDeepLink:sessionResponseData.jsonResponse]; - }); + // try to update and launch the attribution changed delegate blocking + if (toLaunchAttributionDelegate) { + [self.logger debug:@"Launching attribution changed delegate"]; + [self.adjustDelegate performSelectorOnMainThread:@selector(adjustAttributionChanged:) + withObject:sessionResponseData.attribution + waitUntilDone:NO]; // non-blocking + } + + if ([ADJUtil isNull:sessionResponseData.jsonResponse]) { + return; + } + + NSString *deepLink = [sessionResponseData.jsonResponse objectForKey:@"deeplink"]; + if (deepLink == nil) { + return; + } + + [self.logger info:@"Trying to open deep link (%@)", deepLink]; + + [self performSelectorOnMainThread:@selector(launchDeepLink:) + withObject:deepLink + waitUntilDone:NO]; // non-blocking } - (void) launchAttributionResponseTasksInternal:(ADJAttributionResponseData *)attributionResponseData { diff --git a/Adjust/ADJConfig.h b/Adjust/ADJConfig.h index 89f51cc50..56e80bbce 100644 --- a/Adjust/ADJConfig.h +++ b/Adjust/ADJConfig.h @@ -17,7 +17,7 @@ /** * Optional delegate that will get informed about tracking results */ -@protocol AdjustDelegate +@protocol AdjustDelegate @optional /** From 4d4b0f0061c56958ccf2f23866b1dd01014f6948 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 11 Mar 2016 15:40:56 +0100 Subject: [PATCH 27/33] Change log levels --- Adjust/ADJActivityHandler.m | 6 +++--- AdjustTests/ADJActivityHandlerTests.m | 14 ++++++-------- .../AdjustExample-iOS/AppDelegate.m | 1 + 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index 2275fa3ba..4d0f06a83 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -250,11 +250,11 @@ - (void)setDeviceToken:(NSData *)deviceToken { - (void)setIadDate:(NSDate *)iAdImpressionDate withPurchaseDate:(NSDate *)appPurchaseDate { if (iAdImpressionDate == nil) { - [self.logger verbose:@"iAdImpressionDate not received"]; + [self.logger debug:@"iAdImpressionDate not received"]; return; } - [self.logger verbose:@"iAdImpressionDate received: %@", iAdImpressionDate]; + [self.logger debug:@"iAdImpressionDate received: %@", iAdImpressionDate]; double now = [NSDate.date timeIntervalSince1970]; @@ -280,7 +280,7 @@ - (void)setIadDetails:(NSDictionary *)attributionDetails [self.logger warn:@"Unable to read iAd details"]; if (retriesLeft < 0) { - [self.logger error:@"Limit number of retry for iAd v3 surpassed"]; + [self.logger warn:@"Limit number of retry for iAd v3 surpassed"]; return; } diff --git a/AdjustTests/ADJActivityHandlerTests.m b/AdjustTests/ADJActivityHandlerTests.m index 2e1a36098..a426c734d 100644 --- a/AdjustTests/ADJActivityHandlerTests.m +++ b/AdjustTests/ADJActivityHandlerTests.m @@ -893,7 +893,7 @@ - (void)testIadDates [NSThread sleepForTimeInterval:1]; // check that iAdImpressionDate was not received. - aVerbose(@"iAdImpressionDate not received"); + aDebug(@"iAdImpressionDate not received"); // didn't send click package anTest(@"PackageHandler addPackage"); @@ -902,7 +902,7 @@ - (void)testIadDates [NSThread sleepForTimeInterval:1]; // check that iAdImpressionDate was not received. - aVerbose(@"iAdImpressionDate not received"); + aDebug(@"iAdImpressionDate not received"); // didn't send click package anTest(@"PackageHandler addPackage"); @@ -925,7 +925,7 @@ - (void)testIadDates // iAdImpressionDate received NSString * iAdImpressionDate1Log =[NSString stringWithFormat:@"iAdImpressionDate received: %@", date1]; - aVerbose(iAdImpressionDate1Log); + aDebug(iAdImpressionDate1Log); // first iad package added aTest(@"PackageHandler addPackage"); @@ -935,7 +935,7 @@ - (void)testIadDates // iAdImpressionDate received NSString * iAdImpressionDate2Log =[NSString stringWithFormat:@"iAdImpressionDate received: %@", date2]; - aVerbose(iAdImpressionDate2Log); + aDebug(iAdImpressionDate2Log); // second iad package added aTest(@"PackageHandler addPackage"); @@ -994,7 +994,7 @@ - (void)testIadDetails [NSThread sleepForTimeInterval:1]; aWarn(@"Unable to read iAd details"); - aError(@"Limit number of retry for iAd v3 surpassed"); + aWarn(@"Limit number of retry for iAd v3 surpassed"); [activityHandler setIadDetails:nil error:errorCode0 retriesLeft:0]; [NSThread sleepForTimeInterval:4]; @@ -1152,9 +1152,7 @@ - (void)testLaunchDeepLink [activityHandler launchSessionResponseTasks:sessionResponseData]; [NSThread sleepForTimeInterval:2.0]; - aInfo(@"Open deep link (wrongDeeplink://)"); - - aError(@"Unable to open deep link (wrongDeeplink://)"); + aInfo(@"Trying to open deep link (wrongDeeplink://)"); } - (void)testUpdateAttribution diff --git a/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m b/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m index 0d82e37f0..e1ed91fb3 100644 --- a/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m +++ b/examples/AdjustExample-iOS/AdjustExample-iOS/AppDelegate.m @@ -48,6 +48,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { + NSLog(@"application openURL %@", url); [Adjust appWillOpenUrl:url]; return YES; From 89dd4d280bcc306afd81c2eeb4bae458f5edd956 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 11 Mar 2016 17:15:46 +0100 Subject: [PATCH 28/33] Test send click --- AdjustTests/ADJActivityHandlerTests.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/AdjustTests/ADJActivityHandlerTests.m b/AdjustTests/ADJActivityHandlerTests.m index a426c734d..b7ab05557 100644 --- a/AdjustTests/ADJActivityHandlerTests.m +++ b/AdjustTests/ADJActivityHandlerTests.m @@ -805,6 +805,7 @@ - (void)testAppWillOpenUrl // three click packages: attributions, extraParams and mixed for (int i = 3; i > 0; i--) { aTest(@"PackageHandler addPackage"); + aTest(@"PackageHandler sendFirstPackage"); } // checking the default values of the first session package @@ -929,6 +930,7 @@ - (void)testIadDates // first iad package added aTest(@"PackageHandler addPackage"); + aTest(@"PackageHandler sendFirstPackage"); [activityHandler setIadDate:date2 withPurchaseDate:nil]; [NSThread sleepForTimeInterval:1]; @@ -939,6 +941,7 @@ - (void)testIadDates // second iad package added aTest(@"PackageHandler addPackage"); + aTest(@"PackageHandler sendFirstPackage"); // 1 session + 2 click packages aiEquals(3, (int)[self.packageHandlerMock.packageQueue count]); @@ -1000,7 +1003,7 @@ - (void)testIadDetails [NSThread sleepForTimeInterval:4]; aWarn(@"Unable to read iAd details"); - anError(@"Limit number of retry for iAd v3 surpassed"); + anWarn(@"Limit number of retry for iAd v3 surpassed"); aDebug(@"iAd with 0 tries to read v3"); aWarn(@"Reached limit number of retry for iAd v3. Trying iAd v2"); @@ -1038,6 +1041,9 @@ - (void)testIadDetails [activityHandler setIadDetails:attributionDetails error:nil retriesLeft:1]; [NSThread sleepForTimeInterval:2]; + aTest(@"PackageHandler addPackage"); + aTest(@"PackageHandler sendFirstPackage"); + // check the number of activity packages // 1 session + 1 sdk_click aiEquals(2, (int)[self.packageHandlerMock.packageQueue count]); @@ -2090,6 +2096,9 @@ - (void)checkFinishTasks:(NSObject *)delegateTest [NSThread sleepForTimeInterval:1.0]; + aTest(@"PackageHandler addPackage"); + aTest(@"PackageHandler sendFirstPackage"); + // test sdk_click response data ADJActivityPackage * sdkClickPackage = self.packageHandlerMock.packageQueue[2]; ADJClickResponseData * sdkClickResponseData = [ADJResponseData buildResponseData:sdkClickPackage]; From 3cc546c206ad0fd57d04c2e02712bb9f51e21f49 Mon Sep 17 00:00:00 2001 From: uerceg Date: Mon, 14 Mar 2016 14:03:03 +0100 Subject: [PATCH 29/33] Removing unused imports --- Adjust/ADJSessionFailure.h | 1 - Adjust/ADJSessionSuccess.h | 1 - 2 files changed, 2 deletions(-) diff --git a/Adjust/ADJSessionFailure.h b/Adjust/ADJSessionFailure.h index 74b64ebe5..a39233dc9 100644 --- a/Adjust/ADJSessionFailure.h +++ b/Adjust/ADJSessionFailure.h @@ -7,7 +7,6 @@ // #import -#import "ADJActivityKind.h" @interface ADJSessionFailure : NSObject diff --git a/Adjust/ADJSessionSuccess.h b/Adjust/ADJSessionSuccess.h index 3012ae144..16b43367a 100644 --- a/Adjust/ADJSessionSuccess.h +++ b/Adjust/ADJSessionSuccess.h @@ -7,7 +7,6 @@ // #import -#import "ADJActivityKind.h" @interface ADJSessionSuccess : NSObject From aaaf408a89fef75483a98c67055f2783bf9c6738 Mon Sep 17 00:00:00 2001 From: uerceg Date: Mon, 14 Mar 2016 14:03:39 +0100 Subject: [PATCH 30/33] Oranizing imports for dynamic framework --- Adjust.xcodeproj/project.pbxproj | 462 +++++++++--------- .../xcshareddata/xcschemes/AdjustSdk.xcscheme | 2 +- AdjustSdk/AdjustSdk.h | 5 +- 3 files changed, 241 insertions(+), 228 deletions(-) diff --git a/Adjust.xcodeproj/project.pbxproj b/Adjust.xcodeproj/project.pbxproj index af9ac4232..0cca4a1cd 100644 --- a/Adjust.xcodeproj/project.pbxproj +++ b/Adjust.xcodeproj/project.pbxproj @@ -103,54 +103,63 @@ 96ED003E1A38A98C00209110 /* ADJDelegateTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 96ED003D1A38A98C00209110 /* ADJDelegateTest.m */; }; 96FCC53A1C186426007BBFE1 /* ADJResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC5361C186426007BBFE1 /* ADJResponseData.h */; }; 96FCC53B1C186426007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC5371C186426007BBFE1 /* ADJResponseData.m */; }; - 96FCC5521C1865D3007BBFE1 /* ADJResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FCC54E1C1865D3007BBFE1 /* ADJResponseData.h */; }; - 96FCC5531C1865D3007BBFE1 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FCC54F1C1865D3007BBFE1 /* ADJResponseData.m */; }; 96FDD75E1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FDD75D1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.m */; }; 9D363AC31BDA50FA00B47FE9 /* ADJLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 96E5E37318BBB48A008E7B30 /* ADJLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DA11A691C96D2A200980777 /* ADJActivityHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A331C96D2A200980777 /* ADJActivityHandler.h */; }; + 9DA11A6A1C96D2A200980777 /* ADJActivityHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A341C96D2A200980777 /* ADJActivityHandler.m */; }; + 9DA11A6B1C96D2A200980777 /* ADJActivityKind.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A351C96D2A200980777 /* ADJActivityKind.h */; }; + 9DA11A6C1C96D2A200980777 /* ADJActivityKind.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A361C96D2A200980777 /* ADJActivityKind.m */; }; + 9DA11A6D1C96D2A200980777 /* ADJActivityPackage.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A371C96D2A200980777 /* ADJActivityPackage.h */; }; + 9DA11A6E1C96D2A200980777 /* ADJActivityPackage.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A381C96D2A200980777 /* ADJActivityPackage.m */; }; + 9DA11A6F1C96D2A200980777 /* ADJActivityState.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A391C96D2A200980777 /* ADJActivityState.h */; }; + 9DA11A701C96D2A200980777 /* ADJActivityState.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A3A1C96D2A200980777 /* ADJActivityState.m */; }; + 9DA11A711C96D2A200980777 /* NSData+ADJAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A3C1C96D2A200980777 /* NSData+ADJAdditions.h */; }; + 9DA11A721C96D2A200980777 /* NSData+ADJAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A3D1C96D2A200980777 /* NSData+ADJAdditions.m */; }; + 9DA11A731C96D2A200980777 /* NSString+ADJAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A3E1C96D2A200980777 /* NSString+ADJAdditions.h */; }; + 9DA11A741C96D2A200980777 /* NSString+ADJAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A3F1C96D2A200980777 /* NSString+ADJAdditions.m */; }; + 9DA11A751C96D2A200980777 /* UIDevice+ADJAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A401C96D2A200980777 /* UIDevice+ADJAdditions.h */; }; + 9DA11A761C96D2A200980777 /* UIDevice+ADJAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A411C96D2A200980777 /* UIDevice+ADJAdditions.m */; }; + 9DA11A771C96D2A200980777 /* ADJAdjustFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A421C96D2A200980777 /* ADJAdjustFactory.h */; }; + 9DA11A781C96D2A200980777 /* ADJAdjustFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A431C96D2A200980777 /* ADJAdjustFactory.m */; }; + 9DA11A791C96D2A200980777 /* ADJAttribution.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A441C96D2A200980777 /* ADJAttribution.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DA11A7A1C96D2A200980777 /* ADJAttribution.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A451C96D2A200980777 /* ADJAttribution.m */; }; + 9DA11A7B1C96D2A200980777 /* ADJAttributionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A461C96D2A200980777 /* ADJAttributionHandler.h */; }; + 9DA11A7C1C96D2A200980777 /* ADJAttributionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A471C96D2A200980777 /* ADJAttributionHandler.m */; }; + 9DA11A7D1C96D2A200980777 /* ADJConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A481C96D2A200980777 /* ADJConfig.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DA11A7E1C96D2A200980777 /* ADJConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A491C96D2A200980777 /* ADJConfig.m */; }; + 9DA11A7F1C96D2A200980777 /* ADJDeviceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A4A1C96D2A200980777 /* ADJDeviceInfo.h */; }; + 9DA11A801C96D2A200980777 /* ADJDeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A4B1C96D2A200980777 /* ADJDeviceInfo.m */; }; + 9DA11A811C96D2A200980777 /* ADJEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A4C1C96D2A200980777 /* ADJEvent.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DA11A821C96D2A200980777 /* ADJEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A4D1C96D2A200980777 /* ADJEvent.m */; }; + 9DA11A831C96D2A200980777 /* ADJEventFailure.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A4E1C96D2A200980777 /* ADJEventFailure.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DA11A841C96D2A200980777 /* ADJEventFailure.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A4F1C96D2A200980777 /* ADJEventFailure.m */; }; + 9DA11A851C96D2A200980777 /* ADJEventSuccess.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A501C96D2A200980777 /* ADJEventSuccess.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DA11A861C96D2A200980777 /* ADJEventSuccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A511C96D2A200980777 /* ADJEventSuccess.m */; }; + 9DA11A871C96D2A200980777 /* ADJLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A521C96D2A200980777 /* ADJLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DA11A881C96D2A200980777 /* ADJLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A531C96D2A200980777 /* ADJLogger.m */; }; + 9DA11A891C96D2A200980777 /* ADJPackageBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A541C96D2A200980777 /* ADJPackageBuilder.h */; }; + 9DA11A8A1C96D2A200980777 /* ADJPackageBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A551C96D2A200980777 /* ADJPackageBuilder.m */; }; + 9DA11A8B1C96D2A200980777 /* ADJPackageHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A561C96D2A200980777 /* ADJPackageHandler.h */; }; + 9DA11A8C1C96D2A300980777 /* ADJPackageHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A571C96D2A200980777 /* ADJPackageHandler.m */; }; + 9DA11A8D1C96D2A300980777 /* ADJRequestHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A581C96D2A200980777 /* ADJRequestHandler.h */; }; + 9DA11A8E1C96D2A300980777 /* ADJRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A591C96D2A200980777 /* ADJRequestHandler.m */; }; + 9DA11A8F1C96D2A300980777 /* ADJResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A5A1C96D2A200980777 /* ADJResponseData.h */; }; + 9DA11A901C96D2A300980777 /* ADJResponseData.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A5B1C96D2A200980777 /* ADJResponseData.m */; }; + 9DA11A911C96D2A300980777 /* ADJSessionFailure.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A5C1C96D2A200980777 /* ADJSessionFailure.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DA11A921C96D2A300980777 /* ADJSessionFailure.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A5D1C96D2A200980777 /* ADJSessionFailure.m */; }; + 9DA11A931C96D2A300980777 /* ADJSessionSuccess.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A5E1C96D2A200980777 /* ADJSessionSuccess.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DA11A941C96D2A300980777 /* ADJSessionSuccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A5F1C96D2A200980777 /* ADJSessionSuccess.m */; }; + 9DA11A951C96D2A300980777 /* ADJTimerCycle.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A601C96D2A200980777 /* ADJTimerCycle.h */; }; + 9DA11A961C96D2A300980777 /* ADJTimerCycle.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A611C96D2A200980777 /* ADJTimerCycle.m */; }; + 9DA11A971C96D2A300980777 /* ADJTimerOnce.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A621C96D2A200980777 /* ADJTimerOnce.h */; }; + 9DA11A981C96D2A300980777 /* ADJTimerOnce.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A631C96D2A200980777 /* ADJTimerOnce.m */; }; + 9DA11A991C96D2A300980777 /* Adjust.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A641C96D2A200980777 /* Adjust.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9DA11A9A1C96D2A300980777 /* Adjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A651C96D2A200980777 /* Adjust.m */; }; + 9DA11A9B1C96D2A300980777 /* ADJUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DA11A661C96D2A200980777 /* ADJUtil.h */; }; + 9DA11A9C1C96D2A300980777 /* ADJUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DA11A671C96D2A200980777 /* ADJUtil.m */; }; + 9DA11A9D1C96D2A300980777 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9DA11A681C96D2A200980777 /* Info.plist */; }; 9DE7C8FD1AE688DA001556E5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DE7C8FC1AE688DA001556E5 /* UIKit.framework */; }; 9DFA37B71C0F21D600782607 /* AdjustSdk.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37B51C0F21D600782607 /* AdjustSdk.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 9DFA37DF1C0F220200782607 /* ADJActivityHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37BA1C0F220200782607 /* ADJActivityHandler.h */; }; - 9DFA37E01C0F220200782607 /* ADJActivityHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37BB1C0F220200782607 /* ADJActivityHandler.m */; }; - 9DFA37E11C0F220200782607 /* ADJActivityKind.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37BC1C0F220200782607 /* ADJActivityKind.h */; }; - 9DFA37E21C0F220200782607 /* ADJActivityKind.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37BD1C0F220200782607 /* ADJActivityKind.m */; }; - 9DFA37E31C0F220200782607 /* ADJActivityPackage.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37BE1C0F220200782607 /* ADJActivityPackage.h */; }; - 9DFA37E41C0F220200782607 /* ADJActivityPackage.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37BF1C0F220200782607 /* ADJActivityPackage.m */; }; - 9DFA37E51C0F220200782607 /* ADJActivityState.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37C01C0F220200782607 /* ADJActivityState.h */; }; - 9DFA37E61C0F220200782607 /* ADJActivityState.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37C11C0F220200782607 /* ADJActivityState.m */; }; - 9DFA37E71C0F220200782607 /* ADJAdjustFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37C21C0F220200782607 /* ADJAdjustFactory.h */; }; - 9DFA37E81C0F220200782607 /* ADJAdjustFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37C31C0F220200782607 /* ADJAdjustFactory.m */; }; - 9DFA37E91C0F220200782607 /* ADJAttribution.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37C41C0F220200782607 /* ADJAttribution.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 9DFA37EA1C0F220200782607 /* ADJAttribution.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37C51C0F220200782607 /* ADJAttribution.m */; }; - 9DFA37EB1C0F220200782607 /* ADJAttributionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37C61C0F220200782607 /* ADJAttributionHandler.h */; }; - 9DFA37EC1C0F220200782607 /* ADJAttributionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37C71C0F220200782607 /* ADJAttributionHandler.m */; }; - 9DFA37ED1C0F220200782607 /* ADJConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37C81C0F220200782607 /* ADJConfig.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 9DFA37EE1C0F220200782607 /* ADJConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37C91C0F220200782607 /* ADJConfig.m */; }; - 9DFA37EF1C0F220200782607 /* ADJDeviceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37CA1C0F220200782607 /* ADJDeviceInfo.h */; }; - 9DFA37F01C0F220200782607 /* ADJDeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37CB1C0F220200782607 /* ADJDeviceInfo.m */; }; - 9DFA37F11C0F220200782607 /* ADJEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37CC1C0F220200782607 /* ADJEvent.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 9DFA37F21C0F220200782607 /* ADJEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37CD1C0F220200782607 /* ADJEvent.m */; }; - 9DFA37F31C0F220200782607 /* ADJLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37CE1C0F220200782607 /* ADJLogger.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 9DFA37F41C0F220200782607 /* ADJLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37CF1C0F220200782607 /* ADJLogger.m */; }; - 9DFA37F51C0F220200782607 /* ADJPackageBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37D01C0F220200782607 /* ADJPackageBuilder.h */; }; - 9DFA37F61C0F220200782607 /* ADJPackageBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37D11C0F220200782607 /* ADJPackageBuilder.m */; }; - 9DFA37F71C0F220200782607 /* ADJPackageHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37D21C0F220200782607 /* ADJPackageHandler.h */; }; - 9DFA37F81C0F220200782607 /* ADJPackageHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37D31C0F220200782607 /* ADJPackageHandler.m */; }; - 9DFA37F91C0F220200782607 /* ADJRequestHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37D41C0F220200782607 /* ADJRequestHandler.h */; }; - 9DFA37FA1C0F220200782607 /* ADJRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37D51C0F220200782607 /* ADJRequestHandler.m */; }; - 9DFA37FB1C0F220200782607 /* ADJTimerCycle.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37D61C0F220200782607 /* ADJTimerCycle.h */; }; - 9DFA37FC1C0F220200782607 /* ADJTimerCycle.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37D71C0F220200782607 /* ADJTimerCycle.m */; }; - 9DFA37FD1C0F220200782607 /* ADJTimerOnce.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37D81C0F220200782607 /* ADJTimerOnce.h */; }; - 9DFA37FE1C0F220200782607 /* ADJTimerOnce.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37D91C0F220200782607 /* ADJTimerOnce.m */; }; - 9DFA37FF1C0F220200782607 /* Adjust.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37DA1C0F220200782607 /* Adjust.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 9DFA38001C0F220200782607 /* Adjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37DB1C0F220200782607 /* Adjust.m */; }; - 9DFA38011C0F220200782607 /* ADJUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA37DC1C0F220200782607 /* ADJUtil.h */; }; - 9DFA38021C0F220200782607 /* ADJUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA37DD1C0F220200782607 /* ADJUtil.m */; }; - 9DFA380A1C0F220D00782607 /* NSData+ADJAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA38041C0F220D00782607 /* NSData+ADJAdditions.h */; }; - 9DFA380B1C0F220D00782607 /* NSData+ADJAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA38051C0F220D00782607 /* NSData+ADJAdditions.m */; }; - 9DFA380C1C0F220D00782607 /* NSString+ADJAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA38061C0F220D00782607 /* NSString+ADJAdditions.h */; }; - 9DFA380D1C0F220D00782607 /* NSString+ADJAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA38071C0F220D00782607 /* NSString+ADJAdditions.m */; }; - 9DFA380E1C0F220D00782607 /* UIDevice+ADJAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DFA38081C0F220D00782607 /* UIDevice+ADJAdditions.h */; }; - 9DFA380F1C0F220D00782607 /* UIDevice+ADJAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DFA38091C0F220D00782607 /* UIDevice+ADJAdditions.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -292,59 +301,65 @@ 96ED003D1A38A98C00209110 /* ADJDelegateTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJDelegateTest.m; sourceTree = ""; }; 96FCC5361C186426007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseData.h; sourceTree = ""; }; 96FCC5371C186426007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseData.m; sourceTree = ""; }; - 96FCC54E1C1865D3007BBFE1 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJResponseData.h; path = Adjust/ADJResponseData.h; sourceTree = SOURCE_ROOT; }; - 96FCC54F1C1865D3007BBFE1 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJResponseData.m; path = Adjust/ADJResponseData.m; sourceTree = SOURCE_ROOT; }; - 96FCC5501C1865D3007BBFE1 /* ADJResponseDataTasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJResponseDataTasks.h; path = Adjust/ADJResponseDataTasks.h; sourceTree = SOURCE_ROOT; }; - 96FCC5511C1865D3007BBFE1 /* ADJResponseDataTasks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJResponseDataTasks.m; path = Adjust/ADJResponseDataTasks.m; sourceTree = SOURCE_ROOT; }; 96FDD75C1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSURLSession+NSURLDataWithRequestMocking.h"; sourceTree = ""; }; 96FDD75D1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURLSession+NSURLDataWithRequestMocking.m"; sourceTree = ""; }; + 9DA11A331C96D2A200980777 /* ADJActivityHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJActivityHandler.h; sourceTree = ""; }; + 9DA11A341C96D2A200980777 /* ADJActivityHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJActivityHandler.m; sourceTree = ""; }; + 9DA11A351C96D2A200980777 /* ADJActivityKind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJActivityKind.h; sourceTree = ""; }; + 9DA11A361C96D2A200980777 /* ADJActivityKind.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJActivityKind.m; sourceTree = ""; }; + 9DA11A371C96D2A200980777 /* ADJActivityPackage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJActivityPackage.h; sourceTree = ""; }; + 9DA11A381C96D2A200980777 /* ADJActivityPackage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJActivityPackage.m; sourceTree = ""; }; + 9DA11A391C96D2A200980777 /* ADJActivityState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJActivityState.h; sourceTree = ""; }; + 9DA11A3A1C96D2A200980777 /* ADJActivityState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJActivityState.m; sourceTree = ""; }; + 9DA11A3C1C96D2A200980777 /* NSData+ADJAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+ADJAdditions.h"; sourceTree = ""; }; + 9DA11A3D1C96D2A200980777 /* NSData+ADJAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+ADJAdditions.m"; sourceTree = ""; }; + 9DA11A3E1C96D2A200980777 /* NSString+ADJAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+ADJAdditions.h"; sourceTree = ""; }; + 9DA11A3F1C96D2A200980777 /* NSString+ADJAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+ADJAdditions.m"; sourceTree = ""; }; + 9DA11A401C96D2A200980777 /* UIDevice+ADJAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIDevice+ADJAdditions.h"; sourceTree = ""; }; + 9DA11A411C96D2A200980777 /* UIDevice+ADJAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIDevice+ADJAdditions.m"; sourceTree = ""; }; + 9DA11A421C96D2A200980777 /* ADJAdjustFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJAdjustFactory.h; sourceTree = ""; }; + 9DA11A431C96D2A200980777 /* ADJAdjustFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJAdjustFactory.m; sourceTree = ""; }; + 9DA11A441C96D2A200980777 /* ADJAttribution.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJAttribution.h; sourceTree = ""; }; + 9DA11A451C96D2A200980777 /* ADJAttribution.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJAttribution.m; sourceTree = ""; }; + 9DA11A461C96D2A200980777 /* ADJAttributionHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJAttributionHandler.h; sourceTree = ""; }; + 9DA11A471C96D2A200980777 /* ADJAttributionHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJAttributionHandler.m; sourceTree = ""; }; + 9DA11A481C96D2A200980777 /* ADJConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJConfig.h; sourceTree = ""; }; + 9DA11A491C96D2A200980777 /* ADJConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJConfig.m; sourceTree = ""; }; + 9DA11A4A1C96D2A200980777 /* ADJDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJDeviceInfo.h; sourceTree = ""; }; + 9DA11A4B1C96D2A200980777 /* ADJDeviceInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJDeviceInfo.m; sourceTree = ""; }; + 9DA11A4C1C96D2A200980777 /* ADJEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJEvent.h; sourceTree = ""; }; + 9DA11A4D1C96D2A200980777 /* ADJEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJEvent.m; sourceTree = ""; }; + 9DA11A4E1C96D2A200980777 /* ADJEventFailure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJEventFailure.h; sourceTree = ""; }; + 9DA11A4F1C96D2A200980777 /* ADJEventFailure.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJEventFailure.m; sourceTree = ""; }; + 9DA11A501C96D2A200980777 /* ADJEventSuccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJEventSuccess.h; sourceTree = ""; }; + 9DA11A511C96D2A200980777 /* ADJEventSuccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJEventSuccess.m; sourceTree = ""; }; + 9DA11A521C96D2A200980777 /* ADJLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJLogger.h; sourceTree = ""; }; + 9DA11A531C96D2A200980777 /* ADJLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJLogger.m; sourceTree = ""; }; + 9DA11A541C96D2A200980777 /* ADJPackageBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJPackageBuilder.h; sourceTree = ""; }; + 9DA11A551C96D2A200980777 /* ADJPackageBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJPackageBuilder.m; sourceTree = ""; }; + 9DA11A561C96D2A200980777 /* ADJPackageHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJPackageHandler.h; sourceTree = ""; }; + 9DA11A571C96D2A200980777 /* ADJPackageHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJPackageHandler.m; sourceTree = ""; }; + 9DA11A581C96D2A200980777 /* ADJRequestHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJRequestHandler.h; sourceTree = ""; }; + 9DA11A591C96D2A200980777 /* ADJRequestHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJRequestHandler.m; sourceTree = ""; }; + 9DA11A5A1C96D2A200980777 /* ADJResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJResponseData.h; sourceTree = ""; }; + 9DA11A5B1C96D2A200980777 /* ADJResponseData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJResponseData.m; sourceTree = ""; }; + 9DA11A5C1C96D2A200980777 /* ADJSessionFailure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSessionFailure.h; sourceTree = ""; }; + 9DA11A5D1C96D2A200980777 /* ADJSessionFailure.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSessionFailure.m; sourceTree = ""; }; + 9DA11A5E1C96D2A200980777 /* ADJSessionSuccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJSessionSuccess.h; sourceTree = ""; }; + 9DA11A5F1C96D2A200980777 /* ADJSessionSuccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJSessionSuccess.m; sourceTree = ""; }; + 9DA11A601C96D2A200980777 /* ADJTimerCycle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJTimerCycle.h; sourceTree = ""; }; + 9DA11A611C96D2A200980777 /* ADJTimerCycle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJTimerCycle.m; sourceTree = ""; }; + 9DA11A621C96D2A200980777 /* ADJTimerOnce.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJTimerOnce.h; sourceTree = ""; }; + 9DA11A631C96D2A200980777 /* ADJTimerOnce.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJTimerOnce.m; sourceTree = ""; }; + 9DA11A641C96D2A200980777 /* Adjust.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Adjust.h; sourceTree = ""; }; + 9DA11A651C96D2A200980777 /* Adjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Adjust.m; sourceTree = ""; }; + 9DA11A661C96D2A200980777 /* ADJUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJUtil.h; sourceTree = ""; }; + 9DA11A671C96D2A200980777 /* ADJUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJUtil.m; sourceTree = ""; }; + 9DA11A681C96D2A200980777 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9DE7C8FC1AE688DA001556E5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 9DFA37AD1C0F219400782607 /* AdjustSdk.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AdjustSdk.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9DFA37B51C0F21D600782607 /* AdjustSdk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdjustSdk.h; sourceTree = ""; }; 9DFA37B61C0F21D600782607 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 9DFA37BA1C0F220200782607 /* ADJActivityHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJActivityHandler.h; path = Adjust/ADJActivityHandler.h; sourceTree = SOURCE_ROOT; }; - 9DFA37BB1C0F220200782607 /* ADJActivityHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJActivityHandler.m; path = Adjust/ADJActivityHandler.m; sourceTree = SOURCE_ROOT; }; - 9DFA37BC1C0F220200782607 /* ADJActivityKind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJActivityKind.h; path = Adjust/ADJActivityKind.h; sourceTree = SOURCE_ROOT; }; - 9DFA37BD1C0F220200782607 /* ADJActivityKind.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJActivityKind.m; path = Adjust/ADJActivityKind.m; sourceTree = SOURCE_ROOT; }; - 9DFA37BE1C0F220200782607 /* ADJActivityPackage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJActivityPackage.h; path = Adjust/ADJActivityPackage.h; sourceTree = SOURCE_ROOT; }; - 9DFA37BF1C0F220200782607 /* ADJActivityPackage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJActivityPackage.m; path = Adjust/ADJActivityPackage.m; sourceTree = SOURCE_ROOT; }; - 9DFA37C01C0F220200782607 /* ADJActivityState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJActivityState.h; path = Adjust/ADJActivityState.h; sourceTree = SOURCE_ROOT; }; - 9DFA37C11C0F220200782607 /* ADJActivityState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJActivityState.m; path = Adjust/ADJActivityState.m; sourceTree = SOURCE_ROOT; }; - 9DFA37C21C0F220200782607 /* ADJAdjustFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJAdjustFactory.h; path = Adjust/ADJAdjustFactory.h; sourceTree = SOURCE_ROOT; }; - 9DFA37C31C0F220200782607 /* ADJAdjustFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJAdjustFactory.m; path = Adjust/ADJAdjustFactory.m; sourceTree = SOURCE_ROOT; }; - 9DFA37C41C0F220200782607 /* ADJAttribution.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJAttribution.h; path = Adjust/ADJAttribution.h; sourceTree = SOURCE_ROOT; }; - 9DFA37C51C0F220200782607 /* ADJAttribution.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJAttribution.m; path = Adjust/ADJAttribution.m; sourceTree = SOURCE_ROOT; }; - 9DFA37C61C0F220200782607 /* ADJAttributionHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJAttributionHandler.h; path = Adjust/ADJAttributionHandler.h; sourceTree = SOURCE_ROOT; }; - 9DFA37C71C0F220200782607 /* ADJAttributionHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJAttributionHandler.m; path = Adjust/ADJAttributionHandler.m; sourceTree = SOURCE_ROOT; }; - 9DFA37C81C0F220200782607 /* ADJConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJConfig.h; path = Adjust/ADJConfig.h; sourceTree = SOURCE_ROOT; }; - 9DFA37C91C0F220200782607 /* ADJConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJConfig.m; path = Adjust/ADJConfig.m; sourceTree = SOURCE_ROOT; }; - 9DFA37CA1C0F220200782607 /* ADJDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJDeviceInfo.h; path = Adjust/ADJDeviceInfo.h; sourceTree = SOURCE_ROOT; }; - 9DFA37CB1C0F220200782607 /* ADJDeviceInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJDeviceInfo.m; path = Adjust/ADJDeviceInfo.m; sourceTree = SOURCE_ROOT; }; - 9DFA37CC1C0F220200782607 /* ADJEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJEvent.h; path = Adjust/ADJEvent.h; sourceTree = SOURCE_ROOT; }; - 9DFA37CD1C0F220200782607 /* ADJEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJEvent.m; path = Adjust/ADJEvent.m; sourceTree = SOURCE_ROOT; }; - 9DFA37CE1C0F220200782607 /* ADJLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJLogger.h; path = Adjust/ADJLogger.h; sourceTree = SOURCE_ROOT; }; - 9DFA37CF1C0F220200782607 /* ADJLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJLogger.m; path = Adjust/ADJLogger.m; sourceTree = SOURCE_ROOT; }; - 9DFA37D01C0F220200782607 /* ADJPackageBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJPackageBuilder.h; path = Adjust/ADJPackageBuilder.h; sourceTree = SOURCE_ROOT; }; - 9DFA37D11C0F220200782607 /* ADJPackageBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJPackageBuilder.m; path = Adjust/ADJPackageBuilder.m; sourceTree = SOURCE_ROOT; }; - 9DFA37D21C0F220200782607 /* ADJPackageHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJPackageHandler.h; path = Adjust/ADJPackageHandler.h; sourceTree = SOURCE_ROOT; }; - 9DFA37D31C0F220200782607 /* ADJPackageHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJPackageHandler.m; path = Adjust/ADJPackageHandler.m; sourceTree = SOURCE_ROOT; }; - 9DFA37D41C0F220200782607 /* ADJRequestHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJRequestHandler.h; path = Adjust/ADJRequestHandler.h; sourceTree = SOURCE_ROOT; }; - 9DFA37D51C0F220200782607 /* ADJRequestHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJRequestHandler.m; path = Adjust/ADJRequestHandler.m; sourceTree = SOURCE_ROOT; }; - 9DFA37D61C0F220200782607 /* ADJTimerCycle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJTimerCycle.h; path = Adjust/ADJTimerCycle.h; sourceTree = SOURCE_ROOT; }; - 9DFA37D71C0F220200782607 /* ADJTimerCycle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJTimerCycle.m; path = Adjust/ADJTimerCycle.m; sourceTree = SOURCE_ROOT; }; - 9DFA37D81C0F220200782607 /* ADJTimerOnce.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJTimerOnce.h; path = Adjust/ADJTimerOnce.h; sourceTree = SOURCE_ROOT; }; - 9DFA37D91C0F220200782607 /* ADJTimerOnce.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJTimerOnce.m; path = Adjust/ADJTimerOnce.m; sourceTree = SOURCE_ROOT; }; - 9DFA37DA1C0F220200782607 /* Adjust.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Adjust.h; path = Adjust/Adjust.h; sourceTree = SOURCE_ROOT; }; - 9DFA37DB1C0F220200782607 /* Adjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Adjust.m; path = Adjust/Adjust.m; sourceTree = SOURCE_ROOT; }; - 9DFA37DC1C0F220200782607 /* ADJUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADJUtil.h; path = Adjust/ADJUtil.h; sourceTree = SOURCE_ROOT; }; - 9DFA37DD1C0F220200782607 /* ADJUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADJUtil.m; path = Adjust/ADJUtil.m; sourceTree = SOURCE_ROOT; }; - 9DFA37DE1C0F220200782607 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Adjust/Info.plist; sourceTree = SOURCE_ROOT; }; - 9DFA38041C0F220D00782607 /* NSData+ADJAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+ADJAdditions.h"; path = "Adjust/ADJAdditions/NSData+ADJAdditions.h"; sourceTree = SOURCE_ROOT; }; - 9DFA38051C0F220D00782607 /* NSData+ADJAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSData+ADJAdditions.m"; path = "Adjust/ADJAdditions/NSData+ADJAdditions.m"; sourceTree = SOURCE_ROOT; }; - 9DFA38061C0F220D00782607 /* NSString+ADJAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+ADJAdditions.h"; path = "Adjust/ADJAdditions/NSString+ADJAdditions.h"; sourceTree = SOURCE_ROOT; }; - 9DFA38071C0F220D00782607 /* NSString+ADJAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+ADJAdditions.m"; path = "Adjust/ADJAdditions/NSString+ADJAdditions.m"; sourceTree = SOURCE_ROOT; }; - 9DFA38081C0F220D00782607 /* UIDevice+ADJAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIDevice+ADJAdditions.h"; path = "Adjust/ADJAdditions/UIDevice+ADJAdditions.h"; sourceTree = SOURCE_ROOT; }; - 9DFA38091C0F220D00782607 /* UIDevice+ADJAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIDevice+ADJAdditions.m"; path = "Adjust/ADJAdditions/UIDevice+ADJAdditions.m"; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -543,68 +558,82 @@ path = AdjustTests; sourceTree = ""; }; - 9DFA37AE1C0F219400782607 /* AdjustSdk */ = { + 9DA11A321C96D2A200980777 /* Adjust */ = { isa = PBXGroup; children = ( - 9DFA37B51C0F21D600782607 /* AdjustSdk.h */, - 9DFA37B61C0F21D600782607 /* Info.plist */, - 9DFA37B91C0F21F000782607 /* Adjust */, + 9DA11A3B1C96D2A200980777 /* ADJAdditions */, + 9DA11A331C96D2A200980777 /* ADJActivityHandler.h */, + 9DA11A341C96D2A200980777 /* ADJActivityHandler.m */, + 9DA11A351C96D2A200980777 /* ADJActivityKind.h */, + 9DA11A361C96D2A200980777 /* ADJActivityKind.m */, + 9DA11A371C96D2A200980777 /* ADJActivityPackage.h */, + 9DA11A381C96D2A200980777 /* ADJActivityPackage.m */, + 9DA11A391C96D2A200980777 /* ADJActivityState.h */, + 9DA11A3A1C96D2A200980777 /* ADJActivityState.m */, + 9DA11A421C96D2A200980777 /* ADJAdjustFactory.h */, + 9DA11A431C96D2A200980777 /* ADJAdjustFactory.m */, + 9DA11A441C96D2A200980777 /* ADJAttribution.h */, + 9DA11A451C96D2A200980777 /* ADJAttribution.m */, + 9DA11A461C96D2A200980777 /* ADJAttributionHandler.h */, + 9DA11A471C96D2A200980777 /* ADJAttributionHandler.m */, + 9DA11A481C96D2A200980777 /* ADJConfig.h */, + 9DA11A491C96D2A200980777 /* ADJConfig.m */, + 9DA11A4A1C96D2A200980777 /* ADJDeviceInfo.h */, + 9DA11A4B1C96D2A200980777 /* ADJDeviceInfo.m */, + 9DA11A4C1C96D2A200980777 /* ADJEvent.h */, + 9DA11A4D1C96D2A200980777 /* ADJEvent.m */, + 9DA11A4E1C96D2A200980777 /* ADJEventFailure.h */, + 9DA11A4F1C96D2A200980777 /* ADJEventFailure.m */, + 9DA11A501C96D2A200980777 /* ADJEventSuccess.h */, + 9DA11A511C96D2A200980777 /* ADJEventSuccess.m */, + 9DA11A521C96D2A200980777 /* ADJLogger.h */, + 9DA11A531C96D2A200980777 /* ADJLogger.m */, + 9DA11A541C96D2A200980777 /* ADJPackageBuilder.h */, + 9DA11A551C96D2A200980777 /* ADJPackageBuilder.m */, + 9DA11A561C96D2A200980777 /* ADJPackageHandler.h */, + 9DA11A571C96D2A200980777 /* ADJPackageHandler.m */, + 9DA11A581C96D2A200980777 /* ADJRequestHandler.h */, + 9DA11A591C96D2A200980777 /* ADJRequestHandler.m */, + 9DA11A5A1C96D2A200980777 /* ADJResponseData.h */, + 9DA11A5B1C96D2A200980777 /* ADJResponseData.m */, + 9DA11A5C1C96D2A200980777 /* ADJSessionFailure.h */, + 9DA11A5D1C96D2A200980777 /* ADJSessionFailure.m */, + 9DA11A5E1C96D2A200980777 /* ADJSessionSuccess.h */, + 9DA11A5F1C96D2A200980777 /* ADJSessionSuccess.m */, + 9DA11A601C96D2A200980777 /* ADJTimerCycle.h */, + 9DA11A611C96D2A200980777 /* ADJTimerCycle.m */, + 9DA11A621C96D2A200980777 /* ADJTimerOnce.h */, + 9DA11A631C96D2A200980777 /* ADJTimerOnce.m */, + 9DA11A641C96D2A200980777 /* Adjust.h */, + 9DA11A651C96D2A200980777 /* Adjust.m */, + 9DA11A661C96D2A200980777 /* ADJUtil.h */, + 9DA11A671C96D2A200980777 /* ADJUtil.m */, + 9DA11A681C96D2A200980777 /* Info.plist */, ); - path = AdjustSdk; + path = Adjust; + sourceTree = SOURCE_ROOT; + }; + 9DA11A3B1C96D2A200980777 /* ADJAdditions */ = { + isa = PBXGroup; + children = ( + 9DA11A3C1C96D2A200980777 /* NSData+ADJAdditions.h */, + 9DA11A3D1C96D2A200980777 /* NSData+ADJAdditions.m */, + 9DA11A3E1C96D2A200980777 /* NSString+ADJAdditions.h */, + 9DA11A3F1C96D2A200980777 /* NSString+ADJAdditions.m */, + 9DA11A401C96D2A200980777 /* UIDevice+ADJAdditions.h */, + 9DA11A411C96D2A200980777 /* UIDevice+ADJAdditions.m */, + ); + path = ADJAdditions; sourceTree = ""; }; - 9DFA37B91C0F21F000782607 /* Adjust */ = { + 9DFA37AE1C0F219400782607 /* AdjustSdk */ = { isa = PBXGroup; children = ( - 9DFA38041C0F220D00782607 /* NSData+ADJAdditions.h */, - 9DFA38051C0F220D00782607 /* NSData+ADJAdditions.m */, - 9DFA38061C0F220D00782607 /* NSString+ADJAdditions.h */, - 9DFA38071C0F220D00782607 /* NSString+ADJAdditions.m */, - 9DFA38081C0F220D00782607 /* UIDevice+ADJAdditions.h */, - 9DFA38091C0F220D00782607 /* UIDevice+ADJAdditions.m */, - 9DFA37BA1C0F220200782607 /* ADJActivityHandler.h */, - 9DFA37BB1C0F220200782607 /* ADJActivityHandler.m */, - 9DFA37BC1C0F220200782607 /* ADJActivityKind.h */, - 9DFA37BD1C0F220200782607 /* ADJActivityKind.m */, - 9DFA37BE1C0F220200782607 /* ADJActivityPackage.h */, - 9DFA37BF1C0F220200782607 /* ADJActivityPackage.m */, - 9DFA37C01C0F220200782607 /* ADJActivityState.h */, - 9DFA37C11C0F220200782607 /* ADJActivityState.m */, - 9DFA37C21C0F220200782607 /* ADJAdjustFactory.h */, - 9DFA37C31C0F220200782607 /* ADJAdjustFactory.m */, - 9DFA37C41C0F220200782607 /* ADJAttribution.h */, - 9DFA37C51C0F220200782607 /* ADJAttribution.m */, - 9DFA37C61C0F220200782607 /* ADJAttributionHandler.h */, - 9DFA37C71C0F220200782607 /* ADJAttributionHandler.m */, - 9DFA37C81C0F220200782607 /* ADJConfig.h */, - 9DFA37C91C0F220200782607 /* ADJConfig.m */, - 9DFA37CA1C0F220200782607 /* ADJDeviceInfo.h */, - 9DFA37CB1C0F220200782607 /* ADJDeviceInfo.m */, - 9DFA37CC1C0F220200782607 /* ADJEvent.h */, - 9DFA37CD1C0F220200782607 /* ADJEvent.m */, - 9DFA37CE1C0F220200782607 /* ADJLogger.h */, - 9DFA37CF1C0F220200782607 /* ADJLogger.m */, - 9DFA37D01C0F220200782607 /* ADJPackageBuilder.h */, - 9DFA37D11C0F220200782607 /* ADJPackageBuilder.m */, - 9DFA37D21C0F220200782607 /* ADJPackageHandler.h */, - 9DFA37D31C0F220200782607 /* ADJPackageHandler.m */, - 9DFA37D41C0F220200782607 /* ADJRequestHandler.h */, - 9DFA37D51C0F220200782607 /* ADJRequestHandler.m */, - 9DFA37D61C0F220200782607 /* ADJTimerCycle.h */, - 9DFA37D71C0F220200782607 /* ADJTimerCycle.m */, - 9DFA37D81C0F220200782607 /* ADJTimerOnce.h */, - 9DFA37D91C0F220200782607 /* ADJTimerOnce.m */, - 9DFA37DA1C0F220200782607 /* Adjust.h */, - 9DFA37DB1C0F220200782607 /* Adjust.m */, - 9DFA37DC1C0F220200782607 /* ADJUtil.h */, - 9DFA37DD1C0F220200782607 /* ADJUtil.m */, - 9DFA37DE1C0F220200782607 /* Info.plist */, - 96FCC54E1C1865D3007BBFE1 /* ADJResponseData.h */, - 96FCC54F1C1865D3007BBFE1 /* ADJResponseData.m */, - 96FCC5501C1865D3007BBFE1 /* ADJResponseDataTasks.h */, - 96FCC5511C1865D3007BBFE1 /* ADJResponseDataTasks.m */, + 9DFA37B51C0F21D600782607 /* AdjustSdk.h */, + 9DFA37B61C0F21D600782607 /* Info.plist */, + 9DA11A321C96D2A200980777 /* Adjust */, ); - name = Adjust; + path = AdjustSdk; sourceTree = ""; }; /* End PBXGroup section */ @@ -622,8 +651,8 @@ 96BCFBD11AC99246005A65C5 /* ADJAttribution.h in Headers */, 9601CAE81C74BAAE00670879 /* ADJEventFailure.h in Headers */, 9601CAE41C74B70600670879 /* ADJEventSuccess.h in Headers */, - 968173831C3C2D07002AE1DE /* ADJSessionSuccess.h in Headers */, 968173871C3C2D36002AE1DE /* ADJSessionFailure.h in Headers */, + 968173831C3C2D07002AE1DE /* ADJSessionSuccess.h in Headers */, 96BCFBD91AC9934E005A65C5 /* ADJAdjustFactory.h in Headers */, 96BCFBD81AC9934B005A65C5 /* ADJActivityState.h in Headers */, 96BCFBD61AC99345005A65C5 /* ADJActivityKind.h in Headers */, @@ -648,28 +677,32 @@ buildActionMask = 2147483647; files = ( 9DFA37B71C0F21D600782607 /* AdjustSdk.h in Headers */, - 9DFA37FF1C0F220200782607 /* Adjust.h in Headers */, - 9DFA37F11C0F220200782607 /* ADJEvent.h in Headers */, - 9DFA37ED1C0F220200782607 /* ADJConfig.h in Headers */, - 9DFA37F31C0F220200782607 /* ADJLogger.h in Headers */, - 9DFA37E91C0F220200782607 /* ADJAttribution.h in Headers */, - 9DFA38011C0F220200782607 /* ADJUtil.h in Headers */, - 9DFA37EF1C0F220200782607 /* ADJDeviceInfo.h in Headers */, - 9DFA380C1C0F220D00782607 /* NSString+ADJAdditions.h in Headers */, - 9DFA380A1C0F220D00782607 /* NSData+ADJAdditions.h in Headers */, - 9DFA37FD1C0F220200782607 /* ADJTimerOnce.h in Headers */, - 9DFA37FB1C0F220200782607 /* ADJTimerCycle.h in Headers */, - 9DFA37F51C0F220200782607 /* ADJPackageBuilder.h in Headers */, - 9DFA37E51C0F220200782607 /* ADJActivityState.h in Headers */, - 9DFA380E1C0F220D00782607 /* UIDevice+ADJAdditions.h in Headers */, - 9DFA37F91C0F220200782607 /* ADJRequestHandler.h in Headers */, - 9DFA37DF1C0F220200782607 /* ADJActivityHandler.h in Headers */, - 9DFA37F71C0F220200782607 /* ADJPackageHandler.h in Headers */, - 9DFA37E11C0F220200782607 /* ADJActivityKind.h in Headers */, - 9DFA37E31C0F220200782607 /* ADJActivityPackage.h in Headers */, - 9DFA37E71C0F220200782607 /* ADJAdjustFactory.h in Headers */, - 9DFA37EB1C0F220200782607 /* ADJAttributionHandler.h in Headers */, - 96FCC5521C1865D3007BBFE1 /* ADJResponseData.h in Headers */, + 9DA11A991C96D2A300980777 /* Adjust.h in Headers */, + 9DA11A811C96D2A200980777 /* ADJEvent.h in Headers */, + 9DA11A7D1C96D2A200980777 /* ADJConfig.h in Headers */, + 9DA11A871C96D2A200980777 /* ADJLogger.h in Headers */, + 9DA11A791C96D2A200980777 /* ADJAttribution.h in Headers */, + 9DA11A831C96D2A200980777 /* ADJEventFailure.h in Headers */, + 9DA11A851C96D2A200980777 /* ADJEventSuccess.h in Headers */, + 9DA11A911C96D2A300980777 /* ADJSessionFailure.h in Headers */, + 9DA11A931C96D2A300980777 /* ADJSessionSuccess.h in Headers */, + 9DA11A7F1C96D2A200980777 /* ADJDeviceInfo.h in Headers */, + 9DA11A6F1C96D2A200980777 /* ADJActivityState.h in Headers */, + 9DA11A771C96D2A200980777 /* ADJAdjustFactory.h in Headers */, + 9DA11A9B1C96D2A300980777 /* ADJUtil.h in Headers */, + 9DA11A891C96D2A200980777 /* ADJPackageBuilder.h in Headers */, + 9DA11A8D1C96D2A300980777 /* ADJRequestHandler.h in Headers */, + 9DA11A711C96D2A200980777 /* NSData+ADJAdditions.h in Headers */, + 9DA11A691C96D2A200980777 /* ADJActivityHandler.h in Headers */, + 9DA11A731C96D2A200980777 /* NSString+ADJAdditions.h in Headers */, + 9DA11A751C96D2A200980777 /* UIDevice+ADJAdditions.h in Headers */, + 9DA11A6B1C96D2A200980777 /* ADJActivityKind.h in Headers */, + 9DA11A8F1C96D2A300980777 /* ADJResponseData.h in Headers */, + 9DA11A971C96D2A300980777 /* ADJTimerOnce.h in Headers */, + 9DA11A6D1C96D2A200980777 /* ADJActivityPackage.h in Headers */, + 9DA11A8B1C96D2A200980777 /* ADJPackageHandler.h in Headers */, + 9DA11A951C96D2A300980777 /* ADJTimerCycle.h in Headers */, + 9DA11A7B1C96D2A200980777 /* ADJAttributionHandler.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -738,7 +771,7 @@ 9679920518BBAE2800394606 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0710; + LastUpgradeCheck = 0720; ORGANIZATIONNAME = "adjust GmbH"; TargetAttributes = { 96BCFBE71AC99FBD005A65C5 = { @@ -749,7 +782,7 @@ }; }; }; - buildConfigurationList = 9679920818BBAE2800394606 /* Build configuration list for PBXProject "adjust" */; + buildConfigurationList = 9679920818BBAE2800394606 /* Build configuration list for PBXProject "Adjust" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; @@ -809,6 +842,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9DA11A9D1C96D2A300980777 /* Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -827,7 +861,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -e\n\n# If we're already inside this script then die\nif [ -n \"$RW_MULTIPLATFORM_BUILD_IN_PROGRESS\" ]; then\nexit 0\nfi\nexport RW_MULTIPLATFORM_BUILD_IN_PROGRESS=1\n\nRW_FRAMEWORK_NAME=${PROJECT_NAME}\nRW_FRAMEWORK_LOCATION=\"${BUILT_PRODUCTS_DIR}/${RW_FRAMEWORK_NAME}Sdk.framework\"\n\n# Copy the framework to the project directory\nditto \"${RW_FRAMEWORK_LOCATION}\" \"${SRCROOT}/Frameworks/Dynamic/${RW_FRAMEWORK_NAME}Sdk.framework\""; + shellScript = "set -e\n\n# If we're already inside this script then die\nif [ -n \"$RW_MULTIPLATFORM_BUILD_IN_PROGRESS\" ]; then\nexit 0\nfi\nexport RW_MULTIPLATFORM_BUILD_IN_PROGRESS=1\n\nRW_FRAMEWORK_NAME=${PROJECT_NAME}\nRW_FRAMEWORK_LOCATION=\"${BUILT_PRODUCTS_DIR}/${RW_FRAMEWORK_NAME}Sdk.framework\"\n\n# Copy the framework to the project directory\n# ditto \"${RW_FRAMEWORK_LOCATION}\" \"${SRCROOT}/Frameworks/Dynamic/${RW_FRAMEWORK_NAME}Sdk.framework\""; }; 9DE7C9011AE68F68001556E5 /* Build Framework */ = { isa = PBXShellScriptBuildPhase; @@ -925,28 +959,32 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 9DFA37E81C0F220200782607 /* ADJAdjustFactory.m in Sources */, - 9DFA37E21C0F220200782607 /* ADJActivityKind.m in Sources */, - 9DFA37FA1C0F220200782607 /* ADJRequestHandler.m in Sources */, - 9DFA380F1C0F220D00782607 /* UIDevice+ADJAdditions.m in Sources */, - 9DFA37E41C0F220200782607 /* ADJActivityPackage.m in Sources */, - 9DFA37EE1C0F220200782607 /* ADJConfig.m in Sources */, - 96FCC5531C1865D3007BBFE1 /* ADJResponseData.m in Sources */, - 9DFA38001C0F220200782607 /* Adjust.m in Sources */, - 9DFA37F21C0F220200782607 /* ADJEvent.m in Sources */, - 9DFA38021C0F220200782607 /* ADJUtil.m in Sources */, - 9DFA37EC1C0F220200782607 /* ADJAttributionHandler.m in Sources */, - 9DFA37F41C0F220200782607 /* ADJLogger.m in Sources */, - 9DFA37E61C0F220200782607 /* ADJActivityState.m in Sources */, - 9DFA380B1C0F220D00782607 /* NSData+ADJAdditions.m in Sources */, - 9DFA37FC1C0F220200782607 /* ADJTimerCycle.m in Sources */, - 9DFA37F61C0F220200782607 /* ADJPackageBuilder.m in Sources */, - 9DFA37F01C0F220200782607 /* ADJDeviceInfo.m in Sources */, - 9DFA380D1C0F220D00782607 /* NSString+ADJAdditions.m in Sources */, - 9DFA37F81C0F220200782607 /* ADJPackageHandler.m in Sources */, - 9DFA37E01C0F220200782607 /* ADJActivityHandler.m in Sources */, - 9DFA37FE1C0F220200782607 /* ADJTimerOnce.m in Sources */, - 9DFA37EA1C0F220200782607 /* ADJAttribution.m in Sources */, + 9DA11A7E1C96D2A200980777 /* ADJConfig.m in Sources */, + 9DA11A9C1C96D2A300980777 /* ADJUtil.m in Sources */, + 9DA11A7C1C96D2A200980777 /* ADJAttributionHandler.m in Sources */, + 9DA11A961C96D2A300980777 /* ADJTimerCycle.m in Sources */, + 9DA11A921C96D2A300980777 /* ADJSessionFailure.m in Sources */, + 9DA11A6C1C96D2A200980777 /* ADJActivityKind.m in Sources */, + 9DA11A8E1C96D2A300980777 /* ADJRequestHandler.m in Sources */, + 9DA11A6E1C96D2A200980777 /* ADJActivityPackage.m in Sources */, + 9DA11A8A1C96D2A200980777 /* ADJPackageBuilder.m in Sources */, + 9DA11A7A1C96D2A200980777 /* ADJAttribution.m in Sources */, + 9DA11A881C96D2A200980777 /* ADJLogger.m in Sources */, + 9DA11A861C96D2A200980777 /* ADJEventSuccess.m in Sources */, + 9DA11A701C96D2A200980777 /* ADJActivityState.m in Sources */, + 9DA11A761C96D2A200980777 /* UIDevice+ADJAdditions.m in Sources */, + 9DA11A741C96D2A200980777 /* NSString+ADJAdditions.m in Sources */, + 9DA11A8C1C96D2A300980777 /* ADJPackageHandler.m in Sources */, + 9DA11A941C96D2A300980777 /* ADJSessionSuccess.m in Sources */, + 9DA11A821C96D2A200980777 /* ADJEvent.m in Sources */, + 9DA11A841C96D2A200980777 /* ADJEventFailure.m in Sources */, + 9DA11A721C96D2A200980777 /* NSData+ADJAdditions.m in Sources */, + 9DA11A9A1C96D2A300980777 /* Adjust.m in Sources */, + 9DA11A901C96D2A300980777 /* ADJResponseData.m in Sources */, + 9DA11A801C96D2A200980777 /* ADJDeviceInfo.m in Sources */, + 9DA11A6A1C96D2A200980777 /* ADJActivityHandler.m in Sources */, + 9DA11A981C96D2A300980777 /* ADJTimerOnce.m in Sources */, + 9DA11A781C96D2A200980777 /* ADJAdjustFactory.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1052,10 +1090,6 @@ 9679923118BBAE2800394606 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - "$(ARCHS_STANDARD)", - armv7s, - ); CODE_SIGN_IDENTITY = "iPhone Developer"; DEAD_CODE_STRIPPING = NO; DSTROOT = /tmp/Adjust.dst; @@ -1077,10 +1111,6 @@ 9679923218BBAE2800394606 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - "$(ARCHS_STANDARD)", - armv7s, - ); CODE_SIGN_IDENTITY = "iPhone Developer"; DEAD_CODE_STRIPPING = NO; DSTROOT = /tmp/Adjust.dst; @@ -1102,10 +1132,6 @@ 9679923418BBAE2800394606 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - "$(ARCHS_STANDARD)", - armv7s, - ); FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(DEVELOPER_FRAMEWORKS_DIR)", @@ -1127,10 +1153,6 @@ 9679923518BBAE2800394606 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - "$(ARCHS_STANDARD)", - armv7s, - ); FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(DEVELOPER_FRAMEWORKS_DIR)", @@ -1148,10 +1170,7 @@ 96BCFBE91AC99FBD005A65C5 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - "$(ARCHS_STANDARD)", - armv7s, - ); + ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -1159,10 +1178,7 @@ 96BCFBEA1AC99FBD005A65C5 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - "$(ARCHS_STANDARD)", - armv7s, - ); + ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -1170,10 +1186,6 @@ 9DFA37B31C0F219400782607 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - "$(ARCHS_STANDARD)", - armv7s, - ); CLANG_WARN_UNREACHABLE_CODE = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; @@ -1190,6 +1202,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = com.adjust.AdjustSdk; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -1202,10 +1215,6 @@ 9DFA37B41C0F219400782607 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - "$(ARCHS_STANDARD)", - armv7s, - ); CLANG_WARN_UNREACHABLE_CODE = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; @@ -1222,6 +1231,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; + ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.adjust.AdjustSdk; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -1234,7 +1244,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 9679920818BBAE2800394606 /* Build configuration list for PBXProject "adjust" */ = { + 9679920818BBAE2800394606 /* Build configuration list for PBXProject "Adjust" */ = { isa = XCConfigurationList; buildConfigurations = ( 9679922E18BBAE2800394606 /* Debug */, diff --git a/Adjust.xcodeproj/xcshareddata/xcschemes/AdjustSdk.xcscheme b/Adjust.xcodeproj/xcshareddata/xcschemes/AdjustSdk.xcscheme index 9993b13e7..62b0091a0 100644 --- a/Adjust.xcodeproj/xcshareddata/xcschemes/AdjustSdk.xcscheme +++ b/Adjust.xcodeproj/xcshareddata/xcschemes/AdjustSdk.xcscheme @@ -1,6 +1,6 @@ #import #import -#import +#import +#import +#import +#import From 5e7b07ea30b5d1ffe3458906d282ef82227ec2b2 Mon Sep 17 00:00:00 2001 From: uerceg Date: Mon, 14 Mar 2016 14:03:55 +0100 Subject: [PATCH 31/33] Build script improvements --- Scripts/adjust_build.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Scripts/adjust_build.sh b/Scripts/adjust_build.sh index 4d0994fbc..0d7b30cba 100755 --- a/Scripts/adjust_build.sh +++ b/Scripts/adjust_build.sh @@ -6,10 +6,13 @@ set -e # Go to root folder cd .. -# Create needed folders if they don't exist +# Clean the folders +rm -rf Frameworks/Static +rm -rf Frameworks/Dynamic + +# Create needed folders mkdir -p Frameworks/Static mkdir -p Frameworks/Dynamic -mkdir -p Frameworks/Carthage # Build static AdjustSdk.framework xcodebuild -target AdjustStatic -configuration Release @@ -21,4 +24,4 @@ xcodebuild -target AdjustSdk -configuration Release carthage build --no-skip-current # Copy build Carthage framework to Frameworks folder -cp -R Carthage/Build/iOS/* Frameworks/Carthage/ +cp -R Carthage/Build/iOS/* Frameworks/Dynamic/ From 4d5ccf9b663da9f112ebd844f9d3a3cc90fdbfdb Mon Sep 17 00:00:00 2001 From: uerceg Date: Mon, 14 Mar 2016 14:07:20 +0100 Subject: [PATCH 32/33] Changing version number to 4.6.0 --- Adjust.podspec | 4 ++-- Adjust/ADJUtil.m | 2 +- AdjustTests/ADJPackageFields.m | 2 +- README.md | 4 ++-- VERSION | 2 +- doc/migrate.md | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Adjust.podspec b/Adjust.podspec index 42eaeebf3..6f3b34f5c 100644 --- a/Adjust.podspec +++ b/Adjust.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "Adjust" - s.version = "4.5.4" + s.version = "4.6.0" 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" => "welle@adjust.com" } - s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.5.4" } + s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.6.0" } s.ios.deployment_target = '6.0' s.tvos.deployment_target = '9.0' s.framework = 'SystemConfiguration' diff --git a/Adjust/ADJUtil.m b/Adjust/ADJUtil.m index dc2bfa878..888309e7d 100644 --- a/Adjust/ADJUtil.m +++ b/Adjust/ADJUtil.m @@ -18,7 +18,7 @@ static NSDateFormatter *dateFormat; -static NSString * const kClientSdk = @"ios4.5.4"; +static NSString * const kClientSdk = @"ios4.6.0"; static NSString * const kDefaultScheme = @"AdjustUniversalScheme"; static NSString * const kUniversalLinkPattern = @"https://[^.]*\\.ulink\\.adjust\\.com/ulink/?(.*)"; static NSString * const kBaseUrl = @"https://app.adjust.com"; diff --git a/AdjustTests/ADJPackageFields.m b/AdjustTests/ADJPackageFields.m index df70808a1..95aeca90d 100644 --- a/AdjustTests/ADJPackageFields.m +++ b/AdjustTests/ADJPackageFields.m @@ -16,7 +16,7 @@ - (id) init { // default values self.appToken = @"123456789012"; - self.clientSdk = @"ios4.5.4"; + self.clientSdk = @"ios4.6.0"; self.suffix = @""; self.environment = @"sandbox"; diff --git a/README.md b/README.md index 53576ff5d..566d29555 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ If you're using [CocoaPods][cocoapods] for `iOs` or `tvOS`, you can add the foll `Podfile` and continue with [step 4](#step4): ```ruby -pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.5.4' +pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.6.0' ``` or: ```ruby -pod 'Adjust', '~> 4.5.4' +pod 'Adjust', '~> 4.6.0' ``` If you're using [Carthage][carthage], you can add following line to your `Cartfile` diff --git a/VERSION b/VERSION index 0ed2bfe96..6016e8add 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.5.4 +4.6.0 diff --git a/doc/migrate.md b/doc/migrate.md index a8e1b9caf..ae76e0849 100644 --- a/doc/migrate.md +++ b/doc/migrate.md @@ -1,4 +1,4 @@ -## Migrate your adjust SDK for iOS to v4.5.4 from v3.4.0 +## Migrate your adjust SDK for iOS to v4.6.0 from v3.4.0 ### Initial setup From 8ed59809aa428b433d311fe2050dfed54b8a162b Mon Sep 17 00:00:00 2001 From: Esa McGavin Date: Tue, 15 Mar 2016 13:56:55 +0100 Subject: [PATCH 33/33] edits README --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 566d29555..d7a529b18 100644 --- a/README.md +++ b/README.md @@ -444,7 +444,9 @@ Here is a quick summary of its properties: ### 10. Implement callbacks for tracked events and sessions You can register a delegate callback to be notified of successful and failed tracked events and/or sessions. + The same optional protocol `AdjustDelegate` used for the attribution changed callback [here](#9-implement-the-attribution-callback) is used. + Follow the same steps and implement the following delegate callback function for successful tracked events: ```objc @@ -466,17 +468,18 @@ adjustSessionTrackingSucceeded:(ADJSessionSuccess *)sessionSuccessResponseData { ``` And for failed tracked sessions: + ```objc adjustSessionTrackingFailed:(ADJSessionFailure *)sessionFailureResponseData { } ``` -The delegate functions will be called after the SDK tries to send a package to the server. Within the delegate callback you have access to a response data object specific for the delegate callback. Here is a quick summary of the session response data properties: +The delegate functions will be called after the SDK tries to send a package to the server. Within the delegate callback you have access to a response data object specifically for the delegate callback. Here is a quick summary of the session response data properties: - `NSString message` the message from the server or the error logged by the SDK. - `NSString timeStamp` timestamp from the server. - `NSString adid` a unique device identifier provided by adjust. -- `NSDictionary jsonResponse` the json object with the reponse from the server. +- `NSDictionary jsonResponse` the JSON object with the response from the server. Both event response data objects contain: @@ -484,7 +487,7 @@ Both event response data objects contain: And both event and session failed objects also contain: -- `BOOL willRetry` indicates if the package will be retried to be send later +- `BOOL willRetry` indicates there will be an attempt to resend the package at a later time. ### 11. Disable tracking