Skip to content

Commit 9369031

Browse files
committed
Merge pull request #11 from adjust/development
Update iOS version to v3.3.1
2 parents d12052d + 510a22d commit 9369031

16 files changed

+133
-19
lines changed

Adjust.unitypackage

-2.29 MB
Binary file not shown.

Adjust_v3.2.2.unitypackage

2.31 MB
Binary file not shown.

Assets/Adjust.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Adjust : MonoBehaviour {
1414
public Util.Environment environment = Util.Environment.Sandbox;
1515
public bool eventBuffering = false;
1616
public bool startManually = false;
17-
public const string sdkPrefix = "unity3.2.1";
17+
public const string sdkPrefix = "unity3.2.2";
1818

1919
void Awake() {
2020
if (!this.startManually) {

Assets/Plugins/iOS/AIActivityHandler.h

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- (void)finishedTrackingWithResponse:(AIResponseData *)response;
3333
- (void)setEnabled:(BOOL)enabled;
3434
- (BOOL)isEnabled;
35+
- (void)readOpenUrl:(NSURL*)url;
3536

3637
@end
3738

Assets/Plugins/iOS/AIActivityHandler.m

+60-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@
1717
#import "UIDevice+AIAdditions.h"
1818
#import "NSString+AIAdditions.h"
1919
#import "AIAdjustFactory.h"
20+
#if !ADJUST_NO_IDA
21+
#import <iAd/iAd.h>
22+
#endif
2023

2124
static NSString * const kActivityStateFilename = @"AdjustIoActivityState";
25+
static NSString * const kAdjustPrefix = @"adjust_";
2226
static const char * const kInternalQueueName = "io.adjust.ActivityQueue";
2327

24-
static const uint64_t kTimerInterval = 60 * NSEC_PER_SEC; // 1 minute
25-
static const uint64_t kTimerLeeway = 1 * NSEC_PER_SEC; // 1 second
28+
static const uint64_t kTimerInterval = 60 * NSEC_PER_SEC; // 1 minute
29+
static const uint64_t kTimerLeeway = 1 * NSEC_PER_SEC; // 1 second
2630

2731

2832
#pragma mark -
@@ -43,6 +47,8 @@ @interface AIActivityHandler()
4347
@property (nonatomic, copy) NSString *clientSdk;
4448
@property (nonatomic, assign) BOOL trackingEnabled;
4549
@property (nonatomic, assign) BOOL internalEnabled;
50+
@property (nonatomic, assign) BOOL isIad;
51+
@property (nonatomic, copy) NSString *vendorId;
4652

4753
@end
4854

@@ -141,6 +147,12 @@ - (BOOL)isEnabled {
141147
}
142148
}
143149

150+
- (void)readOpenUrl:(NSURL*)url {
151+
dispatch_async(self.internalQueue, ^{
152+
[self readOpenUrlInternal:url];
153+
});
154+
}
155+
144156
#pragma mark - internal
145157
- (void)initInternal:(NSString *)yourAppToken {
146158
if (![self checkAppTokenNotNil:yourAppToken]) return;
@@ -156,6 +168,15 @@ - (void)initInternal:(NSString *)yourAppToken {
156168
self.idForAdvertisers = UIDevice.currentDevice.aiIdForAdvertisers;
157169
self.fbAttributionId = UIDevice.currentDevice.aiFbAttributionId;
158170
self.userAgent = AIUtil.userAgent;
171+
self.vendorId = UIDevice.currentDevice.aiVendorId;
172+
173+
#if !ADJUST_NO_IDA
174+
if (NSClassFromString(@"ADClient")) {
175+
[ADClient.sharedClient determineAppInstallationAttributionWithCompletionHandler:^(BOOL appInstallationWasAttributedToiAd) {
176+
self.isIad = appInstallationWasAttributedToiAd;
177+
}];
178+
}
179+
#endif
159180

160181
self.packageHandler = [AIAdjustFactory packageHandlerForActivityHandler:self];
161182
[self readActivityState];
@@ -309,6 +330,40 @@ - (void)revenueInternal:(double)amount
309330
[self.logger debug:@"Event %d (revenue)", self.activityState.eventCount];
310331
}
311332

333+
- (void) readOpenUrlInternal:(NSURL *)url {
334+
NSArray* queryArray = [url.query componentsSeparatedByString:@"&"];
335+
NSMutableDictionary* adjustDeepLinks = [NSMutableDictionary dictionary];
336+
337+
for (NSString* fieldValuePair in queryArray) {
338+
NSArray* pairComponents = [fieldValuePair componentsSeparatedByString:@"="];
339+
if (pairComponents.count != 2) continue;
340+
341+
NSString* key = [pairComponents objectAtIndex:0];
342+
if (![key hasPrefix:kAdjustPrefix]) continue;
343+
344+
NSString* value = [pairComponents objectAtIndex:1];
345+
if (value.length == 0) continue;
346+
347+
NSString* keyWOutPrefix = [key substringFromIndex:kAdjustPrefix.length];
348+
if (keyWOutPrefix.length == 0) continue;
349+
350+
[adjustDeepLinks setObject:value forKey:keyWOutPrefix];
351+
}
352+
353+
if (adjustDeepLinks.count == 0) {
354+
return;
355+
}
356+
357+
AIPackageBuilder *reattributionBuilder = [[AIPackageBuilder alloc] init];
358+
reattributionBuilder.deeplinkParameters = adjustDeepLinks;
359+
[self injectGeneralAttributes:reattributionBuilder];
360+
AIActivityPackage *reattributionPackage = [reattributionBuilder buildReattributionPackage];
361+
[self.packageHandler addPackage:reattributionPackage];
362+
[self.packageHandler sendFirstPackage];
363+
364+
[self.logger debug:@"Reattribution %@", adjustDeepLinks];
365+
}
366+
312367
#pragma mark - private
313368

314369
// returns whether or not the activity state should be written
@@ -358,7 +413,7 @@ - (void)writeActivityState {
358413
BOOL result = [NSKeyedArchiver archiveRootObject:self.activityState toFile:filename];
359414
if (result == YES) {
360415
[AIUtil excludeFromBackup:filename];
361-
[self.logger verbose:@"Wrote activity state: %@", self.activityState];
416+
[self.logger debug:@"Wrote activity state: %@", self.activityState];
362417
} else {
363418
[self.logger error:@"Failed to write activity state"];
364419
}
@@ -389,6 +444,8 @@ - (void)injectGeneralAttributes:(AIPackageBuilder *)builder {
389444
builder.idForAdvertisers = self.idForAdvertisers;
390445
builder.fbAttributionId = self.fbAttributionId;
391446
builder.environment = self.environment;
447+
builder.isIad = self.isIad;
448+
builder.vendorId = self.vendorId;
392449

393450
if (self.trackMacMd5) {
394451
builder.macShortMd5 = self.macShortMd5;

Assets/Plugins/iOS/AIActivityKind.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
#import <Foundation/Foundation.h>
1010

1111
typedef enum {
12-
AIActivityKindUnknown = 0,
13-
AIActivityKindSession = 1,
14-
AIActivityKindEvent = 2,
15-
AIActivityKindRevenue = 3,
12+
AIActivityKindUnknown = 0,
13+
AIActivityKindSession = 1,
14+
AIActivityKindEvent = 2,
15+
AIActivityKindRevenue = 3,
16+
AIActivityKindReattribution = 4,
1617
} AIActivityKind;
1718

1819
AIActivityKind AIActivityKindFromString(NSString *string);

Assets/Plugins/iOS/AIActivityKind.m

+7-4
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@ AIActivityKind AIActivityKindFromString(NSString *string) {
1515
return AIActivityKindEvent;
1616
} else if ([@"revenue" isEqualToString:string]) {
1717
return AIActivityKindRevenue;
18+
} else if ([@"reattribution" isEqualToString:string]) {
19+
return AIActivityKindReattribution;
1820
} else {
1921
return AIActivityKindUnknown;
2022
}
2123
}
2224

2325
NSString* AIActivityKindToString(AIActivityKind activityKind) {
2426
switch (activityKind) {
25-
case AIActivityKindSession: return @"session";
26-
case AIActivityKindEvent: return @"event";
27-
case AIActivityKindRevenue: return @"revenue";
28-
case AIActivityKindUnknown: return @"unknown";
27+
case AIActivityKindSession: return @"session";
28+
case AIActivityKindEvent: return @"event";
29+
case AIActivityKindRevenue: return @"revenue";
30+
case AIActivityKindReattribution: return @"reattribution";
31+
case AIActivityKindUnknown: return @"unknown";
2932
}
3033
}

Assets/Plugins/iOS/AIPackageBuilder.h

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
@property (nonatomic, copy) NSString *clientSdk;
2323
@property (nonatomic, copy) NSString *uuid;
2424
@property (nonatomic, assign) BOOL trackingEnabled;
25+
@property (nonatomic, assign) BOOL isIad;
26+
@property (nonatomic, copy) NSString *vendorId;
2527

2628
// sessions
2729
@property (nonatomic, assign) int sessionCount;
@@ -37,8 +39,13 @@
3739
@property (nonatomic, copy) NSDictionary *callbackParameters;
3840
@property (nonatomic, assign) double amountInCents;
3941

42+
// reattributions
43+
@property (nonatomic, copy) NSDictionary* deeplinkParameters;
44+
45+
4046
- (AIActivityPackage *)buildSessionPackage;
4147
- (AIActivityPackage *)buildEventPackage;
4248
- (AIActivityPackage *)buildRevenuePackage;
49+
- (AIActivityPackage *)buildReattributionPackage;
4350

4451
@end

Assets/Plugins/iOS/AIPackageBuilder.m

+34-4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ - (AIActivityPackage *)buildRevenuePackage {
5454
return revenuePackage;
5555
}
5656

57+
- (AIActivityPackage *)buildReattributionPackage {
58+
NSMutableDictionary *parameters = [self defaultParameters];
59+
[self parameters:parameters setDictionaryJson:self.deeplinkParameters forKey:@"deeplink_parameters"];
60+
61+
AIActivityPackage *reattributionPackage = [self defaultActivityPackage];
62+
reattributionPackage.path = @"/reattribute";
63+
reattributionPackage.activityKind = AIActivityKindReattribution;
64+
reattributionPackage.suffix = @"";
65+
reattributionPackage.parameters = parameters;
66+
67+
return reattributionPackage;
68+
}
69+
5770
#pragma mark private
5871
- (AIActivityPackage *)defaultActivityPackage {
5972
AIActivityPackage *activityPackage = [[AIActivityPackage alloc] init];
@@ -75,6 +88,8 @@ - (NSMutableDictionary *)defaultParameters {
7588
[self parameters:parameters setString:self.fbAttributionId forKey:@"fb_id"];
7689
[self parameters:parameters setString:self.environment forKey:@"environment"];
7790
[self parameters:parameters setInt:self.trackingEnabled forKey:@"tracking_enabled"];
91+
[self parameters:parameters setBool:self.isIad forKey:@"is_iad"];
92+
[self parameters:parameters setString:self.vendorId forKey:@"idfv"];
7893

7994
// session related (used for events as well)
8095
[self parameters:parameters setInt:self.sessionCount forKey:@"session_count"];
@@ -87,9 +102,9 @@ - (NSMutableDictionary *)defaultParameters {
87102

88103
- (void)injectEventParameters:(NSMutableDictionary *)parameters {
89104
// event specific
90-
[self parameters:parameters setInt:self.eventCount forKey:@"event_count"];
91-
[self parameters:parameters setString:self.eventToken forKey:@"event_token"];
92-
[self parameters:parameters setDictionary:self.callbackParameters forKey:@"params"];
105+
[self parameters:parameters setInt:self.eventCount forKey:@"event_count"];
106+
[self parameters:parameters setString:self.eventToken forKey:@"event_token"];
107+
[self parameters:parameters setDictionaryBase64:self.callbackParameters forKey:@"params"];
93108
}
94109

95110
- (NSString *)amountString {
@@ -138,13 +153,28 @@ - (void)parameters:(NSMutableDictionary *)parameters setDuration:(double)value f
138153
[self parameters:parameters setInt:intValue forKey:key];
139154
}
140155

141-
- (void)parameters:(NSMutableDictionary *)parameters setDictionary:(NSDictionary *)dictionary forKey:(NSString *)key {
156+
- (void)parameters:(NSMutableDictionary *)parameters setDictionaryBase64:(NSDictionary *)dictionary forKey:(NSString *)key {
142157
if (dictionary == nil) return;
143158

144159
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil];
145160
NSString *dictionaryString = jsonData.aiEncodeBase64;
146161
[self parameters:parameters setString:dictionaryString forKey:key];
147162
}
148163

164+
- (void)parameters:(NSMutableDictionary *)parameters setDictionaryJson:(NSDictionary *)dictionary forKey:(NSString *)key {
165+
if (dictionary == nil) return;
166+
167+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil];
168+
NSString *dictionaryString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
169+
[self parameters:parameters setString:dictionaryString forKey:key];
170+
}
171+
172+
- (void)parameters:(NSMutableDictionary *)parameters setBool:(BOOL)value forKey:(NSString *)key {
173+
if (value < 0) return;
174+
175+
int valueInt = [[NSNumber numberWithBool:value] intValue];
176+
177+
[self parameters:parameters setInt:valueInt forKey:key];
178+
}
149179
@end
150180

Assets/Plugins/iOS/AIUtil.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <sys/xattr.h>
1515

1616
static NSString * const kBaseUrl = @"https://app.adjust.io";
17-
static NSString * const kClientSdk = @"ios3.2.1";
17+
static NSString * const kClientSdk = @"ios3.3.1";
1818

1919
static NSString * const kDateFormat = @"yyyy-MM-dd'T'HH:mm:ss'Z'Z";
2020
static NSDateFormatter * dateFormat;

Assets/Plugins/iOS/Adjust.h

+5
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ static NSString * const AIEnvironmentProduction = @"production";
164164
*/
165165
+ (BOOL)isEnabled;
166166

167+
/**
168+
* Read the URL that opened the application to search for
169+
* an adjust deep link
170+
*/
171+
+ (void)appWillOpenUrl:(NSURL *)url;
167172
@end
168173

169174

Assets/Plugins/iOS/Adjust.m

+4
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,8 @@ + (BOOL)isEnabled {
132132
return [activityHandler isEnabled];
133133
}
134134

135+
+ (void)appWillOpenUrl:(NSURL *)url {
136+
[activityHandler readOpenUrl:url];
137+
}
138+
135139
@end

Assets/Plugins/iOS/UIDevice+AIAdditions.h

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
- (NSString *)aiDeviceType;
1818
- (NSString *)aiDeviceName;
1919
- (NSString *)aiCreateUuid;
20+
- (NSString *)aiVendorId;
2021

2122
@end

Assets/Plugins/iOS/UIDevice+AIAdditions.m

+5
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,9 @@ - (NSString *)aiCreateUuid {
158158
return lowerUuid;
159159
}
160160

161+
- (NSString *)aiVendorId {
162+
NSString * vendorId = [UIDevice.currentDevice.identifierForVendor UUIDString];
163+
return vendorId;
164+
}
165+
161166
@end

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.1
1+
3.2.2

0 commit comments

Comments
 (0)