Skip to content

Commit

Permalink
Merge pull request #549 from adjust/v4293
Browse files Browse the repository at this point in the history
Version 4.29.3
  • Loading branch information
uerceg authored Jun 16, 2021
2 parents e79ef64 + ee18c10 commit 14a6d8b
Show file tree
Hide file tree
Showing 45 changed files with 265 additions and 94 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.29.2"
s.version = "4.29.3"
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.29.2" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.29.3" }
s.ios.deployment_target = '6.0'
s.tvos.deployment_target = '9.0'
s.framework = 'SystemConfiguration'
Expand Down
2 changes: 1 addition & 1 deletion Adjust.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2266,7 +2266,7 @@
9679920518BBAE2800394606 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1240;
LastUpgradeCheck = 1250;
ORGANIZATIONNAME = "adjust GmbH";
TargetAttributes = {
9615158E1CD2CB2C0022D336 = {
Expand Down
2 changes: 1 addition & 1 deletion Adjust.xcodeproj/xcshareddata/xcschemes/AdjustSdk.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
23 changes: 18 additions & 5 deletions Adjust/ADJActivityState.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "ADJAdjustFactory.h"
#import "ADJActivityState.h"
#import "NSString+ADJAdditions.h"
#import "ADJUtil.h"

static const int kTransactionIdCount = 10;
static NSString *appToken = nil;
Expand All @@ -23,7 +24,7 @@ - (id)init {
return nil;
}

[self assignRandomToken];
[self assignRandomToken:[ADJUtil generateRandomUuid]];

self.eventCount = 0;
self.sessionCount = 0;
Expand Down Expand Up @@ -81,8 +82,20 @@ - (BOOL)findTransactionId:(NSString *)transactionId {

#pragma mark - Private & helper methods

- (void)assignRandomToken {
self.dedupeToken = [[NSUUID UUID] UUIDString];
- (void)assignRandomToken:(NSString *)randomToken {
// self.secondaryDedupeToken = [[NSUUID UUID] UUIDString];
NSString *persistedDedupeToken = [ADJUtil getPersistedRandomToken];
if (persistedDedupeToken != nil) {
if ((bool)[[NSUUID alloc] initWithUUIDString:persistedDedupeToken]) {
[[ADJAdjustFactory logger] verbose:@"Primary dedupe token successfully read"];
self.dedupeToken = persistedDedupeToken;
self.isPersisted = YES;
return;
}
}

self.dedupeToken = randomToken;
self.isPersisted = [ADJUtil setPersistedRandomToken:self.dedupeToken];
}

- (NSString *)description {
Expand Down Expand Up @@ -110,10 +123,10 @@ - (id)initWithCoder:(NSCoder *)decoder {

// Default values for migrating devices.
if ([decoder containsValueForKey:@"uuid"]) {
self.dedupeToken = [decoder decodeObjectForKey:@"uuid"];
[self assignRandomToken:[decoder decodeObjectForKey:@"uuid"]];
}
if (self.dedupeToken == nil) {
[self assignRandomToken];
[self assignRandomToken:[ADJUtil generateRandomUuid]];
}

if ([decoder containsValueForKey:@"transactionIds"]) {
Expand Down
72 changes: 60 additions & 12 deletions Adjust/ADJPackageBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,11 @@ - (NSMutableDictionary *)getSessionParameters:(BOOL)isInDelay {
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setInt:self.activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

if (!isInDelay) {
Expand Down Expand Up @@ -461,7 +465,11 @@ - (NSMutableDictionary *)getEventParameters:(BOOL)isInDelay forEventPackage:(ADJ
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setInt:self.activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

if (!isInDelay) {
Expand Down Expand Up @@ -547,7 +555,11 @@ - (NSMutableDictionary *)getInfoParameters:(NSString *)source {
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setInt:self.activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

if (self.attribution != nil) {
Expand Down Expand Up @@ -612,7 +624,11 @@ - (NSMutableDictionary *)getAdRevenueParameters:(NSString *)source payload:(NSDa
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setInt:self.activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

return parameters;
Expand Down Expand Up @@ -688,7 +704,11 @@ - (NSMutableDictionary *)getAdRevenueParameters:(ADJAdRevenue *)adRevenue isInDe
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setInt:self.activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

return parameters;
Expand Down Expand Up @@ -752,7 +772,11 @@ - (NSMutableDictionary *)getClickParameters:(NSString *)source {
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setInt:self.activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

if (self.attribution != nil) {
Expand Down Expand Up @@ -808,7 +832,11 @@ - (NSMutableDictionary *)getAttributionParameters:(NSString *)initiatedBy {
}

if (self.activityState != nil) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

return parameters;
Expand Down Expand Up @@ -856,7 +884,11 @@ - (NSMutableDictionary *)getGdprParameters {
}

if (self.activityState != nil) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

return parameters;
Expand Down Expand Up @@ -919,7 +951,11 @@ - (NSMutableDictionary *)getDisableThirdPartySharingParameters {
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setInt:self.activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

return parameters;
Expand Down Expand Up @@ -988,7 +1024,11 @@ - (NSMutableDictionary *)getThirdPartySharingParameters:(nonnull ADJThirdPartySh
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setInt:self.activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

return parameters;
Expand Down Expand Up @@ -1054,7 +1094,11 @@ - (NSMutableDictionary *)getMeasurementConsentParameters:(BOOL)enabled {
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setInt:self.activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

return parameters;
Expand Down Expand Up @@ -1107,7 +1151,11 @@ - (NSMutableDictionary *)getSubscriptionParameters:(BOOL)isInDelay forSubscripti
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.sessionLength forKey:@"session_length"];
[ADJPackageBuilder parameters:parameters setInt:self.activityState.subsessionCount forKey:@"subsession_count"];
[ADJPackageBuilder parameters:parameters setDuration:self.activityState.timeSpent forKey:@"time_spent"];
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
if (self.activityState.isPersisted) {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"primary_dedupe_token"];
} else {
[ADJPackageBuilder parameters:parameters setString:self.activityState.dedupeToken forKey:@"secondary_dedupe_token"];
}
}

if (!isInDelay) {
Expand Down
6 changes: 6 additions & 0 deletions Adjust/ADJUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,10 @@ typedef void (^isInactiveInjected)(BOOL);

+ (NSString *)installedAt;

+ (NSString *)generateRandomUuid;

+ (NSString *)getPersistedRandomToken;

+ (BOOL)setPersistedRandomToken:(NSString *)randomToken;

@end
60 changes: 59 additions & 1 deletion Adjust/ADJUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
static NSRegularExpression *shortUniversalLinkRegex = nil;
static NSRegularExpression *excludedDeeplinkRegex = nil;

static NSString * const kClientSdk = @"ios4.29.2";
static NSString * const kClientSdk = @"ios4.29.3";
static NSString * const kDeeplinkParam = @"deep_link=";
static NSString * const kSchemeDelimiter = @"://";
static NSString * const kDefaultScheme = @"AdjustUniversalScheme";
Expand Down Expand Up @@ -1509,4 +1509,62 @@ + (NSString *)installedAt {
return [ADJUtil formatDate:installTime];
}

+ (NSString *)generateRandomUuid {
CFUUIDRef newUniqueId = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef stringRef = CFUUIDCreateString(kCFAllocatorDefault, newUniqueId);
NSString *uuidString = (__bridge_transfer NSString*)stringRef;
NSString *lowerUuid = [uuidString lowercaseString];
CFRelease(newUniqueId);
return lowerUuid;
}

+ (NSString *)getPersistedRandomToken {
NSMutableDictionary *keychainItem = [[NSMutableDictionary alloc] init];
keychainItem[(__bridge id)kSecAttrAccessible] = (__bridge id)kSecAttrAccessibleAfterFirstUnlock;
keychainItem[(__bridge id)kSecClass] = (__bridge id)kSecClassGenericPassword;
keychainItem[(__bridge id)kSecAttrAccount] = @"adjust_uuid";
keychainItem[(__bridge id)kSecAttrService] = @"deviceInfo";
if (!keychainItem) {
return nil;
}

keychainItem[(__bridge id)kSecReturnData] = (__bridge id)kCFBooleanTrue;
keychainItem[(__bridge id)kSecReturnAttributes] = (__bridge id)kCFBooleanTrue;
CFDictionaryRef result = nil;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)keychainItem, (CFTypeRef *)&result);
if (status != noErr) {
return nil;
}

NSDictionary *resultDict = (__bridge_transfer NSDictionary *)result;
NSData *data = resultDict[(__bridge id)kSecValueData];
if (!data) {
return nil;
}

return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}

+ (BOOL)setPersistedRandomToken:(NSString *)randomToken {
NSMutableDictionary *keychainItem = [[NSMutableDictionary alloc] init];
keychainItem[(__bridge id)kSecAttrAccessible] = (__bridge id)kSecAttrAccessibleAfterFirstUnlock;
keychainItem[(__bridge id)kSecClass] = (__bridge id)kSecClassGenericPassword;
keychainItem[(__bridge id)kSecAttrAccount] = @"adjust_uuid";
keychainItem[(__bridge id)kSecAttrService] = @"deviceInfo";
keychainItem[(__bridge id)kSecValueData] = [randomToken dataUsingEncoding:NSUTF8StringEncoding];
OSStatus status = SecItemAdd((__bridge CFDictionaryRef)keychainItem, NULL);
if (status != noErr) {
[[ADJAdjustFactory logger] warn:@"Primary dedupe token unsuccessfully written"];
return NO;
} else {
NSString *persistedRandomToken = [ADJUtil getPersistedRandomToken];
if ([randomToken isEqualToString:persistedRandomToken]) {
[[ADJAdjustFactory logger] debug:@"Primary dedupe token successfully written"];
return YES;
} else {
return NO;
}
}
}

@end
4 changes: 2 additions & 2 deletions Adjust/Adjust.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Adjust.h
// Adjust SDK
//
// V4.29.2
// V4.29.3
// Created by Christian Wellenbrock (@wellle) on 23rd July 2013.
// Copyright (c) 2012-2021 Adjust GmbH. All rights reserved.
//
Expand Down Expand Up @@ -322,7 +322,7 @@ extern NSString * __nonnull const ADJDataResidencyUS;
/**
* Obtain singleton Adjust object.
*/
+ (nullable id)getInstance;
+ (nullable instancetype)getInstance;

- (void)appDidLaunch:(nullable ADJConfig *)adjustConfig;

Expand Down
4 changes: 2 additions & 2 deletions Adjust/Adjust.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ @implementation Adjust
static Adjust *defaultInstance = nil;
static dispatch_once_t onceToken = 0;

+ (id)getInstance {
+ (instancetype)getInstance {
dispatch_once(&onceToken, ^{
defaultInstance = [[self alloc] init];
});
return defaultInstance;
}

- (id)init {
- (instancetype)init {
self = [super init];
if (self == nil) {
return nil;
Expand Down
2 changes: 1 addition & 1 deletion AdjustBridge/AdjustBridgeRegister.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ + (NSString *)adjust_js {
if (this.sdkPrefix) {
return this.sdkPrefix;
} else {
return 'web-bridge4.29.2';
return 'web-bridge4.29.3';
}
},
setTestOptions: function(testOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
6F08421F2007769F00568A31 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1240;
LastUpgradeCheck = 1250;
ORGANIZATIONNAME = adjust;
TargetAttributes = {
6F0842262007769F00568A31 = {
Expand Down
Loading

0 comments on commit 14a6d8b

Please sign in to comment.