diff --git a/Adjust.podspec b/Adjust.podspec index b5153db43..ef8c4dbed 100644 --- a/Adjust.podspec +++ b/Adjust.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "Adjust" - s.version = "4.8.1" + s.version = "4.8.2" 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.8.1" } + s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.8.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 97e4880c9..35c7182a6 100644 --- a/Adjust/ADJActivityHandler.m +++ b/Adjust/ADJActivityHandler.m @@ -136,23 +136,6 @@ - (id)initWithConfig:(ADJConfig *)adjustConfig { [self initInternal]; }); - // get timer values - kForegroundTimerStart = ADJAdjustFactory.timerStart; - kForegroundTimerInterval = ADJAdjustFactory.timerInterval; - kBackgroundTimerInterval = ADJAdjustFactory.timerInterval; - - // initialize timers to be available in applicationDidBecomeActive/WillResignActive - // after initInternal so that the handlers are initialized - self.foregroundTimer = [ADJTimerCycle timerWithBlock:^{ [self foregroundTimerFired]; } - queue:self.internalQueue - startTime:kForegroundTimerStart - intervalTime:kForegroundTimerInterval - name:kForegroundTimerName]; - - self.backgroundTimer = [ADJTimerOnce timerWithBlock:^{ [self backgroundTimerFired]; } - queue:self.internalQueue - name:kBackgroundTimerName]; - [self addNotificationObserver]; return self; @@ -429,8 +412,13 @@ - (void)backgroundTimerFired { #pragma mark - internal - (void)initInternal { + // get session values kSessionInterval = ADJAdjustFactory.sessionInterval; kSubSessionInterval = ADJAdjustFactory.subsessionInterval; + // get timer values + kForegroundTimerStart = ADJAdjustFactory.timerStart; + kForegroundTimerInterval = ADJAdjustFactory.timerInterval; + kBackgroundTimerInterval = ADJAdjustFactory.timerInterval; self.deviceInfo = [ADJDeviceInfo deviceInfoWithSdkPrefix:self.adjustConfig.sdkPrefix]; @@ -442,6 +430,16 @@ - (void)initInternal { [self.logger info:@"Default tracker: '%@'", self.adjustConfig.defaultTracker]; } + self.foregroundTimer = [ADJTimerCycle timerWithBlock:^{ [self foregroundTimerFired]; } + queue:self.internalQueue + startTime:kForegroundTimerStart + intervalTime:kForegroundTimerInterval + name:kForegroundTimerName]; + + self.backgroundTimer = [ADJTimerOnce timerWithBlock:^{ [self backgroundTimerFired]; } + queue:self.internalQueue + name:kBackgroundTimerName]; + BOOL toSend = [self toSend]; self.packageHandler = [ADJAdjustFactory packageHandlerForActivityHandler:self startsSending:toSend]; diff --git a/Adjust/ADJUtil.m b/Adjust/ADJUtil.m index 0a6a1ca91..bfbdb16be 100644 --- a/Adjust/ADJUtil.m +++ b/Adjust/ADJUtil.m @@ -19,21 +19,30 @@ #include static NSDateFormatter *dateFormat; +static NSRegularExpression * universalLinkRegex = nil; +static NSNumberFormatter * secondsNumberFormatter = nil; -static NSString * const kClientSdk = @"ios4.8.1"; +static NSString * const kClientSdk = @"ios4.8.2"; static NSString * const kDefaultScheme = @"AdjustUniversalScheme"; static NSString * const kUniversalLinkPattern = @"https://[^.]*\\.ulink\\.adjust\\.com/ulink/?(.*)"; static NSString * const kBaseUrl = @"https://app.adjust.com"; static NSString * const kDateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'Z"; -static NSRegularExpression * universalLinkRegex = nil; -static NSNumberFormatter * secondsNumberFormatter = nil; static const double kRequestTimeout = 60; // 60 seconds #pragma mark - @implementation ADJUtil + (void) initialize { + if (self != [ADJUtil class]) { + return; + } + [self initializeDateFormat]; + [self initializeUniversalLinkRegex]; + [self initializeSecondsNumberFormatter]; +} + ++ (void)initializeDateFormat { dateFormat = [[NSDateFormatter alloc] init]; if ([NSCalendar instancesRespondToSelector:@selector(calendarWithIdentifier:)]) { @@ -58,6 +67,27 @@ + (void) initialize { dateFormat.locale = [NSLocale systemLocale]; [dateFormat setDateFormat:kDateFormat]; + +} ++ (void)initializeUniversalLinkRegex { + NSError *error = NULL; + + NSRegularExpression *regex = [NSRegularExpression + regularExpressionWithPattern:kUniversalLinkPattern + options:NSRegularExpressionCaseInsensitive + error:&error]; + + if ([ADJUtil isNotNull:error]) { + [ADJAdjustFactory.logger error:@"Universal link regex rule error (%@)", [error description]]; + return; + } + + universalLinkRegex = regex; +} + ++ (void)initializeSecondsNumberFormatter { + secondsNumberFormatter = [[NSNumberFormatter alloc] init]; + [secondsNumberFormatter setPositiveFormat:@"0.0"]; } + (NSString *)baseUrl { @@ -487,19 +517,8 @@ + (NSURL *)convertUniversalLink:(NSURL *)url scheme:(NSString *)scheme { } if (universalLinkRegex == nil) { - NSError *error = NULL; - - NSRegularExpression *regex = [NSRegularExpression - regularExpressionWithPattern:kUniversalLinkPattern - options:NSRegularExpressionCaseInsensitive - error:&error]; - - if ([ADJUtil isNotNull:error]) { - [logger error:@"Universal link regex rule error (%@)", [error description]]; - return nil; - } - - universalLinkRegex = regex; + [logger error:@"Universal link regex not correctly configured"]; + return nil; } NSArray *matches = [universalLinkRegex matchesInString:urlString options:0 range:NSMakeRange(0, [urlString length])]; @@ -538,11 +557,6 @@ + (NSURL *)convertUniversalLink:(NSURL *)url scheme:(NSString *)scheme { } + (NSString *)secondsNumberFormat:(double)seconds { - if (secondsNumberFormatter == nil) { - secondsNumberFormatter = [[NSNumberFormatter alloc] init]; - [secondsNumberFormatter setPositiveFormat:@"0.0"]; - } - // normalize negative zero if (seconds < 0) { seconds = seconds * -1; diff --git a/AdjustTests/ADJPackageFields.m b/AdjustTests/ADJPackageFields.m index 0a53687cb..b348c38a1 100644 --- a/AdjustTests/ADJPackageFields.m +++ b/AdjustTests/ADJPackageFields.m @@ -16,7 +16,7 @@ - (id) init { // default values self.appToken = @"qwerty123456"; - self.clientSdk = @"ios4.8.1"; + self.clientSdk = @"ios4.8.2"; self.suffix = @""; self.environment = @"sandbox"; diff --git a/CHANGELOG.md b/CHANGELOG.md index 11b8be324..42b383055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +### Version 4.8.2 (5th August 2016) +#### Fixed +- Initialize static vars to prevent dealloc + +--- + +### Version 4.8.1 (3rd August 2016) +#### Added +- Added Safari Framework in the example app. + +### Fixed +- Replace sleeping background thread with delay execution + +--- + ### Version 4.8.0 (25th July 2016) #### Added - Added tracking support for native web apps (no SDK version change). diff --git a/README.md b/README.md index cc70d7958..c29cc04a8 100644 --- a/README.md +++ b/README.md @@ -66,13 +66,13 @@ If you're using [CocoaPods][cocoapods], you can add the following line to your ` [this step](#sdk-integrate): ```ruby -pod 'Adjust', '~> 4.8.1' +pod 'Adjust', '~> 4.8.2' ``` or: ```ruby -pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.8.1' +pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.8.2' ``` If you're using [Carthage][carthage], you can add following line to your `Cartfile` and continue with @@ -809,7 +809,7 @@ send `sdk_click` package anyway to the adjust backend. If you have your log leve ``` [Adjust]d: Added package 1 (click) [Adjust]v: Path: /sdk_click -[Adjust]v: ClientSdk: ios4.8.0 +[Adjust]v: ClientSdk: ios4.8.2 [Adjust]v: Parameters: [Adjust]v: app_token {YourAppToken} [Adjust]v: created_at 2016-04-15T14:25:51.676Z+0200 diff --git a/VERSION b/VERSION index 697e99391..326ec6355 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.8.1 +4.8.2