Skip to content

Commit 890402e

Browse files
committed
Merge pull request #165 from adjust/fixes
Fixes
2 parents b549f53 + cd79bcf commit 890402e

File tree

17 files changed

+306
-20
lines changed

17 files changed

+306
-20
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ Pods
2424

2525
# git files
2626
*.orig
27+
28+
# Adjust
29+
Frameworks

Adjust.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Pod::Spec.new do |s|
22
s.name = "Adjust"
3-
s.version = "4.5.3"
3+
s.version = "4.5.4"
44
s.summary = "This is the iOS SDK of adjust. You can read more about it at http://adjust.com."
55
s.homepage = "http://adjust.com"
66
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
77
s.author = { "Christian Wellenbrock" => "[email protected]" }
8-
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.5.3" }
8+
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.5.4" }
99
s.ios.deployment_target = '6.0'
1010
s.tvos.deployment_target = '9.0'
1111
s.framework = 'SystemConfiguration'

Adjust.xcodeproj/project.pbxproj

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@
660660
9DFA37A91C0F219400782607 /* Frameworks */,
661661
9DFA37AA1C0F219400782607 /* Headers */,
662662
9DFA37AB1C0F219400782607 /* Resources */,
663+
9DB1EE2C1C635DC0007FCFFC /* Copy Dynamic Framework */,
663664
);
664665
buildRules = (
665666
);
@@ -753,6 +754,20 @@
753754
/* End PBXResourcesBuildPhase section */
754755

