Skip to content

Commit

Permalink
Merge pull request #279 from adjust/v4112
Browse files Browse the repository at this point in the history
Version 4.11.2
  • Loading branch information
uerceg authored Mar 14, 2017
2 parents d147292 + 0778d19 commit a3462b4
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 22 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.11.1"
s.version = "4.11.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" => "[email protected]" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.11.1" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.11.2" }
s.ios.deployment_target = '6.0'
s.tvos.deployment_target = '9.0'
s.framework = 'SystemConfiguration'
Expand Down
3 changes: 3 additions & 0 deletions Adjust/ADJActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ - (id)initWithConfig:(ADJConfig *)adjustConfig

[self.logger lockLogLevel];

// inject app token be available in activity state
[ADJActivityState saveAppToken:adjustConfig.appToken];

// read files to have sync values available
[self readAttribution];
[self readActivityState];
Expand Down
2 changes: 2 additions & 0 deletions Adjust/ADJActivityState.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

- (void)resetSessionAttributes:(double)now;

+ (void)saveAppToken:(NSString *)appTokenToSave;

// Transaction ID management
- (void)addTransactionId:(NSString *)transactionId;
- (BOOL)findTransactionId:(NSString *)transactionId;
Expand Down
47 changes: 37 additions & 10 deletions Adjust/ADJActivityState.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#import "ADJAdjustFactory.h"
#import "ADJActivityState.h"
#import "UIDevice+ADJAdditions.h"
#import "NSString+ADJAdditions.h"

static const int kTransactionIdCount = 10;
static NSString *appToken = nil;

@implementation ADJActivityState

