Skip to content

Version 5.1.0 #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/Adjust/Native/Editor/Dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</androidPackage>
</androidPackages>
<iosPods>
<iosPod name="Adjust" version="5.1.0" minTargetSdk="12.0">
<iosPod name="Adjust" version="5.1.1" minTargetSdk="12.0">
</iosPod>
</iosPods>
</dependencies>
29 changes: 9 additions & 20 deletions Assets/Adjust/Native/iOS/AdjustUnity.mm
Original file line number Diff line number Diff line change
Expand Up @@ -346,16 +346,7 @@ void _AdjustSetPushToken(const char* pushToken) {
void _AdjustProcessDeeplink(const char* deeplink) {
if (deeplink != NULL) {
NSString *strDeeplink = [NSString stringWithUTF8String:deeplink];
NSURL *urlDeeplink;
if ([NSString instancesRespondToSelector:@selector(stringByAddingPercentEncodingWithAllowedCharacters:)]) {
urlDeeplink = [NSURL URLWithString:[strDeeplink stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
urlDeeplink = [NSURL URLWithString:[strDeeplink stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
#pragma clang diagnostic pop

NSURL *urlDeeplink = [NSURL URLWithString:strDeeplink];
ADJDeeplink *deeplink = [[ADJDeeplink alloc] initWithDeeplink:urlDeeplink];
[Adjust processDeeplink:deeplink];
}
Expand All @@ -381,6 +372,13 @@ void _AdjustGetAttribution(AdjustDelegateAttributionGetter callback) {
addValueOrEmpty(dictionary, @"costType", attribution.costType);
addValueOrEmpty(dictionary, @"costAmount", attribution.costAmount);
addValueOrEmpty(dictionary, @"costCurrency", attribution.costCurrency);

NSData *jsonData = [NSJSONSerialization dataWithJSONObject:attribution.jsonResponse
options:0
error:nil];
NSString *strJsonResponse = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
addValueOrEmpty(dictionary, @"jsonResponse", strJsonResponse);

NSData *dataAttribution = [NSJSONSerialization dataWithJSONObject:dictionary
options:0
error:nil];
Expand Down Expand Up @@ -719,16 +717,7 @@ void _AdjustVerifyAppStorePurchase(const char* transactionId,
void _AdjustProcessAndResolveDeeplink(const char* deeplink, AdjustDelegateResolvedDeeplinkCallback callback) {
if (deeplink != NULL) {
NSString *strDeeplink = [NSString stringWithUTF8String:deeplink];
NSURL *urlDeeplink;
if ([NSString instancesRespondToSelector:@selector(stringByAddingPercentEncodingWithAllowedCharacters:)]) {
urlDeeplink = [NSURL URLWithString:[strDeeplink stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
urlDeeplink = [NSURL URLWithString:[strDeeplink stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
#pragma clang diagnostic pop

NSURL *urlDeeplink = [NSURL URLWithString:strDeeplink];
ADJDeeplink *deeplink = [[ADJDeeplink alloc] initWithDeeplink:urlDeeplink];
[Adjust processAndResolveDeeplink:deeplink withCompletionHandler:^(NSString * _Nullable resolvedLink) {
// TODO: nil checks
Expand Down
8 changes: 8 additions & 0 deletions Assets/Adjust/Native/iOS/AdjustUnityDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ - (void)adjustAttributionChangedWannabe:(ADJAttribution *)attribution {
forKey:@"costCurrency"
toDictionary:dictionary];

NSData *jsonData = [NSJSONSerialization dataWithJSONObject:attribution.jsonResponse
options:0
error:nil];
NSString *strJsonResponse = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
[self addValueOrEmpty:strJsonResponse
forKey:@"jsonResponse"
toDictionary:dictionary];

NSData *dataAttribution = [NSJSONSerialization dataWithJSONObject:dictionary
options:0
error:nil];
Expand Down
552 changes: 326 additions & 226 deletions Assets/Adjust/Scripts/AdjustAndroid.cs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Assets/Adjust/Scripts/AdjustAttribution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class AdjustAttribution
public string CostType { get; set; }
public double? CostAmount { get; set; }
public string CostCurrency { get; set; }
public Dictionary<string, object> JsonResponse { get; set; }
// Android only
public string FbInstallReferrer { get; set; }

Expand Down Expand Up @@ -49,6 +50,14 @@ public AdjustAttribution(string jsonString)
}
this.CostCurrency = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCostCurrency);
this.FbInstallReferrer = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyFbInstallReferrer);

string jsonResponseString = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyJsonResponse);
var jsonResponseNode = JSON.Parse(jsonResponseString);
if (jsonResponseNode != null && jsonResponseNode.AsObject != null)
{
this.JsonResponse = new Dictionary<string, object>();
AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, this.JsonResponse);
}
}

public AdjustAttribution(Dictionary<string, string> dicAttributionData)
Expand Down
49 changes: 49 additions & 0 deletions Assets/Adjust/Scripts/AdjustThreadDispatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using UnityEngine;

public class AdjustThreadDispatcher : MonoBehaviour
{
private static readonly Queue<Action> executionQueue = new Queue<Action>();
private static AdjustThreadDispatcher instance;

public static void RunOnMainThread(Action action)
{
if (action == null)
{
return;
}

lock (executionQueue)
{
executionQueue.Enqueue(action);
}
}

private void Update()
{
while (executionQueue.Count > 0)
{
Action action;
lock (executionQueue)
{
action = executionQueue.Dequeue();
}
if (action != null)
{
action.Invoke();
}
}
}

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void Initialize()
{
if (instance == null)
{
GameObject obj = new GameObject("AdjustThreadDispatcher");
instance = obj.AddComponent<AdjustThreadDispatcher>();
DontDestroyOnLoad(obj);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Adjust/Scripts/AdjustThreadDispatcher.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/Adjust/Scripts/AdjustUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ public static Dictionary<string, string> GetSkanUpdateDataDictionary(string skan
return skanUpdateDataDictionary;
}

public static string GetValueOrEmptyToNull(string value)
{
return string.IsNullOrEmpty(value) ? null : value;
}

#if UNITY_ANDROID
public static AndroidJavaObject TestOptionsMap2AndroidJavaObject(Dictionary<string, string> testOptionsMap, AndroidJavaObject ajoCurrentActivity)
{
Expand Down
Loading