Skip to content

Commit 0512415

Browse files
authored
Merge pull request #331 from adjust/v513
Version 5.1.3
2 parents d30ec09 + 6b995b0 commit 0512415

File tree

9 files changed

+105
-29
lines changed

9 files changed

+105
-29
lines changed

Assets/Adjust/Scripts/AdjustAndroid.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace AdjustSdk
88
#if UNITY_ANDROID
99
public class AdjustAndroid
1010
{
11-
private const string sdkPrefix = "unity5.1.2";
11+
private const string sdkPrefix = "unity5.1.3";
1212
private static bool isDeferredDeeplinkOpeningEnabled = true;
1313
private static AndroidJavaClass ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust");
1414
private static AndroidJavaObject ajoCurrentActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
@@ -769,11 +769,13 @@ public void onAttributionChanged(AndroidJavaObject ajoAttribution)
769769
}
770770

771771
string jsonResponse = ajoAttribution.Get<string>(AdjustUtils.KeyJsonResponse);
772-
var jsonResponseNode = JSON.Parse(jsonResponse);
773-
if (jsonResponseNode != null && jsonResponseNode.AsObject != null)
774-
{
775-
adjustAttribution.JsonResponse = new Dictionary<string, object>();
776-
AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, adjustAttribution.JsonResponse);
772+
if (jsonResponse != null) {
773+
var jsonResponseNode = JSON.Parse(jsonResponse);
774+
if (jsonResponseNode != null && jsonResponseNode.AsObject != null)
775+
{
776+
adjustAttribution.JsonResponse = new Dictionary<string, object>();
777+
AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, adjustAttribution.JsonResponse);
778+
}
777779
}
778780

779781
if (callback != null)
@@ -1232,11 +1234,13 @@ public void onAttributionRead(AndroidJavaObject ajoAttribution)
12321234
}
12331235

12341236
string jsonResponse = ajoAttribution.Get<string>(AdjustUtils.KeyJsonResponse);
1235-
var jsonResponseNode = JSON.Parse(jsonResponse);
1236-
if (jsonResponseNode != null && jsonResponseNode.AsObject != null)
1237-
{
1238-
adjustAttribution.JsonResponse = new Dictionary<string, object>();
1239-
AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, adjustAttribution.JsonResponse);
1237+
if (jsonResponse != null) {
1238+
var jsonResponseNode = JSON.Parse(jsonResponse);
1239+
if (jsonResponseNode != null && jsonResponseNode.AsObject != null)
1240+
{
1241+
adjustAttribution.JsonResponse = new Dictionary<string, object>();
1242+
AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, adjustAttribution.JsonResponse);
1243+
}
12401244
}
12411245

12421246
if (callback != null)

Assets/Adjust/Scripts/AdjustAttribution.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ public AdjustAttribution(string jsonString)
5151
this.CostCurrency = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCostCurrency);
5252
this.FbInstallReferrer = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyFbInstallReferrer);
5353

54-
string jsonResponseString = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyJsonResponse);
55-
var jsonResponseNode = JSON.Parse(jsonResponseString);
56-
if (jsonResponseNode != null && jsonResponseNode.AsObject != null)
54+
var jsonResponseValue = jsonNode[AdjustUtils.KeyJsonResponse];
55+
if (jsonResponseValue == null)
5756
{
58-
this.JsonResponse = new Dictionary<string, object>();
59-
AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, this.JsonResponse);
57+
return;
6058
}
59+
this.JsonResponse = AdjustUtils.GetAttributionJsonResponse(jsonResponseValue);
6160
}
6261