755756
/* Begin PBXShellScriptBuildPhase section */
757+
9DB1EE2C1C635DC0007FCFFC /* Copy Dynamic Framework */ = {
758+
isa = PBXShellScriptBuildPhase;
759+
buildActionMask = 2147483647;
760+
files = (
761+
);
762+
inputPaths = (
763+
);
764+
name = "Copy Dynamic Framework";
765+
outputPaths = (
766+
);
767+
runOnlyForDeploymentPostprocessing = 0;
768+
shellPath = /bin/sh;
769+
shellScript = "set -e\n\n# If we're already inside this script then die\nif [ -n \"$RW_MULTIPLATFORM_BUILD_IN_PROGRESS\" ]; then\nexit 0\nfi\nexport RW_MULTIPLATFORM_BUILD_IN_PROGRESS=1\n\nRW_FRAMEWORK_NAME=${PROJECT_NAME}\nRW_FRAMEWORK_LOCATION=\"${BUILT_PRODUCTS_DIR}/${RW_FRAMEWORK_NAME}Sdk.framework\"\n\n# Copy the framework to the project directory\nditto \"${RW_FRAMEWORK_LOCATION}\" \"${SRCROOT}/Frameworks/Dynamic/${RW_FRAMEWORK_NAME}Sdk.framework\"";
770+
};
756771
9DE7C9011AE68F68001556E5 /* Build Framework */ = {
757772
isa = PBXShellScriptBuildPhase;
758773
buildActionMask = 2147483647;
@@ -779,7 +794,7 @@
779794
);
780795
runOnlyForDeploymentPostprocessing = 0;
781796
shellPath = /bin/sh;
782-
shellScript = "set -e\n\n# If we're already inside this script then die\nif [ -n \"$RW_MULTIPLATFORM_BUILD_IN_PROGRESS\" ]; then\nexit 0\nfi\nexport RW_MULTIPLATFORM_BUILD_IN_PROGRESS=1\n\nRW_FRAMEWORK_NAME=${PROJECT_NAME}\nRW_INPUT_STATIC_LIB=\"lib${PROJECT_NAME}.a\"\nRW_FRAMEWORK_LOCATION=\"${BUILT_PRODUCTS_DIR}/Static/${RW_FRAMEWORK_NAME}Sdk.framework\"\n\nfunction build_static_library {\n echo \"1\"\n echo \"${BUILD_DIR}\"\n # Will rebuild the static library as specified\n # build_static_library sdk\n xcrun xcodebuild -project \"${PROJECT_FILE_PATH}\" \\\n -target \"${TARGET_NAME}\" \\\n -configuration \"${CONFIGURATION}\" \\\n -sdk \"${1}\" \\\n ONLY_ACTIVE_ARCH=NO \\\n BUILD_DIR=\"${BUILD_DIR}\" \\\n OBJROOT=\"${OBJROOT}\" \\\n BUILD_ROOT=\"${BUILD_ROOT}\" \\\n SYMROOT=\"${SYMROOT}\" $ACTION\n}\n\nfunction make_fat_library {\n # Will smash 2 static libs together\n # make_fat_library in1 in2 out\n xcrun lipo -create \"${1}\" \"${2}\" -output \"${3}\"\n}\n\n# 1 - Extract the platform (iphoneos/iphonesimulator) from the SDK name\nif [[ \"$SDK_NAME\" =~ ([A-Za-z]+) ]]; then\nRW_SDK_PLATFORM=${BASH_REMATCH[1]}\nelse\necho \"Could not find platform name from SDK_NAME: $SDK_NAME\"\nexit 1\nfi\n\n# 2 - Extract the version from the SDK\nif [[ \"$SDK_NAME\" =~ ([0-9]+.*$) ]]; then\nRW_SDK_VERSION=${BASH_REMATCH[1]}\nelse\necho \"Could not find sdk version from SDK_NAME: $SDK_NAME\"\nexit 1\nfi\n\n# 3 - Determine the other platform\nif [ \"$RW_SDK_PLATFORM\" == \"iphoneos\" ]; then\nRW_OTHER_PLATFORM=iphonesimulator\nelse\nRW_OTHER_PLATFORM=iphoneos\nfi\n\n# 4 - Find the build directory\nif [[ \"$BUILT_PRODUCTS_DIR\" =~ (.*)$RW_SDK_PLATFORM$ ]]; then\nRW_OTHER_BUILT_PRODUCTS_DIR=\"${BASH_REMATCH[1]}${RW_OTHER_PLATFORM}\"\nelse\necho \"Could not find other platform build directory.\"\nexit 1\nfi\n\n# Build the other platform.\nbuild_static_library \"${RW_OTHER_PLATFORM}${RW_SDK_VERSION}\"\n\n# If we're currently building for iphonesimulator, then need to rebuild\n# to ensure that we get both i386 and x86_64\nif [ \"$RW_SDK_PLATFORM\" == \"iphonesimulator\" ]; then\nbuild_static_library \"${SDK_NAME}\"\nfi\n\n# Join the 2 static libs into 1 and push into the .framework\nmake_fat_library \"${BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}\" \\\n\"${RW_OTHER_BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}\" \\\n\"${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}Sdk\"\n\n# Ensure that the framework is present in both platform's build directories\ncp -a \"${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}Sdk\" \\\n\"${RW_OTHER_BUILT_PRODUCTS_DIR}/Static/${RW_FRAMEWORK_NAME}Sdk.framework/Versions/A/${RW_FRAMEWORK_NAME}Sdk\"";
797+
shellScript = "set -e\n\n# If we're already inside this script then die\nif [ -n \"$RW_MULTIPLATFORM_BUILD_IN_PROGRESS\" ]; then\nexit 0\nfi\nexport RW_MULTIPLATFORM_BUILD_IN_PROGRESS=1\n\nRW_FRAMEWORK_NAME=${PROJECT_NAME}\nRW_INPUT_STATIC_LIB=\"lib${PROJECT_NAME}.a\"\nRW_FRAMEWORK_LOCATION=\"${BUILT_PRODUCTS_DIR}/Static/${RW_FRAMEWORK_NAME}Sdk.framework\"\n\nfunction build_static_library {\n echo \"1\"\n echo \"${BUILD_DIR}\"\n # Will rebuild the static library as specified\n # build_static_library sdk\n xcrun xcodebuild -project \"${PROJECT_FILE_PATH}\" \\\n -target \"${TARGET_NAME}\" \\\n -configuration \"${CONFIGURATION}\" \\\n -sdk \"${1}\" \\\n ONLY_ACTIVE_ARCH=NO \\\n BUILD_DIR=\"${BUILD_DIR}\" \\\n OBJROOT=\"${OBJROOT}\" \\\n BUILD_ROOT=\"${BUILD_ROOT}\" \\\n SYMROOT=\"${SYMROOT}\" $ACTION\n}\n\nfunction make_fat_library {\n # Will smash 2 static libs together\n # make_fat_library in1 in2 out\n xcrun lipo -create \"${1}\" \"${2}\" -output \"${3}\"\n}\n\n# 1 - Extract the platform (iphoneos/iphonesimulator) from the SDK name\nif [[ \"$SDK_NAME\" =~ ([A-Za-z]+) ]]; then\nRW_SDK_PLATFORM=${BASH_REMATCH[1]}\nelse\necho \"Could not find platform name from SDK_NAME: $SDK_NAME\"\nexit 1\nfi\n\n# 2 - Extract the version from the SDK\nif [[ \"$SDK_NAME\" =~ ([0-9]+.*$) ]]; then\nRW_SDK_VERSION=${BASH_REMATCH[1]}\nelse\necho \"Could not find sdk version from SDK_NAME: $SDK_NAME\"\nexit 1\nfi\n\n# 3 - Determine the other platform\nif [ \"$RW_SDK_PLATFORM\" == \"iphoneos\" ]; then\nRW_OTHER_PLATFORM=iphonesimulator\nelse\nRW_OTHER_PLATFORM=iphoneos\nfi\n\n# 4 - Find the build directory\nif [[ \"$BUILT_PRODUCTS_DIR\" =~ (.*)$RW_SDK_PLATFORM$ ]]; then\nRW_OTHER_BUILT_PRODUCTS_DIR=\"${BASH_REMATCH[1]}${RW_OTHER_PLATFORM}\"\nelse\necho \"Could not find other platform build directory.\"\nexit 1\nfi\n\n# Build the other platform.\nbuild_static_library \"${RW_OTHER_PLATFORM}${RW_SDK_VERSION}\"\n\n# If we're currently building for iphonesimulator, then need to rebuild\n# to ensure that we get both i386 and x86_64\nif [ \"$RW_SDK_PLATFORM\" == \"iphonesimulator\" ]; then\nbuild_static_library \"${SDK_NAME}\"\nfi\n\n# Join the 2 static libs into 1 and push into the .framework\nmake_fat_library \"${BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}\" \\\n\"${RW_OTHER_BUILT_PRODUCTS_DIR}/${RW_INPUT_STATIC_LIB}\" \\\n\"${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}Sdk\"\n\n# Ensure that the framework is present in both platform's build directories\ncp -a \"${RW_FRAMEWORK_LOCATION}/Versions/A/${RW_FRAMEWORK_NAME}Sdk\" \\\n\"${RW_OTHER_BUILT_PRODUCTS_DIR}/Static/${RW_FRAMEWORK_NAME}Sdk.framework/Versions/A/${RW_FRAMEWORK_NAME}Sdk\"\n\n# Copy the framework to the project directory\nditto \"${RW_FRAMEWORK_LOCATION}\" \"${SRCROOT}/Frameworks/Static/${RW_FRAMEWORK_NAME}Sdk.framework\"";
783798
};
784799
/* End PBXShellScriptBuildPhase section */
785800

