diff --git a/Adjust.podspec b/Adjust.podspec index 72e7a3825..ea5be490c 100644 --- a/Adjust.podspec +++ b/Adjust.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "Adjust" - s.version = "4.0.3" + s.version = "4.0.4" 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.0.3" } + s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.0.4" } s.platform = :ios, '4.3' s.framework = 'SystemConfiguration' s.weak_framework = 'AdSupport', 'iAd' diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index 935f70e0c..9730d8ed8 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -193,6 +193,9 @@ - (BOOL)updateAttribution:(ADJAttribution *)attribution { } - (void)launchAttributionDelegate{ + if (self.delegate == nil) { + return; + } if (![self.delegate respondsToSelector:@selector(adjustAttributionChanged:)]) { [self.logger warn:@"Delegate can't be launched because it does not implement AdjustDelegate"]; return; @@ -356,8 +359,6 @@ - (void)eventInternal:(ADJEvent *)event ADJPackageBuilder *eventBuilder = [[ADJPackageBuilder alloc] initWithDeviceInfo:self.deviceInfo activityState:self.activityState config:self.adjustConfig]; - [self setIadDate:[NSDate date] withPurchaseDate:[NSDate date]]; - ADJActivityPackage *eventPackage = [eventBuilder buildEventPackage:event]; [self.packageHandler addPackage:eventPackage]; @@ -480,6 +481,7 @@ - (void)writeAttribution { } - (void)readActivityState { + [NSKeyedUnarchiver setClass:[ADJActivityState class] forClassName:@"AIActivityState"]; self.activityState = [ADJUtil readObject:kActivityStateFilename objectName:@"Activity state" class:[ADJActivityState class]]; diff --git a/Adjust/ADJActivityState.m b/Adjust/ADJActivityState.m index f5e8ff287..8dd749dab 100644 --- a/Adjust/ADJActivityState.m +++ b/Adjust/ADJActivityState.m @@ -80,25 +80,33 @@ - (id)initWithCoder:(NSCoder *)decoder { self.timeSpent = [decoder decodeDoubleForKey:@"timeSpent"]; self.createdAt = [decoder decodeDoubleForKey:@"createdAt"]; self.lastActivity = [decoder decodeDoubleForKey:@"lastActivity"]; - self.uuid = [decoder decodeObjectForKey:@"uuid"]; - self.transactionIds = [decoder decodeObjectForKey:@"transactionIds"]; - self.enabled = [decoder decodeBoolForKey:@"enabled"]; - self.askingAttribution = [decoder decodeBoolForKey:@"askingAttribution"]; // default values for migrating devices + if ([decoder containsValueForKey:@"uuid"]) { + self.uuid = [decoder decodeObjectForKey:@"uuid"]; + } + if (self.uuid == nil) { self.uuid = [UIDevice.currentDevice adjCreateUuid]; } + if ([decoder containsValueForKey:@"transactionIds"]) { + self.transactionIds = [decoder decodeObjectForKey:@"transactionIds"]; + } + if (self.transactionIds == nil) { self.transactionIds = [NSMutableArray arrayWithCapacity:kTransactionIdCount]; } - if (![decoder containsValueForKey:@"enabled"]) { + if ([decoder containsValueForKey:@"enabled"]) { + self.enabled = [decoder decodeBoolForKey:@"enabled"]; + } else { self.enabled = YES; } - if (![decoder containsValueForKey:@"askingAttribution"]) { + if ([decoder containsValueForKey:@"askingAttribution"]) { + self.askingAttribution = [decoder decodeBoolForKey:@"askingAttribution"]; + } else { self.askingAttribution = NO; } diff --git a/Adjust/ADJPackageHandler.m b/Adjust/ADJPackageHandler.m index 306702d1b..5f3aaa9b5 100644 --- a/Adjust/ADJPackageHandler.m +++ b/Adjust/ADJPackageHandler.m @@ -140,6 +140,7 @@ - (void)sendNextInternal { #pragma mark - private - (void)readPackageQueue { @try { + [NSKeyedUnarchiver setClass:[ADJActivityPackage class] forClassName:@"AIActivityPackage"]; NSString *filename = self.packageQueueFilename; id object = [NSKeyedUnarchiver unarchiveObjectWithFile:filename]; if ([object isKindOfClass:[NSArray class]]) { diff --git a/Adjust/ADJUtil.m b/Adjust/ADJUtil.m index 518018d83..4a7fb6eb6 100644 --- a/Adjust/ADJUtil.m +++ b/Adjust/ADJUtil.m @@ -16,7 +16,7 @@ #include static NSString * const kBaseUrl = @"https://app.adjust.com"; -static NSString * const kClientSdk = @"ios4.0.3"; +static NSString * const kClientSdk = @"ios4.0.4"; static NSString * const kDateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'Z"; static NSDateFormatter *dateFormat; @@ -24,6 +24,11 @@ #pragma mark - @implementation ADJUtil ++ (void) initialize { + dateFormat = [[NSDateFormatter alloc] init]; + [dateFormat setDateFormat:kDateFormat]; +} + + (NSString *)baseUrl { return kBaseUrl; } @@ -80,11 +85,6 @@ + (NSString *)formatSeconds1970:(double) value { + (NSString *)formatDate:(NSDate *) value { - if (dateFormat == nil) { - dateFormat = [[NSDateFormatter alloc] init]; - [dateFormat setDateFormat:kDateFormat]; - } - return [dateFormat stringFromDate:value]; } diff --git a/AdjustTests/ADJActivityHandlerTests.m b/AdjustTests/ADJActivityHandlerTests.m index 3244aa107..060fd3639 100644 --- a/AdjustTests/ADJActivityHandlerTests.m +++ b/AdjustTests/ADJActivityHandlerTests.m @@ -123,7 +123,7 @@ - (void)testFirstRun ADJActivityPackage *activityPackage = (ADJActivityPackage *) self.packageHandlerMock.packageQueue[0]; // check the Sdk version is being tested - XCTAssertEqual(@"ios4.0.3", activityPackage.clientSdk, @"%@", activityPackage.extendedString); + XCTAssertEqual(@"ios4.0.4", activityPackage.clientSdk, @"%@", activityPackage.extendedString); // check the server url XCTAssertEqual(@"https://app.adjust.com", ADJUtil.baseUrl); @@ -177,9 +177,6 @@ - (void)testFirstRun // has delegate XCTAssertEqual(1, [(NSString *)parameters[@"needs_attribution_data"] intValue], @"%@", activityPackage.extendedString); - // network type - XCTAssertNotNil((NSString *)parameters[@"network_type"], @"%@", activityPackage.extendedString); - // os name XCTAssertEqual(@"ios", parameters[@"os_name"], @"%@", activityPackage.extendedString); diff --git a/README.md b/README.md index 533d286f2..d578ab77d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you're using [CocoaPods][cocoapods], you can add the following line to your `Podfile` and continue with [step 3](#step3): ```ruby -pod 'Adjust', :git => 'git://github.com/adjust/ios_sdk.git', :tag => 'v4.0.3' +pod 'Adjust', :git => 'git://github.com/adjust/ios_sdk.git', :tag => 'v4.0.4' ``` ### 1. Get the SDK diff --git a/VERSION b/VERSION index c4e41f945..c5106e6d1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.3 +4.0.4 diff --git a/doc/migrate.md b/doc/migrate.md index 70417fee8..dd21e6590 100644 --- a/doc/migrate.md +++ b/doc/migrate.md @@ -1,4 +1,4 @@ -## Migrate your adjust SDK for iOS to v4.0.3 from v3.4.0 +## Migrate your adjust SDK for iOS to v4.0.4 from v3.4.0 ### Initial setup