Expand Down Expand Up @@ -44,6 +46,12 @@ - (id)init {

#pragma mark - Public methods

+ (void)saveAppToken:(NSString *)appTokenToSave {
@synchronized (self) {
appToken = appTokenToSave;
}
}

- (void)resetSessionAttributes:(double)now {
self.subsessionCount = 1;
self.sessionLength = 0;
Expand Down Expand Up @@ -120,31 +128,50 @@ - (void)assignUuidOldMethod:(NSString *)uuid {
self.isPersisted = [ADJKeychain setValue:self.uuid forKeychainKey:@"adjust_persisted_uuid" inService:@"deviceInfo"];
}

- (void)assignUuidNewMethod:(NSString *)uuid {
NSString *persistedUuidNew = [ADJKeychain valueForKeychainKeyNew:@"adjust_persisted_uuid" service:@"deviceInfo"];
- (NSString *)generateUniqueKey {
if (appToken == nil) {
return nil;
}

// Check if value exists in keychain.
if (persistedUuidNew != nil) {
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];

if (bundleIdentifier == nil) {
return nil;
}

NSString *joinedKey = [NSString stringWithFormat:@"%@%@", bundleIdentifier, appToken];

return [joinedKey adjSha1];
}

- (void)assignUuidNewMethod:(NSString *)uuid {
// First check if we have the key written with app's unique key name.
NSString *uniqueKey = [self generateUniqueKey];
NSString *persistedUuidUnique = [ADJKeychain valueForKeychainKeyNew:uniqueKey service:@"deviceInfo"];

if (persistedUuidUnique != nil) {
// Check if value has UUID format.
if ((bool)[[NSUUID alloc] initWithUUIDString:persistedUuidNew]) {
if ((bool)[[NSUUID alloc] initWithUUIDString:persistedUuidUnique]) {
[[ADJAdjustFactory logger] verbose:@"Value found and read from the keychain new way"];

// Value written in keychain seems to have UUID format.
self.uuid = persistedUuidNew;
self.uuid = persistedUuidUnique;
self.isPersisted = YES;

return;
}
}

// At this point, UUID was not persisted with new method or if persisted, didn't have proper UUID format.
// At this point, UUID was not persisted with unique key or if persisted, didn't have proper UUID format.

// Check if it's still saved in the keychain with old writing method.
NSString *persistedUuidOld = [ADJKeychain valueForKeychainKeyOld:@"adjust_persisted_uuid" service:@"deviceInfo"];

if (persistedUuidOld != nil) {
// Check if value has UUID format.
if ((bool)[[NSUUID alloc] initWithUUIDString:persistedUuidOld]) {
[[ADJAdjustFactory logger] verbose:@"Value found and read from the keychain old way"];

// Since we have the value in the keychain written with old method, we'll use it to save it with new one.
self.uuid = persistedUuidOld;
} else {
Expand All @@ -157,7 +184,7 @@ - (void)assignUuidNewMethod:(NSString *)uuid {
}

// Try to save that value to the keychain and flag if successfully written.
self.isPersisted = [ADJKeychain setValue:self.uuid forKeychainKey:@"adjust_persisted_uuid" inService:@"deviceInfo"];
self.isPersisted = [ADJKeychain setValue:self.uuid forKeychainKey:uniqueKey inService:@"deviceInfo"];
}

- (NSString *)description {
Expand Down
1 change: 1 addition & 0 deletions Adjust/ADJAdditions/NSString+ADJAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

@interface NSString(ADJAdditions)

- (NSString *)adjSha1;
- (NSString *)adjTrim;
- (NSString *)adjUrlEncode;
- (NSString *)adjUrlDecode;
Expand Down
20 changes: 19 additions & 1 deletion Adjust/ADJAdditions/NSString+ADJAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2012-2014 adjust GmbH. All rights reserved.
//

#import <CommonCrypto/CommonDigest.h>

#import "NSString+ADJAdditions.h"

@implementation NSString(ADJAdditions)
Expand Down Expand Up @@ -41,6 +43,21 @@ - (NSString *)adjRemoveColons {
return [self stringByReplacingOccurrencesOfString:@":" withString:@""];
}

- (NSString *)adjSha1 {
NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
uint8_t digest[CC_SHA1_DIGEST_LENGTH];

CC_SHA1(data.bytes, (CC_LONG)data.length, digest);

NSMutableString *output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];

for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
[output appendFormat:@"%02x", digest[i]];
}

return output;
}

+ (NSString *)adjJoin:(NSString *)first, ... {
NSString *iter, *result = first;
va_list strings;
Expand All @@ -52,10 +69,11 @@ + (NSString *)adjJoin:(NSString *)first, ... {
}

va_end(strings);

return result;
}

+ (BOOL) adjIsEqual:(NSString *)first toString:(NSString *)second {
+ (BOOL)adjIsEqual:(NSString *)first toString:(NSString *)second {
if (first == nil && second == nil) {
return YES;
}
Expand Down
9 changes: 9 additions & 0 deletions Adjust/ADJKeychain.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,23 @@ - (id)init {
#pragma mark - Public methods

+ (BOOL)setValue:(NSString *)value forKeychainKey:(NSString *)key inService:(NSString *)service {
if (key == nil) {
return NO;
}
return [[ADJKeychain getInstance] setValue:value forKeychainKey:key inService:service];
}

+ (NSString *)valueForKeychainKeyOld:(NSString *)key service:(NSString *)service {
if (key == nil) {
return nil;
}
return [[ADJKeychain getInstance] valueForKeychainKeyOld:key service:service];
}

+ (NSString *)valueForKeychainKeyNew:(NSString *)key service:(NSString *)service {
if (key == nil) {
return nil;
}
return [[ADJKeychain getInstance] valueForKeychainKeyNew:key service:service];
}

Expand Down
2 changes: 1 addition & 1 deletion Adjust/ADJUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

static NSString *userAgent = nil;

static NSString * const kClientSdk = @"ios4.11.1";
static NSString * const kClientSdk = @"ios4.11.2";
static NSString * const kDeeplinkParam = @"deep_link=";
static NSString * const kSchemeDelimiter = @"://";
static NSString * const kDefaultScheme = @"AdjustUniversalScheme";
Expand Down
2 changes: 1 addition & 1 deletion Adjust/Adjust.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Adjust.h
// Adjust
//
// V4.11.1
// V4.11.2
// Created by Christian Wellenbrock on 2012-07-23.
// Copyright (c) 2012-2014 adjust GmbH. All rights reserved.
//
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.11.1";
self.clientSdk = @"ios4.11.2";
self.suffix = @"";
self.environment = @"sandbox";

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### Version 4.11.2 (14th March 2017)
#### Changed
- Changed key name used to save persistent UUID to be unique per app.

---

### Version 4.11.1 (13th March 2017)
#### Added
- Added sending of the app's install time.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ In the dialog `Choose options for adding these files` make sure to check the che
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.11.1'
pod 'Adjust', '~> 4.11.2'
```

or:

```ruby
pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.11.1'
pod 'Adjust', :git => 'https://github.com/adjust/ios_sdk.git', :tag => 'v4.11.2'
```

--
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.11.1
4.11.2
2 changes: 1 addition & 1 deletion doc/english/migrate.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Migrate your adjust SDK for iOS to v4.11.1 from v3.4.0
## Migrate your adjust SDK for iOS to v4.11.2 from v3.4.0

### Initial setup

Expand Down
2 changes: 1 addition & 1 deletion doc/japanese/migrate_ja.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## iOS用adjust SDKのv3.4.0からv.4.11.1への移行
## iOS用adjust SDKのv3.4.0からv.4.11.2への移行

### 初期設定

Expand Down
2 changes: 1 addition & 1 deletion doc/migrate.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Migrate your adjust SDK for iOS to v4.11.1 from v3.4.0
## Migrate your adjust SDK for iOS to v4.11.2 from v3.4.0

### Initial setup

Expand Down

0 comments on commit a3462b4

Please sign in to comment.