6362
public AdjustAttribution(Dictionary<string, string> dicAttributionData)
@@ -88,6 +87,31 @@ public AdjustAttribution(Dictionary<string, string> dicAttributionData)
8887
}
8988
this.CostCurrency = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCostCurrency);
9089
this.FbInstallReferrer = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyFbInstallReferrer);
90+
91+
string jsonResponseString = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyJsonResponse);
92+
var jsonResponseNode = JSON.Parse(jsonResponseString);
93+
if (jsonResponseNode != null && jsonResponseNode.AsObject != null)
94+
{
95+
this.JsonResponse = new Dictionary<string, object>();
96+
AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, this.JsonResponse);
97+
}
98+
}
99+
100+
public void BuildJsonResponseFromString(string jsonResponseString)
101+
{
102+
var jsonNode = JSON.Parse(jsonResponseString);
103+
if (jsonNode == null)
104+
{
105+
return;
106+
}
107+
108+
this.JsonResponse = new Dictionary<string, object>();
109+
AdjustUtils.WriteJsonResponseDictionary(jsonNode.AsObject, JsonResponse);
110+
}
111+
112+
public string GetJsonResponseAsString()
113+
{
114+
return AdjustUtils.GetJsonResponseCompact(JsonResponse);
91115
}
92116
}
93117
}

Assets/Adjust/Scripts/AdjustUtils.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,22 @@ public static Dictionary<string, string> GetSkanUpdateDataDictionary(string skan
350350
return skanUpdateDataDictionary;
351351
}
352352

