diff --git a/Adjust.podspec b/Adjust.podspec index 354aa6a87..53118f9b5 100644 --- a/Adjust.podspec +++ b/Adjust.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "Adjust" - s.version = "4.2.0" + s.version = "4.2.1" 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.2.0" } + s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.2.1" } s.platform = :ios, '4.3' s.framework = 'SystemConfiguration' s.weak_framework = 'AdSupport', 'iAd' diff --git a/Adjust/ADJAdditions/NSData+ADJAdditions.h b/Adjust/ADJAdditions/NSData+ADJAdditions.h index 0958f3fce..a2786c116 100644 --- a/Adjust/ADJAdditions/NSData+ADJAdditions.h +++ b/Adjust/ADJAdditions/NSData+ADJAdditions.h @@ -12,4 +12,4 @@ - (NSString *)adjEncodeBase64; -@end \ No newline at end of file +@end diff --git a/Adjust/ADJAdditions/NSData+ADJAdditions.m b/Adjust/ADJAdditions/NSData+ADJAdditions.m index 03228ccd3..6b70105e8 100644 --- a/Adjust/ADJAdditions/NSData+ADJAdditions.m +++ b/Adjust/ADJAdditions/NSData+ADJAdditions.m @@ -61,4 +61,4 @@ - (NSString *)adjEncodeBase64 { return encodedString; } -@end \ No newline at end of file +@end diff --git a/Adjust/ADJAttributionHandler.m b/Adjust/ADJAttributionHandler.m index 7f2c70eaf..fde45cee2 100644 --- a/Adjust/ADJAttributionHandler.m +++ b/Adjust/ADJAttributionHandler.m @@ -117,23 +117,23 @@ -(void) getAttributionInternal { NSError *requestError; NSURLResponse *urlResponse = nil; - NSData *response = [NSURLConnection sendSynchronousRequest:request + NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError]; // connection error - if (requestError != nil) { + if (responseData == nil || requestError != nil) { [self.logger error:@"Failed to get attribution. (%@)", requestError.localizedDescription]; return; } - NSString *responseString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; + NSString *responseString = [[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] adjTrim]; NSInteger statusCode = ((NSHTTPURLResponse*)urlResponse).statusCode; [self.logger verbose:@"status code %d for attribution response: %@", statusCode, responseString]; - NSDictionary *jsonDict = [ADJUtil buildJsonDict:responseString]; + NSDictionary *jsonDict = [ADJUtil buildJsonDict:responseData]; if (jsonDict == nil || jsonDict == (id)[NSNull null]) { - [self.logger error:@"Failed to parse json attribution response: %@", responseString.adjTrim]; + [self.logger error:@"Failed to parse json attribution response: %@", responseString]; return; } diff --git a/Adjust/ADJRequestHandler.m b/Adjust/ADJRequestHandler.m index 52045f1e4..c6e29aacb 100644 --- a/Adjust/ADJRequestHandler.m +++ b/Adjust/ADJRequestHandler.m @@ -67,12 +67,12 @@ - (void)sendInternal:(ADJActivityPackage *)package sendToPackageHandler:(BOOL)se NSMutableURLRequest *request = [self requestForPackage:package]; NSHTTPURLResponse *response = nil; NSError *error = nil; - NSData *data = [NSURLConnection sendSynchronousRequest:request + NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; // connection error - if (error != nil) { + if (responseData == nil || error != nil) { [self.logger error:@"%@. (%@) Will retry later.", package.failureMessage, error.localizedDescription]; [self.packageHandler finishedTrackingActivity:nil]; if (sendToPackageHandler) { @@ -81,15 +81,15 @@ - (void)sendInternal:(ADJActivityPackage *)package sendToPackageHandler:(BOOL)se return; } - NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + NSString *responseString = [[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] adjTrim]; NSInteger statusCode = response.statusCode; [self.logger verbose:@"status code %d for package response: %@", statusCode, responseString]; - NSDictionary *jsonDict = [ADJUtil buildJsonDict:responseString]; + NSDictionary *jsonDict = [ADJUtil buildJsonDict:responseData]; if (jsonDict == nil || jsonDict == (id)[NSNull null]) { - [self.logger error:@"Failed to parse json response. (%@) Will retry later.", responseString.adjTrim]; + [self.logger error:@"Failed to parse json response. (%@) Will retry later.", responseString]; if (sendToPackageHandler) { [self.packageHandler closeFirstPackage]; } diff --git a/Adjust/ADJUtil.h b/Adjust/ADJUtil.h index 76fc47b0d..7bf79e441 100644 --- a/Adjust/ADJUtil.h +++ b/Adjust/ADJUtil.h @@ -15,7 +15,7 @@ + (void)excludeFromBackup:(NSString *)filename; + (NSString *)formatSeconds1970:(double)value; + (NSString *)formatDate:(NSDate *)value; -+ (NSDictionary *) buildJsonDict:(NSString *)jsonString; ++ (NSDictionary *) buildJsonDict:(NSData *)jsonData; + (NSString *)getFullFilename:(NSString *) baseFilename; diff --git a/Adjust/ADJUtil.m b/Adjust/ADJUtil.m index 1bc21a78b..d14dd2f13 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.2.0"; +static NSString * const kClientSdk = @"ios4.2.1"; static NSString * const kDateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'Z"; static NSDateFormatter *dateFormat; @@ -69,7 +69,7 @@ + (void)excludeFromBackup:(NSString *)path { BOOL success = [url setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error]; - if (!success) { + if (!success || error != nil) { [logger debug:@"Failed to exclude '%@' from backup (%@)", url.lastPathComponent, error.localizedDescription]; } } @@ -89,10 +89,17 @@ + (NSString *)formatDate:(NSDate *) value { } -+ (NSDictionary *)buildJsonDict:(NSString *)jsonString { ++ (NSDictionary *)buildJsonDict:(NSData *)jsonData { + if (jsonData == nil) { + return nil; + } NSError *error = nil; - NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; - NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; + NSDictionary *jsonDict = nil; + @try { + jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; + } @catch (NSException *ex) { + return nil; + } if (error != nil) { return nil; diff --git a/AdjustTests/ADJActivityHandlerTests.m b/AdjustTests/ADJActivityHandlerTests.m index 2d13d1f0b..ca6ab72ee 100644 --- a/AdjustTests/ADJActivityHandlerTests.m +++ b/AdjustTests/ADJActivityHandlerTests.m @@ -121,7 +121,7 @@ - (void)testFirstRun ADJActivityPackage *activityPackage = (ADJActivityPackage *) self.packageHandlerMock.packageQueue[0]; // check the Sdk version is being tested - XCTAssertEqual(@"ios4.2.0", activityPackage.clientSdk, @"%@", activityPackage.extendedString); + XCTAssertEqual(@"ios4.2.1", activityPackage.clientSdk, @"%@", activityPackage.extendedString); // check the server url XCTAssertEqual(@"https://app.adjust.com", ADJUtil.baseUrl); diff --git a/AdjustTests/ADJAttributionHandlerTests.m b/AdjustTests/ADJAttributionHandlerTests.m index 9acfd05f4..62333f359 100644 --- a/AdjustTests/ADJAttributionHandlerTests.m +++ b/AdjustTests/ADJAttributionHandlerTests.m @@ -161,7 +161,7 @@ -(void) testAskInConnectionError { [NSURLConnection setConnectionError:YES]; - NSDictionary *jsonDict = [ADJUtil buildJsonDict:@"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\",\"network\":\"networkValue\",\"campaign\":\"campaignValue\",\"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\",\"click_label\":\"clickLabelValue\"},\"ask_in\":0,\"message\":\"response OK\",\"deeplink\":\"testApp://\"}"]; + NSDictionary *jsonDict = [ADJUtil buildJsonDict:[@"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\",\"network\":\"networkValue\",\"campaign\":\"campaignValue\",\"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\",\"click_label\":\"clickLabelValue\"},\"ask_in\":0,\"message\":\"response OK\",\"deeplink\":\"testApp://\"}" dataUsingEncoding:NSUTF8StringEncoding]]; [attributionHandler checkAttribution:jsonDict]; @@ -297,7 +297,7 @@ -(void) testCancelTimer { NSString * jsonString = @"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\",\"network\":\"networkValue\",\"campaign\":\"campaignValue\",\"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\",\"click_label\":\"clickLabelValue\"},\"message\":\"response OK\",\"ask_in\":\"5000\"}"; - NSDictionary * jsonDict = [ADJUtil buildJsonDict:jsonString]; + NSDictionary * jsonDict = [ADJUtil buildJsonDict:[jsonString dataUsingEncoding:NSUTF8StringEncoding]]; [attributionHandler checkAttribution:jsonDict]; diff --git a/README.md b/README.md index b008e0f7c..2ac00a31b 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.2.0' +pod 'Adjust', :git => 'git://github.com/adjust/ios_sdk.git', :tag => 'v4.2.1' ``` ### 1. Get the SDK diff --git a/VERSION b/VERSION index 6aba2b245..fae6e3d04 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.2.0 +4.2.1 diff --git a/doc/migrate.md b/doc/migrate.md index a17f6883c..fa5c274ef 100644 --- a/doc/migrate.md +++ b/doc/migrate.md @@ -1,4 +1,4 @@ -## Migrate your adjust SDK for iOS to v4.2.0 from v3.4.0 +## Migrate your adjust SDK for iOS to v4.2.1 from v3.4.0 ### Initial setup