Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
nonelse committed Jan 26, 2016
1 parent 56dfbe2 commit cd41787
Show file tree
Hide file tree
Showing 22 changed files with 730 additions and 119 deletions.
18 changes: 18 additions & 0 deletions Adjust.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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, ); }; };
Expand Down Expand Up @@ -235,6 +238,10 @@
96CD2BDD1A13BFC600A40AFB /* NSString+ADJAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+ADJAdditions.m"; sourceTree = "<group>"; };
96CD2BDE1A13BFC600A40AFB /* UIDevice+ADJAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIDevice+ADJAdditions.h"; sourceTree = "<group>"; };
96CD2BDF1A13BFC600A40AFB /* UIDevice+ADJAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIDevice+ADJAdditions.m"; sourceTree = "<group>"; };
96DD62731C52810500DDF56A /* ADJTrackingSucceededDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJTrackingSucceededDelegate.h; sourceTree = "<group>"; };
96DD62741C52810500DDF56A /* ADJTrackingSucceededDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJTrackingSucceededDelegate.m; sourceTree = "<group>"; };
96DD62781C52818000DDF56A /* ADJTrackingFailedDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJTrackingFailedDelegate.h; sourceTree = "<group>"; };
96DD62791C52818000DDF56A /* ADJTrackingFailedDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADJTrackingFailedDelegate.m; sourceTree = "<group>"; };
96E5E34C18BBB48A008E7B30 /* Adjust.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Adjust.h; sourceTree = "<group>"; };
96E5E34D18BBB48A008E7B30 /* Adjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Adjust.m; sourceTree = "<group>"; };
96E5E36218BBB48A008E7B30 /* ADJActivityHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADJActivityHandler.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 = "<group>"; };
96FDD75D1C566C38009C402E /* NSURLSession+NSURLDataWithRequestMocking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURLSession+NSURLDataWithRequestMocking.m"; sourceTree = "<group>"; };
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 = "<group>"; };
Expand Down Expand Up @@ -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 = "<group>";
Expand Down Expand Up @@ -861,9 +876,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 */,
Expand Down
3 changes: 1 addition & 2 deletions Adjust/ADJActivityHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
- (void)trackEvent:(ADJEvent *)event;

- (void)finishedTracking:(ADJResponseData *)responseData;
- (void)launchResponseTasks:(ADJResponseData *)responseData;
- (void)launchAttributionTasks:(ADJResponseData *)responseData;
- (void)setEnabled:(BOOL)enabled;
- (BOOL)isEnabled;
Expand All @@ -30,7 +29,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
Expand Down
56 changes: 27 additions & 29 deletions Adjust/ADJActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,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), ^{
Expand All @@ -317,27 +313,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];
Expand Down Expand Up @@ -518,12 +493,12 @@ - (void) launchResponseTasksInternal:(ADJResponseData *)responseData {
}

- (void) launchAttributionTasksInternal:(ADJResponseData *)responseData {
SEL updateAttributionSEL = [self updateAttribution:responseData.attribution];
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];
}
Expand All @@ -532,6 +507,27 @@ - (void) launchAttributionTasksInternal:(ADJResponseData *)responseData {
});
}

- (BOOL)updateAttribution:(ADJAttribution *)attribution {
if (attribution == nil) {
return NO;
}
if ([attribution isEqual:self.attribution]) {
return NO;
}
self.attribution = attribution;
[self writeAttribution];

if (self.adjustDelegate == nil) {
return NO;
}

if (![self.adjustDelegate respondsToSelector:@selector(adjustAttributionChanged:)]) {
return NO;
}

return YES;
}

- (void) launchFinishedDelegate:(ADJResponseData *)responseData {
// no event package
if (responseData.activityKind != ADJActivityKindEvent) {
Expand All @@ -547,6 +543,7 @@ - (void) launchFinishedDelegate:(ADJResponseData *)responseData {
if (responseData.success
&& [self.adjustDelegate respondsToSelector:@selector(adjustTrackingSucceeded:)])
{
[self.logger debug:@"Launching success tracking delegate"];
[self.adjustDelegate performSelectorOnMainThread:@selector(adjustTrackingSucceeded:)
withObject:[responseData successResponseData]
waitUntilDone:YES];
Expand All @@ -556,6 +553,7 @@ - (void) launchFinishedDelegate:(ADJResponseData *)responseData {
if (!responseData.success
&& [self.adjustDelegate respondsToSelector:@selector(adjustTrackingFailed:)])
{
[self.logger debug:@"Launching failed tracking delegate"];
[self.adjustDelegate performSelectorOnMainThread:@selector(adjustTrackingFailed:)
withObject:[responseData failureResponseData]
waitUntilDone:YES];
Expand Down
4 changes: 3 additions & 1 deletion Adjust/ADJAdditions/UIDevice+ADJAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 mot available -> iad v2
if (!isIadV3Avaliable) {
[logger warn:@"iAd v3 not available. Trying iAd v2"];
[self adjSetIadWithDates:activityHandler ADClientSharedClientInstance:ADClientSharedClientInstance];
}
#pragma clang diagnostic pop
Expand Down
2 changes: 0 additions & 2 deletions AdjustTests/ADJActivityHandlerMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@

@property (nonatomic, strong) ADJAttribution *attributionUpdated;

- (void) setUpdatedAttribution:(BOOL)updated;

@end
16 changes: 5 additions & 11 deletions AdjustTests/ADJActivityHandlerMock.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
@interface ADJActivityHandlerMock()

@property (nonatomic, strong) ADJLoggerMock *loggerMock;
@property (nonatomic, assign) BOOL updated;

@end

Expand All @@ -26,7 +25,6 @@ - (id)initWithConfig:(ADJConfig *)adjustConfig {
if (self == nil) return nil;

self.loggerMock = (ADJLoggerMock *) [ADJAdjustFactory logger];
self.updated = NO;

[self.loggerMock test:[prefix stringByAppendingFormat:@"initWithConfig"]];

Expand All @@ -45,8 +43,8 @@ - (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]];
}

- (void)setEnabled:(BOOL)enabled {
Expand Down Expand Up @@ -82,7 +80,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 {
Expand All @@ -95,16 +93,12 @@ - (void)setIadDetails:(NSDictionary *)attributionDetails
[self.loggerMock test:[prefix stringByAppendingFormat:@"setIadDetails, %@ error, %@", attributionDetails, error]];
}

- (void) launchAttributionDelegate {
[self.loggerMock test:[prefix stringByAppendingFormat:@"launchAttributionDelegate"]];
- (void) launchAttributionTasks:(ADJResponseData *)responseData {
[self.loggerMock test:[prefix stringByAppendingFormat:@"launchAttributionTasks, %@", responseData]];
}

- (void) setOfflineMode:(BOOL)enabled {
[self.loggerMock test:[prefix stringByAppendingFormat:@"setOfflineMode"]];
}

- (void) setUpdatedAttribution:(BOOL)updated {
self.updated = updated;
}

@end
Loading

0 comments on commit cd41787

Please sign in to comment.