Skip to content

Commit

Permalink
Merge pull request #221 from adjust/v482
Browse files Browse the repository at this point in the history
V482
  • Loading branch information
nonelse authored Aug 5, 2016
2 parents 6793034 + ac9af8f commit 7ab7cb5
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 45 deletions.
4 changes: 2 additions & 2 deletions Adjust.podspec
Original file line number Diff line number Diff line change
@@ -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" => "[email protected]" }
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'
Expand Down
32 changes: 15 additions & 17 deletions Adjust/ADJActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];

Expand All @@ -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];
Expand Down
56 changes: 35 additions & 21 deletions Adjust/ADJUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,30 @@
#include <stdlib.h>

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:)]) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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<NSTextCheckingResult *> *matches = [universalLinkRegex matchesInString:urlString options:0 range:NSMakeRange(0, [urlString length])];
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion AdjustTests/ADJPackageFields.m
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.8.1
4.8.2

0 comments on commit 7ab7cb5

Please sign in to comment.