diff --git a/Adjust.podspec b/Adjust.podspec index 995a1fedf..9b0fa6970 100644 --- a/Adjust.podspec +++ b/Adjust.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "Adjust" - s.version = "4.21.1" + s.version = "4.21.2" s.summary = "This is the iOS SDK of adjust. You can read more about it at http://adjust.com." s.homepage = "https://github.com/adjust/ios_sdk" 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.21.1" } + s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.21.2" } s.ios.deployment_target = '6.0' s.tvos.deployment_target = '9.0' s.framework = 'SystemConfiguration' diff --git a/Adjust/ADJActivityHandler.m b/Adjust/ADJActivityHandler.m index bf0fc9335..d6f1c4697 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -32,6 +32,7 @@ static NSString * const kForegroundTimerName = @"Foreground timer"; static NSString * const kBackgroundTimerName = @"Background timer"; static NSString * const kDelayStartTimerName = @"Delay Start timer"; +static NSString * const kiAdTimeoutTimerName = @"iAd Timeout timer"; static NSTimeInterval kForegroundTimerInterval; static NSTimeInterval kForegroundTimerStart; @@ -399,8 +400,9 @@ - (void)setTrackingStateOptedOut { - (void)setAttributionDetails:(NSDictionary *)attributionDetails error:(NSError *)error { - [self.iAdTimeoutTimer cancel]; - + if (self.iAdTimeoutTimer) { + [self.iAdTimeoutTimer cancel]; + } if (![ADJUtil isNull:error]) { [self.logger warn:@"Unable to read iAd details"]; @@ -435,7 +437,7 @@ - (void)setAttributionDetails:(NSDictionary *)attributionDetails self.iAdRetriesLeft = self.iAdRetriesLeft - 1; dispatch_time_t retryTime = dispatch_time(DISPATCH_TIME_NOW, iAdRetryDelay); dispatch_after(retryTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - [self checkForIad]; + [self checkForiAd]; }); return; } @@ -793,8 +795,8 @@ - (void)initI:(ADJActivityHandler *)selfI startsSending:[selfI toSendI:selfI sdkClickHandlerOnly:YES]]; - if (self.adjustConfig.allowiAdInfoReading == YES) { - [self checkForIad]; + if (selfI.adjustConfig.allowiAdInfoReading == YES) { + [selfI checkForiAdI:selfI]; } [selfI preLaunchActionsI:selfI preLaunchActionsArray:preLaunchActionsArray]; @@ -1297,8 +1299,8 @@ - (void)setEnabledI:(ADJActivityHandler *)selfI enabled:(BOOL)enabled { } else if ([ADJUserDefaults getDisableThirdPartySharing]) { [selfI disableThirdPartySharing]; } - if (self.adjustConfig.allowiAdInfoReading == YES) { - [self checkForIad]; + if (selfI.adjustConfig.allowiAdInfoReading == YES) { + [selfI checkForiAdI:selfI]; } } @@ -1309,23 +1311,30 @@ - (void)setEnabledI:(ADJActivityHandler *)selfI enabled:(BOOL)enabled { unPausingMessage:@"Resuming handlers due to SDK being enabled"]; } -- (void)checkForIad { - if (self.iAdTimeoutTimer == nil) { - self.iAdTimeoutTimer = +- (void)checkForiAd { + [ADJUtil launchInQueue:self.internalQueue + selfInject:self + block:^(ADJActivityHandler *selfI) { + [selfI checkForiAdI:selfI]; + }]; +} + +- (void)checkForiAdI:(ADJActivityHandler *)selfI { + if (selfI.iAdTimeoutTimer == nil) { + selfI.iAdTimeoutTimer = [ADJTimerOnce timerWithBlock:^{ - [self - setAttributionDetails:nil - error:[NSError errorWithDomain:@"com.adjust.sdk.iAd" - code:100 - userInfo:@{@"Error reason": @"iAd request timed out"}]]; + [selfI setAttributionDetails:nil + error:[NSError errorWithDomain:@"com.adjust.sdk.iAd" + code:100 + userInfo:@{@"Error reason": @"iAd request timed out"}]]; } - queue:self.internalQueue - name:@"iAdTimeoutTimer"]; + queue:selfI.internalQueue + name:kiAdTimeoutTimerName]; } - [[UIDevice currentDevice] adjCheckForiAd:self iAdTimeoutTimer:self.iAdTimeoutTimer]; + [[UIDevice currentDevice] adjCheckForiAd:selfI iAdTimeoutTimer:selfI.iAdTimeoutTimer]; } - (void)setOfflineModeI:(ADJActivityHandler *)selfI diff --git a/Adjust/ADJAdditions/UIDevice+ADJAdditions.m b/Adjust/ADJAdditions/UIDevice+ADJAdditions.m index b6b081e0e..7f10cc173 100644 --- a/Adjust/ADJAdditions/UIDevice+ADJAdditions.m +++ b/Adjust/ADJAdditions/UIDevice+ADJAdditions.m @@ -220,8 +220,9 @@ - (BOOL)setiAdWithDetails:(ADJActivityHandler *)activityHandler error:error]; }]; #pragma clang diagnostic pop - [iAdTimeoutTimer startIn:5.0]; - + if (iAdTimeoutTimer) { + [iAdTimeoutTimer startIn:5.0]; + } return YES; } diff --git a/Adjust/ADJTimerOnce.m b/Adjust/ADJTimerOnce.m index bfa4d8545..e6ea63e78 100644 --- a/Adjust/ADJTimerOnce.m +++ b/Adjust/ADJTimerOnce.m @@ -72,6 +72,15 @@ - (void)startIn:(NSTimeInterval)startIn { self.source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, self.internalQueue); + if (!self.source) { + [self.logger error:@"%@ could not start witouth source", self.name]; + return; + } + if (!self.block) { + [self.logger error:@"%@ could not start witouth block", self.name]; + return; + } + dispatch_source_set_timer(self.source, dispatch_walltime(NULL, startIn * NSEC_PER_SEC), DISPATCH_TIME_FOREVER, diff --git a/Adjust/ADJUtil.m b/Adjust/ADJUtil.m index 96d1058f8..6f103c499 100644 --- a/Adjust/ADJUtil.m +++ b/Adjust/ADJUtil.m @@ -43,7 +43,7 @@ static CTTelephonyNetworkInfo *networkInfo = nil; #endif -static NSString * const kClientSdk = @"ios4.21.1"; +static NSString * const kClientSdk = @"ios4.21.2"; static NSString * const kDeeplinkParam = @"deep_link="; static NSString * const kSchemeDelimiter = @"://"; static NSString * const kDefaultScheme = @"AdjustUniversalScheme"; @@ -370,44 +370,45 @@ + (id)readObject:(NSString *)fileName + (void)writeObject:(id)object fileName:(NSString *)fileName - objectName:(NSString *)objectName -{ + objectName:(NSString *)objectName { @synchronized([ADJUtil class]) { - BOOL result; - NSString *filePath = [ADJUtil getFilePathInAppSupportDir:fileName]; - - if (!filePath) { - [[ADJAdjustFactory logger] error:@"Cannot get filepath from filename: %@, to write %@ file", fileName, objectName]; - return; - } + @try { + BOOL result; + NSString *filePath = [ADJUtil getFilePathInAppSupportDir:fileName]; + if (!filePath) { + [[ADJAdjustFactory logger] error:@"Cannot get filepath from filename: %@, to write %@ file", fileName, objectName]; + return; + } - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) { - NSError *errorArchiving = nil; + if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) { + NSError *errorArchiving = nil; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability" - NSData *data = [NSKeyedArchiver archivedDataWithRootObject:object requiringSecureCoding:NO error:&errorArchiving]; + NSData *data = [NSKeyedArchiver archivedDataWithRootObject:object requiringSecureCoding:NO error:&errorArchiving]; #pragma clang diagnostic pop - if (data && errorArchiving == nil) { - NSError *errorWriting = nil; - result = [data writeToFile:filePath options:NSDataWritingAtomic error:&errorWriting]; - result = result && (errorWriting == nil); + if (data && errorArchiving == nil) { + NSError *errorWriting = nil; + result = [data writeToFile:filePath options:NSDataWritingAtomic error:&errorWriting]; + result = result && (errorWriting == nil); + } else { + result = NO; + } } else { - result = NO; + result = [NSKeyedArchiver archiveRootObject:object toFile:filePath]; } - } else { - result = [NSKeyedArchiver archiveRootObject:object toFile:filePath]; - } - if (result == YES) { - [ADJUtil excludeFromBackup:filePath]; - if ([object isKindOfClass:[NSArray class]]) { - [[ADJAdjustFactory logger] debug:@"Package handler wrote %d packages", [object count]]; + if (result == YES) { + [ADJUtil excludeFromBackup:filePath]; + if ([object isKindOfClass:[NSArray class]]) { + [[ADJAdjustFactory logger] debug:@"Package handler wrote %d packages", [object count]]; + } else { + [[ADJAdjustFactory logger] debug:@"Wrote %@: %@", objectName, object]; + } } else { - [[ADJAdjustFactory logger] debug:@"Wrote %@: %@", objectName, object]; + [[ADJAdjustFactory logger] error:@"Failed to write %@ file", objectName]; } - } else { - [[ADJAdjustFactory logger] error:@"Failed to write %@ file", objectName]; + } @catch (NSException *exception) { + [[ADJAdjustFactory logger] error:@"Failed to write %@ file (%@)", objectName, exception]; } - } } diff --git a/Adjust/Adjust.h b/Adjust/Adjust.h index e2658ad89..f33bbc0eb 100644 --- a/Adjust/Adjust.h +++ b/Adjust/Adjust.h @@ -2,7 +2,7 @@ // Adjust.h // Adjust // -// V4.21.1 +// V4.21.2 // Created by Christian Wellenbrock (wellle) on 23rd July 2013. // Copyright © 2012-2017 Adjust GmbH. All rights reserved. // diff --git a/AdjustBridge/AdjustBridgeRegister.m b/AdjustBridge/AdjustBridgeRegister.m index 9b12a52be..8ae4c40cf 100644 --- a/AdjustBridge/AdjustBridgeRegister.m +++ b/AdjustBridge/AdjustBridgeRegister.m @@ -221,7 +221,7 @@ + (NSString *)adjust_js { if (this.sdkPrefix) { return this.sdkPrefix; } else { - return 'web-bridge4.21.1'; + return 'web-bridge4.21.2'; } }, setTestOptions: function(testOptions) { diff --git a/AdjustTests/AdjustUnitTests/ADJPackageFields.m b/AdjustTests/AdjustUnitTests/ADJPackageFields.m index d21e55a6e..13606d9e9 100644 --- a/AdjustTests/AdjustUnitTests/ADJPackageFields.m +++ b/AdjustTests/AdjustUnitTests/ADJPackageFields.m @@ -16,7 +16,7 @@ - (id) init { // default values self.appToken = @"qwerty123456"; - self.clientSdk = @"ios4.21.1"; + self.clientSdk = @"ios4.21.2"; self.suffix = @""; self.environment = @"sandbox"; diff --git a/CHANGELOG.md b/CHANGELOG.md index 923e5dbe1..cd92d282e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### Version 4.21.2 (15th April 2020) +#### Fixed +- Added check for timer source and block existence prior to starting it. + +--- + ### Version 4.21.1 (9th April 2020) #### Added - Added support for Mac Catalyst (thanks to @rjchatfield). diff --git a/README.md b/README.md index a4de3ec0d..30bff553e 100644 --- a/README.md +++ b/README.md @@ -74,13 +74,13 @@ We will describe the steps to integrate the Adjust SDK into your iOS project. We If you're using [CocoaPods][cocoapods], you can add the following line to your `Podfile` and continue from [this step](#sdk-integrate): ```ruby -pod 'Adjust', '~> 4.21.1' +pod 'Adjust', '~> 4.21.2' ``` or: ```ruby -pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.21.1' +pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.21.2' ``` --- diff --git a/VERSION b/VERSION index 79b1bb629..c93e58ee0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.21.1 +4.21.2 diff --git a/doc/chinese/README.md b/doc/chinese/README.md index 2cd831e03..1acf5ab24 100644 --- a/doc/chinese/README.md +++ b/doc/chinese/README.md @@ -73,13 +73,13 @@ Read this in other languages: [English][en-readme], [中文][zh-readme], [日本 如果您正在使用[CocoaPods][cocoapods],您可以将以下代码行添加至 `Podfile`,然后继续进行[此步骤](#sdk-integrate): ```ruby -pod 'Adjust', '~> 4.21.1' +pod 'Adjust', '~> 4.21.2' ``` 或: ```ruby -pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.21.1' +pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.21.2' ``` --- diff --git a/doc/english/migrate.md b/doc/english/migrate.md index 0c4373eeb..e74db1313 100644 --- a/doc/english/migrate.md +++ b/doc/english/migrate.md @@ -1,4 +1,4 @@ -## Migrate your adjust SDK for iOS to v4.21.1 from v3.4.0 +## Migrate your Adjust SDK for iOS to v4.21.2 from v3.4.0 ### Initial setup diff --git a/doc/english/web_views.md b/doc/english/web_views.md index 9f2ac0f45..30ea2d10a 100644 --- a/doc/english/web_views.md +++ b/doc/english/web_views.md @@ -64,7 +64,7 @@ We will describe the steps to integrate the Adjust SDK into your iOS project. We If you're using [CocoaPods][cocoapods], you can add the following line to your `Podfile` and continue from [this step](#sdk-integrate): ```ruby -pod 'Adjust/WebBridge', '~> 4.21.1' +pod 'Adjust/WebBridge', '~> 4.21.2' ``` --- diff --git a/doc/japanese/README.md b/doc/japanese/README.md index b0cf6c936..783d31f04 100644 --- a/doc/japanese/README.md +++ b/doc/japanese/README.md @@ -25,13 +25,13 @@ adjust SDKをiOSプロジェクトに連携する手順を説明します。 [こちらの手順](#sdk-integrate)に進んでください。 ```ruby -pod 'Adjust', '~> 4.21.1' +pod 'Adjust', '~> 4.21.2' ``` または ```ruby -pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.21.1' +pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.21.2' ``` --- diff --git a/doc/korean/README.md b/doc/korean/README.md index f20bb7b14..c4d1678aa 100644 --- a/doc/korean/README.md +++ b/doc/korean/README.md @@ -73,13 +73,13 @@ iOS 개발용 Xcode를 사용한다는 가정하에 iOS 프로젝트에 Adjust S [CocoaPods][cocoapods]를 사용하는 경우, 다음 내용을 `Podfile`에 추가한 후 [해당 단계](#sdk-integrate)를 완료하세요. ```ruby -pod 'Adjust', '~> 4.21.1' +pod 'Adjust', '~> 4.21.2' ``` 또는: ```ruby -pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.21.1' +pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.21.2' ``` --- diff --git a/doc/korean/web_views.md b/doc/korean/web_views.md index 7c1c848a3..1f3a32e69 100644 --- a/doc/korean/web_views.md +++ b/doc/korean/web_views.md @@ -64,7 +64,7 @@ iOS 개발용 Xcode를 사용한다는 가정하에 iOS 프로젝트에 Adjust S [CocoaPods][cocoapods]를 사용하는 경우, 다음 내용을 'Podfile'에 추가한 후 [해당 단계](#sdk-integrate)를 완료하세요. ```ruby -pod 'Adjust/WebBridge', '~> 4.21.1' +pod 'Adjust/WebBridge', '~> 4.21.2' ``` --- diff --git a/doc/migrate.md b/doc/migrate.md index 8eaed6623..e74db1313 100644 --- a/doc/migrate.md +++ b/doc/migrate.md @@ -1,4 +1,4 @@ -## Migrate your Adjust SDK for iOS to v4.21.1 from v3.4.0 +## Migrate your Adjust SDK for iOS to v4.21.2 from v3.4.0 ### Initial setup