353+
public static Dictionary<string, object> GetAttributionJsonResponse(string attributionJsonResponse)
354+
{
355+
Dictionary<string, object> attributionJsonResponseDictionary = new Dictionary<string, object>();
356+
var attributionJsonResponseNode = JSON.Parse(attributionJsonResponse);
357+
if (attributionJsonResponseNode != null && attributionJsonResponseNode.AsObject != null)
358+
{
359+
Dictionary<string, object> temp = new Dictionary<string, object>();
360+
AdjustUtils.WriteJsonResponseDictionary(attributionJsonResponseNode.AsObject, temp);
361+
foreach (KeyValuePair<string, object> entry in temp)
362+
{
363+
attributionJsonResponseDictionary.Add(entry.Key, entry.Value);
364+
}
365+
}
366+
return attributionJsonResponseDictionary;
367+
}
368+
353369
public static string GetValueOrEmptyToNull(string value)
354370
{
355371
return string.IsNullOrEmpty(value) ? null : value;

Assets/Adjust/Scripts/AdjustiOS.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace AdjustSdk
88
#if UNITY_IOS
99
public class AdjustiOS
1010
{
11-
private const string sdkPrefix = "unity5.1.2";
11+
private const string sdkPrefix = "unity5.1.3";
1212

1313
// app callbacks as method parameters
1414
private static List<Action<bool>> appIsEnabledGetterCallbacks;

Assets/Adjust/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.adjust.sdk",
3-
"version": "5.1.2",
3+
"version": "5.1.3",
44
"unity": "2019.4",
55
"displayName": "Adjust",
66
"license": "MIT",

Assets/Example/Example.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ public void AttributionChangedCallback(AdjustAttribution attributionData)
158158
{
159159
Debug.Log("Click label: " + attributionData.ClickLabel);
160160
}
161+
if (attributionData.JsonResponse != null)
162+
{
163+
Debug.Log("JsonResponse: " + attributionData.GetJsonResponseAsString());
164+
}
161165
}
162166

163167
public void EventSuccessCallback(AdjustEventSuccess eventSuccessData)

Assets/Test/Scripts/CommandExecutor.cs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -369,15 +369,24 @@ private void Config()
369369
_testLibrary.AddInfoToSend("cost_amount", attribution.CostAmount.ToString());
370370
_testLibrary.AddInfoToSend("cost_currency", attribution.CostCurrency);
371371
_testLibrary.AddInfoToSend("fb_install_referrer", attribution.FbInstallReferrer);
372-
var updatedJsonResponse = new Dictionary<string, object>(attribution.JsonResponse);
373372
#if UNITY_IOS
374-
updatedJsonResponse.Remove("fb_install_referrer");
375-
if (updatedJsonResponse.TryGetValue("cost_amount", out var costAmount) && costAmount is IConvertible)
373+
var updatedJsonResponse = new Dictionary<string, object>();
374+
if (attribution.JsonResponse != null)
376375
{
377-
updatedJsonResponse["cost_amount"] = string.Format("{0:0.00}", System.Convert.ToDouble(costAmount));
376+
updatedJsonResponse = new Dictionary<string, object>(attribution.JsonResponse);
377+
updatedJsonResponse.Remove("fb_install_referrer");
378+
if (updatedJsonResponse.TryGetValue("cost_amount", out var costAmount) && costAmount is IConvertible)
379+
{
380+
updatedJsonResponse["cost_amount"] = string.Format("{0:0.00}", System.Convert.ToDouble(costAmount));
381+
}
378382
}
379-
#endif
380383
_testLibrary.AddInfoToSend("json_response", JsonConvert.SerializeObject(updatedJsonResponse));
384+
#else
385+
if (attribution.JsonResponse != null)
386+
{
387+
_testLibrary.AddInfoToSend("json_response", attribution.GetJsonResponseAsString());
388+
}
389+
#endif
381390
_testLibrary.SendInfoToServer(localExtraPath);
382391
});
383392
}
@@ -969,15 +978,24 @@ private void AttributionGetter()
969978
_testLibrary.AddInfoToSend("cost_amount", attribution.CostAmount.ToString());
970979
_testLibrary.AddInfoToSend("cost_currency", attribution.CostCurrency);
971980
_testLibrary.AddInfoToSend("fb_install_referrer", attribution.FbInstallReferrer);
972-
var updatedJsonResponse = new Dictionary<string, object>(attribution.JsonResponse);
973981
#if UNITY_IOS
974-
updatedJsonResponse.Remove("fb_install_referrer");
975-
if (updatedJsonResponse.TryGetValue("cost_amount", out var costAmount) && costAmount is IConvertible)
982+
var updatedJsonResponse = new Dictionary<string, object>();
983+
if (attribution.JsonResponse != null)
984+
{
985+
updatedJsonResponse = new Dictionary<string, object>(attribution.JsonResponse);
986+
updatedJsonResponse.Remove("fb_install_referrer");
987+
if (updatedJsonResponse.TryGetValue("cost_amount", out var costAmount) && costAmount is IConvertible)
988+
{
989+
updatedJsonResponse["cost_amount"] = string.Format("{0:0.00}", System.Convert.ToDouble(costAmount));
990+
}
991+
}
992+
_testLibrary.AddInfoToSend("json_response", JsonConvert.SerializeObject(updatedJsonResponse));
993+
#else
994+
if (attribution.JsonResponse != null)
976995
{
977-
updatedJsonResponse["cost_amount"] = string.Format("{0:0.00}", System.Convert.ToDouble(costAmount));
996+
_testLibrary.AddInfoToSend("json_response", attribution.GetJsonResponseAsString());
978997
}
979998
#endif
980-
_testLibrary.AddInfoToSend("json_response", JsonConvert.SerializeObject(updatedJsonResponse));
981999
_testLibrary.SendInfoToServer(localExtraPath);
9821000
});
9831001
}

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
### Version 5.1.3 (March 24th 2025)
2+
#### Fixed
3+
- Fixed null reference exceptions when migrating from pre 5.1.0 version (https://github.com/adjust/unity_sdk/issues/330).
4+
5+
#### Native SDKs
6+
- [[email protected]][ios_sdk_v5.1.1]
7+
- [[email protected]][android_sdk_v5.1.0]
8+
9+
---
10+
111
### Version 5.1.2 (March 6th 2025)
212
#### Added
313
- Added support for custom `CODE_SIGN_ENTITLEMENTS` file name (https://github.com/adjust/unity_sdk/pull/327).

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1.2
1+
5.1.3

0 commit comments

Comments
 (0)