Skip to content

Commit 19a71e8

Browse files
authored
Merge pull request #326 from adjust/v510
Version 5.1.0
2 parents 2f281f2 + e23710b commit 19a71e8

17 files changed

+739
-362
lines changed

Diff for: Assets/Adjust/Native/Editor/Dependencies.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</androidPackage>
88
</androidPackages>
99
<iosPods>
10-
<iosPod name="Adjust" version="5.1.0" minTargetSdk="12.0">
10+
<iosPod name="Adjust" version="5.1.1" minTargetSdk="12.0">
1111
</iosPod>
1212
</iosPods>
1313
</dependencies>

Diff for: Assets/Adjust/Native/iOS/AdjustUnity.mm

+9-20
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,7 @@ void _AdjustSetPushToken(const char* pushToken) {
346346
void _AdjustProcessDeeplink(const char* deeplink) {
347347
if (deeplink != NULL) {
348348
NSString *strDeeplink = [NSString stringWithUTF8String:deeplink];
349-
NSURL *urlDeeplink;
350-
if ([NSString instancesRespondToSelector:@selector(stringByAddingPercentEncodingWithAllowedCharacters:)]) {
351-
urlDeeplink = [NSURL URLWithString:[strDeeplink stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
352-
} else {
353-
#pragma clang diagnostic push
354-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
355-
urlDeeplink = [NSURL URLWithString:[strDeeplink stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
356-
}
357-
#pragma clang diagnostic pop
358-
349+
NSURL *urlDeeplink = [NSURL URLWithString:strDeeplink];
359350
ADJDeeplink *deeplink = [[ADJDeeplink alloc] initWithDeeplink:urlDeeplink];
360351
[Adjust processDeeplink:deeplink];
361352
}
@@ -381,6 +372,13 @@ void _AdjustGetAttribution(AdjustDelegateAttributionGetter callback) {
381372
addValueOrEmpty(dictionary, @"costType", attribution.costType);
382373
addValueOrEmpty(dictionary, @"costAmount", attribution.costAmount);
383374
addValueOrEmpty(dictionary, @"costCurrency", attribution.costCurrency);
375+
376+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:attribution.jsonResponse
377+
options:0
378+
error:nil];
379+
NSString *strJsonResponse = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
380+
addValueOrEmpty(dictionary, @"jsonResponse", strJsonResponse);
381+
384382
NSData *dataAttribution = [NSJSONSerialization dataWithJSONObject:dictionary
385383
options:0
386384
error:nil];
@@ -719,16 +717,7 @@ void _AdjustVerifyAppStorePurchase(const char* transactionId,
719717
void _AdjustProcessAndResolveDeeplink(const char* deeplink, AdjustDelegateResolvedDeeplinkCallback callback) {
720718
if (deeplink != NULL) {
721719
NSString *strDeeplink = [NSString stringWithUTF8String:deeplink];
722-
NSURL *urlDeeplink;
723-
if ([NSString instancesRespondToSelector:@selector(stringByAddingPercentEncodingWithAllowedCharacters:)]) {
724-
urlDeeplink = [NSURL URLWithString:[strDeeplink stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
725-
} else {
726-
#pragma clang diagnostic push
727-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
728-
urlDeeplink = [NSURL URLWithString:[strDeeplink stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
729-
}
730-
#pragma clang diagnostic pop
731-
720+
NSURL *urlDeeplink = [NSURL URLWithString:strDeeplink];
732721
ADJDeeplink *deeplink = [[ADJDeeplink alloc] initWithDeeplink:urlDeeplink];
733722
[Adjust processAndResolveDeeplink:deeplink withCompletionHandler:^(NSString * _Nullable resolvedLink) {
734723
// TODO: nil checks

Diff for: Assets/Adjust/Native/iOS/AdjustUnityDelegate.mm

+8
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ - (void)adjustAttributionChangedWannabe:(ADJAttribution *)attribution {
124124
forKey:@"costCurrency"
125125
toDictionary:dictionary];
126126

127+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:attribution.jsonResponse
128+
options:0
129+
error:nil];
130+
NSString *strJsonResponse = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
131+
[self addValueOrEmpty:strJsonResponse
132+
forKey:@"jsonResponse"
133+
toDictionary:dictionary];
134+
127135
NSData *dataAttribution = [NSJSONSerialization dataWithJSONObject:dictionary
128136
options:0
129137
error:nil];

Diff for: Assets/Adjust/Scripts/AdjustAndroid.cs

+326-226
Large diffs are not rendered by default.

Diff for: Assets/Adjust/Scripts/AdjustAttribution.cs

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class AdjustAttribution
1515
public string CostType { get; set; }
1616
public double? CostAmount { get; set; }
1717
public string CostCurrency { get; set; }
18+
public Dictionary<string, object> JsonResponse { get; set; }
1819
// Android only
1920
public string FbInstallReferrer { get; set; }
2021

@@ -49,6 +50,14 @@ public AdjustAttribution(string jsonString)
4950
}
5051
this.CostCurrency = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCostCurrency);
5152
this.FbInstallReferrer = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyFbInstallReferrer);
53+
54+
string jsonResponseString = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyJsonResponse);
55+
var jsonResponseNode = JSON.Parse(jsonResponseString);
56+
if (jsonResponseNode != null && jsonResponseNode.AsObject != null)
57+
{
58+
this.JsonResponse = new Dictionary<string, object>();
59+
AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, this.JsonResponse);
60+
}
5261
}
5362

5463
public AdjustAttribution(Dictionary<string, string> dicAttributionData)

Diff for: Assets/Adjust/Scripts/AdjustThreadDispatcher.cs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class AdjustThreadDispatcher : MonoBehaviour
6+
{
7+
private static readonly Queue<Action> executionQueue = new Queue<Action>();
8+
private static AdjustThreadDispatcher instance;
9+
10+
public static void RunOnMainThread(Action action)
11+
{
12+
if (action == null)
13+
{
14+
return;
15+
}
16+
17+
lock (executionQueue)
18+
{
19+
executionQueue.Enqueue(action);
20+
}
21+
}
22+
23+
private void Update()
24+
{
25+
while (executionQueue.Count > 0)
26+
{
27+
Action action;
28+
lock (executionQueue)
29+
{
30+
action = executionQueue.Dequeue();
31+
}
32+
if (action != null)
33+
{
34+
action.Invoke();
35+
}
36+
}
37+
}
38+
39+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
40+
private static void Initialize()
41+
{
42+
if (instance == null)
43+
{
44+
GameObject obj = new GameObject("AdjustThreadDispatcher");
45+
instance = obj.AddComponent<AdjustThreadDispatcher>();
46+
DontDestroyOnLoad(obj);
47+
}
48+
}
49+
}

Diff for: Assets/Adjust/Scripts/AdjustThreadDispatcher.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Assets/Adjust/Scripts/AdjustUtils.cs

+5
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,11 @@ public static Dictionary<string, string> GetSkanUpdateDataDictionary(string skan
350350
return skanUpdateDataDictionary;
351351
}
352352

353+
public static string GetValueOrEmptyToNull(string value)
354+
{
355+
return string.IsNullOrEmpty(value) ? null : value;
356+
}
357+
353358
#if UNITY_ANDROID
354359
public static AndroidJavaObject TestOptionsMap2AndroidJavaObject(Dictionary<string, string> testOptionsMap, AndroidJavaObject ajoCurrentActivity)
355360
{

0 commit comments

Comments
 (0)