@@ -950,6 +965,7 @@
950965
COPY_PHASE_STRIP = NO;
951966
ENABLE_NS_ASSERTIONS = NO;
952967
GCC_C_LANGUAGE_STANDARD = gnu99;
968+
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
953969
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
954970
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
955971
GCC_WARN_UNDECLARED_SELECTOR = YES;

Adjust/ADJConfig.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
* You can increase or reduce the amount of logs from Adjust by passing
5353
* one of the following parameters. Use Log.ASSERT to disable all logging.
5454
*
55-
* @param logLevel The desired minimum log level (default: info)
55+
* @var logLevel The desired minimum log level (default: info)
5656
* Must be one of the following:
5757
* - ADJLogLevelVerbose (enable all logging)
5858
* - ADJLogLevelDebug (enable more logging)
@@ -68,7 +68,7 @@
6868
* When enabled, events get buffered and only get tracked each
6969
* minute. Buffered events are still persisted, of course.
7070
*
71-
* @param eventBufferingEnabled Enable or disable event buffering
71+
* @var eventBufferingEnabled Enable or disable event buffering
7272
*/
7373
@property (nonatomic, assign) BOOL eventBufferingEnabled;
7474

@@ -77,7 +77,7 @@
7777
*
7878
* See the AdjustDelegate declaration above for details
7979
*
80-
* @param delegate The delegate that might implement the optional delegate
80+
* @var delegate The delegate that might implement the optional delegate
8181
* methods like adjustAttributionChanged:
8282
*/
8383
@property (nonatomic, weak) NSObject<AdjustDelegate> *delegate;

Adjust/ADJEvent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* Create Event object with Event Token.
2424
*
25-
* @param event Event token that is created in the dashboard
25+
* @param eventToken Event token that is created in the dashboard
2626
* at http://adjust.com and should be six characters long.
2727
*/
2828
+ (ADJEvent *)eventWithEventToken:(NSString *)eventToken;

