Skip to content

Commit d4da56c

Browse files
authored
Merge pull request #97 from adjust/v4110
Version 4.11.0
2 parents 1b0016f + fdf65df commit d4da56c

26 files changed

+387
-275
lines changed

Assets/Adjust/Adjust.cs

+29-7
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,24 @@ public static void resetSessionCallbackParameters() {
253253
return;
254254
#endif
255255
}
256+
257+
public static string getAdid() {
258+
if (Adjust.instance == null) {
259+
Debug.Log(Adjust.errorMessage);
260+
return null;
261+
}
262+
263+
return Adjust.instance.getAdid();
264+
}
265+
266+
public static AdjustAttribution getAttribution() {
267+
if (Adjust.instance == null) {
268+
Debug.Log(Adjust.errorMessage);
269+
return null;
270+
}
271+
272+
return Adjust.instance.getAttribution();
273+
}
256274

257275
// iOS specific methods
258276
public static void setDeviceToken(string deviceToken) {
@@ -390,31 +408,35 @@ private void AttributionChangedCallback(AdjustAttribution attributionData) {
390408
Debug.Log("Attribution changed!");
391409

392410
if (attributionData.trackerName != null) {
393-
Debug.Log("trackerName " + attributionData.trackerName);
411+
Debug.Log("Tracker name: " + attributionData.trackerName);
394412
}
395413

396414
if (attributionData.trackerToken != null) {
397-
Debug.Log("trackerToken " + attributionData.trackerToken);
415+
Debug.Log("Tracker token: " + attributionData.trackerToken);
398416
}
399417

400418
if (attributionData.network != null) {
401-
Debug.Log("network " + attributionData.network);
419+
Debug.Log("Network: " + attributionData.network);
402420
}
403421

404422
if (attributionData.campaign != null) {
405-
Debug.Log("campaign " + attributionData.campaign);
423+
Debug.Log("Campaign: " + attributionData.campaign);
406424
}
407425

408426
if (attributionData.adgroup != null) {
409-
Debug.Log("adgroup " + attributionData.adgroup);
427+
Debug.Log("Adgroup: " + attributionData.adgroup);
410428
}
411429

412430
if (attributionData.creative != null) {
413-
Debug.Log("creative " + attributionData.creative);
431+
Debug.Log("Creative: " + attributionData.creative);
414432
}
415433

416434
if (attributionData.clickLabel != null) {
417-
Debug.Log("clickLabel" + attributionData.clickLabel);
435+
Debug.Log("Click label: " + attributionData.clickLabel);
436+
}
437+
438+
if (attributionData.adid != null) {
439+
Debug.Log("ADID: " + attributionData.adid);
418440
}
419441
}
420442

Assets/Adjust/Android/AdjustAndroid.cs

+31-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace com.adjust.sdk {
88
#if UNITY_ANDROID
99
public class AdjustAndroid : IAdjust {
1010
#region Fields
11-
private const string sdkPrefix = "unity4.10.3";
11+
private const string sdkPrefix = "unity4.11.0";
1212

1313
private static bool launchDeferredDeeplink = true;
1414

@@ -199,6 +199,35 @@ public void setDeviceToken(string deviceToken) {
199199
ajcAdjust.CallStatic("setPushToken", deviceToken);
200200
}
201201

202+
public string getAdid() {
203+
return ajcAdjust.CallStatic<string>("getAdid");
204+
}
205+
206+
public AdjustAttribution getAttribution() {
207+
try {
208+
AndroidJavaObject ajoAttribution = ajcAdjust.CallStatic<AndroidJavaObject>("getAttribution");
209+
210+
if (null == ajoAttribution) {
211+
return null;
212+
}
213+
214+
AdjustAttribution adjustAttribution = new AdjustAttribution();
215+
216+
adjustAttribution.trackerName = ajoAttribution.Get<string>(AdjustUtils.KeyTrackerName);
217+
adjustAttribution.trackerToken = ajoAttribution.Get<string>(AdjustUtils.KeyTrackerToken);
218+
adjustAttribution.network = ajoAttribution.Get<string>(AdjustUtils.KeyNetwork);
219+
adjustAttribution.campaign = ajoAttribution.Get<string>(AdjustUtils.KeyCampaign);
220+
adjustAttribution.adgroup = ajoAttribution.Get<string>(AdjustUtils.KeyAdgroup);
221+
adjustAttribution.creative = ajoAttribution.Get<string>(AdjustUtils.KeyCreative);
222+
adjustAttribution.clickLabel = ajoAttribution.Get<string>(AdjustUtils.KeyClickLabel);
223+
adjustAttribution.adid = ajoAttribution.Get<string>(AdjustUtils.KeyAdid);
224+
225+
return adjustAttribution;
226+
} catch (Exception) {}
227+
228+
return null;
229+
}
230+
202231
public static void addSessionPartnerParameter(string key, string value) {
203232
if (ajcAdjust == null) {
204233
ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust");
@@ -293,6 +322,7 @@ public void onAttributionChanged(AndroidJavaObject attribution) {
293322
adjustAttribution.adgroup = attribution.Get<string>(AdjustUtils.KeyAdgroup);
294323
adjustAttribution.creative = attribution.Get<string>(AdjustUtils.KeyCreative);
295324
adjustAttribution.clickLabel = attribution.Get<string>(AdjustUtils.KeyClickLabel);
325+
adjustAttribution.adid = attribution.Get<string>(AdjustUtils.KeyAdid);
296326

297327
callback(adjustAttribution);
298328
}
1.4 KB
Binary file not shown.

Assets/Adjust/ExampleGUI/ExampleGUI.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -121,31 +121,35 @@ public void AttributionChangedCallback(AdjustAttribution attributionData) {
121121
Debug.Log("Attribution changed!");
122122

123123
if (attributionData.trackerName != null) {
124-
Debug.Log("Tracker name " + attributionData.trackerName);
124+
Debug.Log("Tracker name: " + attributionData.trackerName);
125125
}
126126

127127
if (attributionData.trackerToken != null) {
128-
Debug.Log("Tracker token " + attributionData.trackerToken);
128+
Debug.Log("Tracker token: " + attributionData.trackerToken);
129129
}
130130

131131
if (attributionData.network != null) {
132-
Debug.Log("Network " + attributionData.network);
132+
Debug.Log("Network: " + attributionData.network);
133133
}
134134

135135
if (attributionData.campaign != null) {
136-
Debug.Log("Campaign " + attributionData.campaign);
136+
Debug.Log("Campaign: " + attributionData.campaign);
137137
}
138138

139139
if (attributionData.adgroup != null) {
140-
Debug.Log("Adgroup " + attributionData.adgroup);
140+
Debug.Log("Adgroup: " + attributionData.adgroup);
141141
}
142142

143143
if (attributionData.creative != null) {
144-
Debug.Log("Creative " + attributionData.creative);
144+
Debug.Log("Creative: " + attributionData.creative);
145145
}
146146

147147
if (attributionData.clickLabel != null) {
148-
Debug.Log("Click label " + attributionData.clickLabel);
148+
Debug.Log("Click label: " + attributionData.clickLabel);
149+
}
150+
151+
if (attributionData.adid != null) {
152+
Debug.Log("ADID: " + attributionData.adid);
149153
}
150154
}
151155

Assets/Adjust/Metro/AdjustMetro.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@
88

99
namespace com.adjust.sdk {
1010
public class AdjustMetro : IAdjust {
11-
private const string sdkPrefix = "unity4.10.3";
11+
private const string sdkPrefix = "unity4.11.0";
1212

1313
public bool isEnabled() {
1414
return AdjustWS.IsEnabled();
1515
}
1616

17+
public string getAdid() {
18+
return null;
19+
}
20+
21+
public AdjustAttribution getAttribution() {
22+
return null;
23+
}
24+
1725
public void onPause() {
1826
AdjustWS.ApplicationDeactivated();
1927
}

Assets/Adjust/Unity/AdjustAttribution.cs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace com.adjust.sdk {
55
public class AdjustAttribution {
66
#region Properties
7+
public string adid {get; set; }
78
public string network { get; set; }
89
public string adgroup { get; set; }
910
public string campaign { get; set; }
@@ -30,6 +31,7 @@ public AdjustAttribution(string jsonString) {
3031
adgroup = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyAdgroup);
3132
creative = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCreative);
3233
clickLabel = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyClickLabel);
34+
adid = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyAdid);
3335
}
3436

3537
public AdjustAttribution(Dictionary<string, string> dicAttributionData) {
@@ -44,6 +46,7 @@ public AdjustAttribution(Dictionary<string, string> dicAttributionData) {
4446
adgroup = TryGetValue(dicAttributionData, AdjustUtils.KeyAdgroup);
4547
creative = TryGetValue(dicAttributionData, AdjustUtils.KeyCreative);
4648
clickLabel = TryGetValue(dicAttributionData, AdjustUtils.KeyClickLabel);
49+
adid = TryGetValue(dicAttributionData, AdjustUtils.KeyAdid);
4750
}
4851
#endregion
4952

Assets/Adjust/Unity/IAdjust.cs

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
namespace com.adjust.sdk {
55
public interface IAdjust {
66
bool isEnabled();
7+
string getAdid();
8+
AdjustAttribution getAttribution();
79

810
void onPause();
911
void onResume();

Assets/Adjust/WP8/AdjustWP8.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@
88

99
namespace com.adjust.sdk {
1010
public class AdjustWP8 : IAdjust {
11-
private const string sdkPrefix = "unity4.10.3";
11+
private const string sdkPrefix = "unity4.11.0";
1212

1313
public bool isEnabled() {
1414
return AdjustWP.IsEnabled();
1515
}
1616

17+
public string getAdid() {
18+
return null;
19+
}
20+
21+
public AdjustAttribution getAttribution() {
22+
return null;
23+
}
24+
1725
public void onPause() {
1826
AdjustWP.ApplicationDeactivated();
1927
}

Assets/Adjust/iOS/ADJAttribution.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@
3434
// tracker click_label
3535
@property (nonatomic, copy) NSString *clickLabel;
3636

37+
@property (nonatomic, copy) NSString *adid;
38+
3739
- (BOOL)isEqualToAttribution:(ADJAttribution *)attribution;
3840

39-
+ (ADJAttribution *)dataWithJsonDict:(NSDictionary *)jsonDict;
40-
- (id)initWithJsonDict:(NSDictionary *)jsonDict;
41+
+ (ADJAttribution *)dataWithJsonDict:(NSDictionary *)jsonDict
42+
adid:(NSString *)adid;
43+
- (id)initWithJsonDict:(NSDictionary *)jsonDict
44+
adid:(NSString *)adid;
4145
- (NSDictionary *)dictionary;
4246

4347
@end

Assets/Adjust/iOS/ADJConfig.h

-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,5 @@
170170
*/
171171
@property (nonatomic, copy) NSString *userAgent;
172172

173-
@property (nonatomic, assign, readonly) BOOL hasResponseDelegate;
174-
175173
- (BOOL) isValid;
176174
@end

Assets/Adjust/iOS/Adjust.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Adjust.h
33
// Adjust
44
//
5-
// V4.10.3
5+
// V4.11.0
66
// Created by Christian Wellenbrock on 2012-07-23.
77
// Copyright (c) 2012-2014 adjust GmbH. All rights reserved.
88
//
@@ -171,6 +171,9 @@ extern NSString * const ADJEnvironmentProduction;
171171
*/
172172
+ (void)resetSessionPartnerParameters;
173173

174+
+ (ADJAttribution *)attribution;
175+
+ (NSString *)adid;
176+
174177
/**
175178
* Obtain singleton Adjust object
176179
*/
@@ -197,5 +200,7 @@ extern NSString * const ADJEnvironmentProduction;
197200
- (void)removeSessionCallbackParameter:(NSString *)key;
198201
- (void)addSessionPartnerParameter:(NSString *)key value:(NSString *)value;
199202
- (void)addSessionCallbackParameter:(NSString *)key value:(NSString *)value;
203+
- (ADJAttribution *)attribution;
204+
- (NSString *)adid;
200205

201206
@end

Assets/Adjust/iOS/AdjustSdk.a

113 KB
Binary file not shown.

Assets/Adjust/iOS/AdjustUnity.mm

+67-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ - (id)init {
3838

3939
extern "C"
4040
{
41+
void addValueOrEmpty(NSMutableDictionary *dictionary, NSString *key, NSObject *value) {
42+
if (nil != value) {
43+
[dictionary setObject:[NSString stringWithFormat:@"%@", value] forKey:key];
44+
} else {
45+
[dictionary setObject:@"" forKey:key];
46+
}
47+
}
48+
4149
void _AdjustLaunchApp(const char* appToken, const char* environment, const char* sdkPrefix, int allowSuppressLogLevel, int logLevel,
4250
int eventBuffering, int sendInBackground, double delayStart, const char* userAgent, int launchDeferredDeeplink, const char* sceneName,
4351
int isAttributionCallbackImplemented, int isEventSuccessCallbackImplemented, int isEventFailureCallbackImplemented,
@@ -122,7 +130,7 @@ void _AdjustTrackEvent(const char* eventToken, double revenue, const char* curre
122130
NSArray *arrayCallbackParameters = ConvertArrayParameters(jsonCallbackParameters);
123131

124132
if (arrayCallbackParameters != nil) {
125-
int count = [arrayCallbackParameters count];
133+
NSUInteger count = [arrayCallbackParameters count];
126134

127135
for (int i = 0; i < count;) {
128136
NSString *key = arrayCallbackParameters[i];
@@ -138,7 +146,7 @@ void _AdjustTrackEvent(const char* eventToken, double revenue, const char* curre
138146
NSArray *arrayPartnerParameters = ConvertArrayParameters(jsonPartnerParameters);
139147

140148
if (arrayPartnerParameters != nil) {
141-
int count = [arrayPartnerParameters count];
149+
NSUInteger count = [arrayPartnerParameters count];
142150

143151
for (int i = 0; i < count;) {
144152
NSString *key = arrayPartnerParameters[i];
@@ -201,12 +209,69 @@ void _AdjustSetDeviceToken(const char* deviceToken) {
201209

202210
char* _AdjustGetIdfa() {
203211
NSString *idfa = [Adjust idfa];
212+
213+
if (nil == idfa) {
214+
return NULL;
215+
}
216+
204217
const char* idfaCString = [idfa UTF8String];
218+
219+
if (NULL == idfaCString) {
220+
return NULL;
221+
}
222+
205223
char* idfaCStringCopy = strdup(idfaCString);
206224

207225
return idfaCStringCopy;
208226
}
209227

228+
char* _AdjustGetAdid() {
229+
NSString *adid = [Adjust adid];
230+
231+
if (nil == adid) {
232+
return NULL;
233+
}
234+
235+
const char* adidCString = [adid UTF8String];
236+
237+
if (NULL == adidCString) {
238+
return NULL;
239+
}
240+
241+
char* adidCStringCopy = strdup(adidCString);
242+
243+
return adidCStringCopy;
244+
}
245+
246+
char* _AdjustGetAttribution() {
247+
ADJAttribution *attribution = [Adjust attribution];
248+
249+
if (nil == attribution) {
250+
return NULL;
251+
}
252+
253+
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
254+
255+
addValueOrEmpty(dictionary, @"trackerToken", attribution.trackerToken);
256+
addValueOrEmpty(dictionary, @"trackerName", attribution.trackerName);
257+
addValueOrEmpty(dictionary, @"network", attribution.network);
258+
addValueOrEmpty(dictionary, @"campaign", attribution.campaign);
259+
addValueOrEmpty(dictionary, @"creative", attribution.creative);
260+
addValueOrEmpty(dictionary, @"adgroup", attribution.adgroup);
261+
addValueOrEmpty(dictionary, @"clickLabel", attribution.clickLabel);
262+
addValueOrEmpty(dictionary, @"adid", attribution.adid);
263+
264+
NSData *dataAttribution = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil];
265+
NSString *stringAttribution = [[NSString alloc] initWithBytes:[dataAttribution bytes]
266+
length:[dataAttribution length]
267+
encoding:NSUTF8StringEncoding];
268+
269+
const char* attributionCString = [stringAttribution UTF8String];
270+
char* attributionCStringCopy = strdup(attributionCString);
271+
272+
return attributionCStringCopy;
273+
}
274+
210275
void _AdjustSendFirstPackages() {
211276
[Adjust sendFirstPackages];
212277
}

0 commit comments

Comments
 (0)