Adjust/ADJEvent.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ - (BOOL) checkRevenue:(NSNumber*) revenue
135135
return NO;
136136
}
137137
} else {
138-
if (![ADJUtil isNull:currency]) {
138+
if ([ADJUtil isNotNull:currency]) {
139139
[self.logger error:@"Revenue must be set with currency"];
140140
return NO;
141141
}
@@ -159,7 +159,7 @@ - (void) setReceipt:(NSData *)receipt transactionId:(NSString *)transactionId {
159159
}
160160

161161
- (BOOL) checkReceipt:(NSData *)receipt transactionId:(NSString *)transactionId {
162-
if (![ADJUtil isNull:receipt] && [ADJUtil isNull:transactionId]) {
162+
if ([ADJUtil isNotNull:receipt] && [ADJUtil isNull:transactionId]) {
163163
[self.logger error:@"Missing transactionId"];
164164
return NO;
165165
}

Adjust/ADJUtil.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
+ (NSString *) queryString:(NSDictionary *)parameters;
3232
+ (BOOL)isNull:(id)value;
33+
+ (BOOL)isNotNull:(id)value;
3334
+ (void)sendRequest:(NSMutableURLRequest *)request
3435
prefixErrorMessage:(NSString *)prefixErrorMessage
3536
jsonResponseHandler:(void (^) (NSDictionary * jsonDict))jsonResponseHandler;
@@ -40,4 +41,8 @@ jsonResponseHandler:(void (^) (NSDictionary * jsonDict))jsonResponseHandler;
4041
jsonResponseHandler:(void (^) (NSDictionary * jsonDict))jsonResponseHandler;
4142

4243
+ (NSDictionary *)convertDictionaryValues:(NSDictionary *)dictionary;
44+
45+
+ (NSURL*)convertUniversalLink:(NSURL *)url scheme:(NSString *)scheme;
46+
+ (NSString*)idfa;
47+
4348
@end

Adjust/ADJUtil.m

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515

1616
#include <sys/xattr.h>
1717

18-
static NSString * const kBaseUrl = @"https://app.adjust.com";
19-
static NSString * const kClientSdk = @"ios4.5.3";
20-
21-
static NSString * const kDateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'Z";
2218
static NSDateFormatter *dateFormat;
2319

20+
static NSString * const kClientSdk = @"ios4.5.4";
21+
static NSString * const kDefaultScheme = @"AdjustUniversalScheme";
22+
static NSString * const kUniversalLinkPattern = @"https://[^.]*\\.ulink\\.adjust\\.com/ulink/?(.*)";
23+
static NSString * const kBaseUrl = @"https://app.adjust.com";
24+
static NSString * const kDateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'Z";
25+
static NSRegularExpression * universalLinkRegex = nil;
26+
2427
#pragma mark -
2528
@implementation ADJUtil
2629

@@ -201,6 +204,10 @@ + (BOOL)isNull:(id)value {
201204
return value == nil || value == (id)[NSNull null];
202205
}
203206

207+
+ (BOOL)isNotNull:(id)value {
208+
return value != nil && value != (id)[NSNull null];
209+
}
210+
204211
+ (NSString *)formatErrorMessage:(NSString *)prefixErrorMessage
205212
systemErrorMessage:(NSString *)systemErrorMessage
206213
suffixErrorMessage:(NSString *)suffixErrorMessage
@@ -354,4 +361,80 @@ + (NSDictionary *)convertDictionaryValues:(NSDictionary *)dictionary
354361

355362
return convertedDictionary;
356363
}
364+
365+
+ (NSString *)idfa {
366+
return [[UIDevice currentDevice] adjIdForAdvertisers];
367+
}
368+
369+
+ (NSURL *)convertUniversalLink:(NSURL *)url scheme:(NSString *)scheme {
370+
id<ADJLogger> logger = ADJAdjustFactory.logger;
371+
372+
if ([ADJUtil isNull:scheme] || [scheme length] == 0) {
373+
[logger warn:@"Non-empty scheme required, using the scheme \"AdjustUniversalScheme\""];
374+
scheme = kDefaultScheme;
375+
}
376+
377+
if ([ADJUtil isNull:url]) {
378+
[logger error:@"Received universal link is nil"];
379+
return nil;
380+
}
381+
382+
NSString *urlString = [url absoluteString];
383+
384+
if ([ADJUtil isNull:urlString]) {
385+
[logger error:@"Parsed universal link is nil"];
386+
return nil;
387+
}
388+
389+
if (universalLinkRegex == nil) {
390+
NSError *error = NULL;
391+
392+
NSRegularExpression *regex = [NSRegularExpression
393+
regularExpressionWithPattern:kUniversalLinkPattern
394+
options:NSRegularExpressionCaseInsensitive
395+
error:&error];
396+
397+
if ([ADJUtil isNotNull:error]) {
398+
[logger error:@"Universal link regex rule error (%@)", [error description]];
399+
return nil;
400+
}
401+
402+
universalLinkRegex = regex;
403+
}
404+
405+
NSArray<NSTextCheckingResult *> *matches = [universalLinkRegex matchesInString:urlString options:0 range:NSMakeRange(0, [urlString length])];
406+
407+
if ([matches count] == 0) {
408+
[logger error:@"Url doesn't match as universal link with format https://[hash].ulink.adjust.com/ulink/..."];
409+
return nil;
410+
}
411+
412+
if ([matches count] > 1) {
413+
[logger error:@"Url match as universal link multiple times"];
414+
return nil;
415+
}
416+
417+
NSTextCheckingResult *match = matches[0];
418+
419+
if ([match numberOfRanges] != 2) {
420+
[logger error:@"Wrong number of ranges matched"];
421+
return nil;
422+
}
423+
424+
NSString *tailSubString = [urlString substringWithRange:[match rangeAtIndex:1]];
425+
426+
NSString *extractedUrlString = [NSString stringWithFormat:@"%@://%@", scheme, tailSubString];
427+
428+
[logger info:@"Converted deeplink from universal link %@", extractedUrlString];
429+
430+
NSURL *extractedUrl = [NSURL URLWithString:extractedUrlString];
431+
432+
if ([ADJUtil isNull:extractedUrl]) {
433+
[logger error:@"Unable to parse converted deeplink from universal link %@", extractedUrlString];
434+
return nil;
435+
}
436+
437+
return extractedUrl;
438+
}
439+
357440
@end

Adjust/Adjust.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ extern NSString * const ADJEnvironmentProduction;
9595
*/
9696
+ (void)setOfflineMode:(BOOL)enabled;
9797

98+
/**
99+
* Convert a universal link style url to a deeplink style url with the corresponding scheme
100+
*/
101+
+ (NSURL*)convertUniversalLink:(NSURL *)url scheme:(NSString *)scheme;
102+
98103
+ (NSString*)idfa;
99104

100105
/**
@@ -111,6 +116,8 @@ extern NSString * const ADJEnvironmentProduction;
111116
- (void)appWillOpenUrl:(NSURL *)url;
112117
- (void)setDeviceToken:(NSData *)deviceToken;
113118
- (void)setOfflineMode:(BOOL)enabled;
119+
- (NSURL*)convertUniversalLink:(NSURL *)url scheme:(NSString *)scheme;
120+
- (NSString*)idfa;
114121

115122
@end
116123

Adjust/Adjust.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "ADJActivityHandler.h"
1111
#import "ADJAdjustFactory.h"
1212
#import "ADJLogger.h"
13-
#import "UIDevice+ADJAdditions.h"
13+
#import "ADJUtil.h"
1414

1515
#if !__has_feature(objc_arc)
1616
#error Adjust requires ARC
@@ -66,7 +66,11 @@ + (void)setOfflineMode:(BOOL)enabled {
6666
}
6767

6868
+ (NSString*)idfa {
69-
return [[UIDevice currentDevice] adjIdForAdvertisers];
69+
return [[Adjust getInstance] idfa];
70+
}
71+
72+
+ (NSURL*)convertUniversalLink:(NSURL *)url scheme:(NSString *)scheme {
73+
return [[Adjust getInstance] convertUniversalLink:url scheme:scheme];
7074
}
7175

7276
+ (id)getInstance {
@@ -139,7 +143,11 @@ - (void)setOfflineMode:(BOOL)enabled {
139143
}
140144

141145
- (NSString*)idfa {
142-
return [[UIDevice currentDevice] adjIdForAdvertisers];
146+
return [ADJUtil idfa];
147+
}
148+
149+
- (NSURL*)convertUniversalLink:(NSURL *)url scheme:(NSString *)scheme {
150+
return [ADJUtil convertUniversalLink:url scheme:scheme];
143151
}
144152

145153
#pragma mark - private

0 commit comments

Comments
 (0)