Skip to content

Commit 9336643

Browse files
authored
Merge pull request #285 from adjust/v4370
Version 4.37.0
2 parents cbb6e64 + 6212727 commit 9336643

19 files changed

+196
-11
lines changed

Assets/Adjust/Android/AdjustAndroid.cs

+28-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
1010
{
11-
private const string sdkPrefix = "unity4.36.0";
11+
private const string sdkPrefix = "unity4.37.0";
1212
private static bool launchDeferredDeeplink = 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");
@@ -19,6 +19,7 @@ public class AdjustAndroid
1919
private static SessionTrackingFailedListener onSessionTrackingFailedListener;
2020
private static SessionTrackingSucceededListener onSessionTrackingSucceededListener;
2121
private static VerificationInfoListener onVerificationInfoListener;
22+
private static DeeplinkResolutionListener onDeeplinkResolvedListener;
2223

2324
public static void Start(AdjustConfig adjustConfig)
2425
{
@@ -684,6 +685,14 @@ public static void VerifyPlayStorePurchase(AdjustPlayStorePurchase purchase, Act
684685
ajcAdjust.CallStatic("verifyPurchase", ajoPurchase, onVerificationInfoListener);
685686
}
686687

688+
public static void ProcessDeeplink(string url, Action<string> resolvedLinkCallback)
689+
{
690+
onDeeplinkResolvedListener = new DeeplinkResolutionListener(resolvedLinkCallback);
691+
AndroidJavaClass ajcUri = new AndroidJavaClass("android.net.Uri");
692+
AndroidJavaObject ajoUri = ajcUri.CallStatic<AndroidJavaObject>("parse", url);
693+
ajcAdjust.CallStatic("processDeeplink", ajoUri, ajoCurrentActivity, onDeeplinkResolvedListener);
694+
}
695+
687696
// Used for testing only.
688697
public static void SetTestOptions(Dictionary<string, string> testOptions)
689698
{
@@ -1024,6 +1033,24 @@ public void onVerificationFinished(AndroidJavaObject verificationInfo)
10241033
}
10251034
}
10261035

1036+
private class DeeplinkResolutionListener : AndroidJavaProxy
1037+
{
1038+
private Action<string> callback;
1039+
1040+
public DeeplinkResolutionListener(Action<string> pCallback) : base("com.adjust.sdk.OnDeeplinkResolvedListener")
1041+
{
1042+
this.callback = pCallback;
1043+
}
1044+
1045+
public void onDeeplinkResolved(string resolvedLink)
1046+
{
1047+
if (callback != null)
1048+
{
1049+
callback(resolvedLink);
1050+
}
1051+
}
1052+
}
1053+
10271054
// Private & helper methods.
10281055
private static bool IsAppSecretSet(AdjustConfig adjustConfig)
10291056
{
Binary file not shown.
2.93 KB
Binary file not shown.

Assets/Adjust/Test/CommandExecutor.cs

+14
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public void ExecuteCommand(Command command)
8282
case "trackAdRevenueV2": TrackAdRevenueV2(); break;
8383
case "getLastDeeplink": GetLastDeeplink(); break;
8484
case "verifyPurchase": VerifyPurchase(); break;
85+
case "processDeeplink": ProcessDeeplink(); break;
8586
default: CommandNotFound(_command.ClassName, _command.MethodName); break;
8687
}
8788
}
@@ -1010,6 +1011,12 @@ private void VerifyPurchase()
10101011
#endif
10111012
}
10121013

1014+
private void ProcessDeeplink()
1015+
{
1016+
var deeplink = _command.GetFirstParameterValue("deeplink");
1017+
Adjust.processDeeplink(deeplink, DeeplinkResolvedCallback);
1018+
}
1019+
10131020
// helper methods
10141021

10151022
private void VerificationInfoCallback(AdjustPurchaseVerificationInfo verificationInfo)
@@ -1021,6 +1028,13 @@ private void VerificationInfoCallback(AdjustPurchaseVerificationInfo verificatio
10211028
_testLibrary.SendInfoToServer(localExtraPath);
10221029
}
10231030

1031+
private void DeeplinkResolvedCallback(string resolvedLink)
1032+
{
1033+
string localExtraPath = ExtraPath;
1034+
_testLibrary.AddInfoToSend("resolved_link", resolvedLink);
1035+
_testLibrary.SendInfoToServer(localExtraPath);
1036+
}
1037+
10241038
private void CommandNotFound(string className, string methodName)
10251039
{
10261040
TestApp.Log("Adjust Test: Method '" + methodName + "' not found for class '" + className + "'");

Assets/Adjust/Unity/Adjust.cs

+39
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class Adjust : MonoBehaviour
8686
private static Action<string> skadUpdateConversionValueDelegate = null;
8787
private static Action<string> skad4UpdateConversionValueDelegate = null;
8888
private static Action<AdjustPurchaseVerificationInfo> verificationInfoDelegate = null;
89+
private static Action<string> deeplinkResolutionDelegate = null;
8990
#endif
9091

9192
void Awake()
@@ -959,6 +960,28 @@ public static void verifyPlayStorePurchase(
959960
#endif
960961
}
961962

963+
public static void processDeeplink(
964+
string url,
965+
Action<string> resolvedLinkDelegate,
966+
string sceneName = "Adjust")
967+
{
968+
if (IsEditor())
969+
{
970+
return;
971+
}
972+
973+
#if UNITY_IOS
974+
Adjust.deeplinkResolutionDelegate = resolvedLinkDelegate;
975+
AdjustiOS.ProcessDeeplink(url, sceneName);
976+
#elif UNITY_ANDROID
977+
AdjustAndroid.ProcessDeeplink(url, resolvedLinkDelegate);
978+
#elif (UNITY_WSA || UNITY_WP8)
979+
Debug.Log("[Adjust]: Deep link processing is only supported for Android and iOS platform.");
980+
#else
981+
Debug.Log(errorMsgPlatform);
982+
#endif
983+
}
984+
962985
#if UNITY_IOS
963986
public void GetNativeAttribution(string attributionData)
964987
{
@@ -1178,6 +1201,22 @@ public void GetNativeVerificationInfo(string verificationInfoData)
11781201
var verificationInfo = new AdjustPurchaseVerificationInfo(verificationInfoData);
11791202
Adjust.verificationInfoDelegate(verificationInfo);
11801203
}
1204+
1205+
public void GetNativeResolvedLink(string resolvedLink)
1206+
{
1207+
if (IsEditor())
1208+
{
1209+
return;
1210+
}
1211+
1212+
if (Adjust.deeplinkResolutionDelegate == null)
1213+
{
1214+
Debug.Log("[Adjust]: Deep link reoslution delegate was not set.");
1215+
return;
1216+
}
1217+
1218+
Adjust.deeplinkResolutionDelegate(resolvedLink);
1219+
}
11811220
#endif
11821221

11831222
private static bool IsEditor()

Assets/Adjust/Unity/AdjustConfig.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class AdjustConfig
4343
internal bool? playStoreKidsAppEnabled;
4444
internal bool? allowSuppressLogLevel;
4545
internal bool? needsCost;
46+
internal bool? readDeviceInfoOnceEnabled;
4647
internal bool launchDeferredDeeplink;
4748
internal AdjustLogLevel? logLevel;
4849
internal AdjustEnvironment environment;
@@ -62,7 +63,6 @@ public class AdjustConfig
6263
internal string preinstallFilePath;
6364
internal bool? finalAndroidAttributionEnabled;
6465
internal string fbAppId;
65-
internal bool? readDeviceInfoOnceEnabled;
6666
// iOS specific members
6767
internal bool? allowAdServicesInfoReading;
6868
internal bool? allowIdfaReading;

Assets/Adjust/Unity/AdjustEvent.cs

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class AdjustEvent
1515
internal List<string> callbackList;
1616
// iOS specific members
1717
internal string receipt;
18+
internal string receiptBase64;
1819
internal bool isReceiptSet;
1920
// Android specific members
2021
internal string purchaseToken;
@@ -81,6 +82,11 @@ public void setReceipt(string receipt)
8182
this.receipt = receipt;
8283
}
8384

85+
public void setReceiptBase64(string receiptBase64)
86+
{
87+
this.receiptBase64 = receiptBase64;
88+
}
89+
8490
// Android specific methods
8591
public void setPurchaseToken(string purchaseToken)
8692
{

Assets/Adjust/Windows/AdjustWindows.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace com.adjust.sdk
1717
{
1818
public class AdjustWindows
1919
{
20-
private const string sdkPrefix = "unity4.36.0";
20+
private const string sdkPrefix = "unity4.37.0";
2121
private static bool appLaunched = false;
2222

2323
public static void Start(AdjustConfig adjustConfig)

Assets/Adjust/iOS/ADJConfig.h

+5
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,9 @@
291291
*/
292292
@property (nonatomic, assign) BOOL coppaCompliantEnabled;
293293

294+
/**
295+
* @brief Enables caching of device ids to read it only once
296+
*/
297+
@property (nonatomic, assign) BOOL readDeviceInfoOnceEnabled;
298+
294299
@end

Assets/Adjust/iOS/Adjust.h

+15-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Adjust.h
33
// Adjust SDK
44
//
5-
// V4.36.0
5+
// V4.37.0
66
// Created by Christian Wellenbrock (@wellle) on 23rd July 2013.
77
// Copyright (c) 2012-2021 Adjust GmbH. All rights reserved.
88
//
@@ -17,6 +17,8 @@
1717
#import "ADJPurchase.h"
1818
#import "ADJPurchaseVerificationResult.h"
1919

20+
typedef void(^AdjustResolvedDeeplinkBlock)(NSString * _Nonnull resolvedLink);
21+
2022
@interface AdjustTestOptions : NSObject
2123

2224
@property (nonatomic, copy, nullable) NSString *baseUrl;
@@ -137,6 +139,15 @@ extern NSString * __nonnull const ADJDataResidencyUS;
137139
*/
138140
+ (void)appWillOpenUrl:(nonnull NSURL *)url;
139141

142+
/**
143+
* @brief Process the deep link that has opened an app and potentially get a resolved link.
144+
*
145+
* @param deeplink URL object which contains info about adjust deep link.
146+
* @param completionHandler Completion handler where either resolved or echoed deep link will be sent.
147+
*/
148+
+ (void)processDeeplink:(nonnull NSURL *)deeplink
149+
completionHandler:(void (^_Nonnull)(NSString * _Nonnull resolvedLink))completionHandler;
150+
140151
/**
141152
* @brief Set the device token used by push notifications.
142153
*
@@ -407,6 +418,9 @@ extern NSString * __nonnull const ADJDataResidencyUS;
407418

408419
- (void)appWillOpenUrl:(nonnull NSURL *)url;
409420

421+
- (void)processDeeplink:(nonnull NSURL *)deeplink
422+
completionHandler:(void (^_Nonnull)(NSString * _Nonnull resolvedLink))completionHandler;
423+
410424
- (void)setOfflineMode:(BOOL)enabled;
411425

412426
- (void)setDeviceToken:(nonnull NSData *)deviceToken;

Assets/Adjust/iOS/AdjustSdk.a

56.5 KB
Binary file not shown.

Assets/Adjust/iOS/AdjustUnity.mm

+42
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ void _AdjustLaunchApp(const char* appToken,
101101
int linkMeEnabled,
102102
int needsCost,
103103
int coppaCompliant,
104+
int readDeviceInfoOnce,
104105
int64_t secretId,
105106
int64_t info1,
106107
int64_t info2,
@@ -222,6 +223,11 @@ void _AdjustLaunchApp(const char* appToken,
222223
[adjustConfig setCoppaCompliantEnabled:(BOOL)coppaCompliant];
223224
}
224225

226+
// Read device info just once.
227+
if (readDeviceInfoOnce != -1) {
228+
[adjustConfig setReadDeviceInfoOnceEnabled:(BOOL)readDeviceInfoOnce];
229+
}
230+
225231
// User agent.
226232
if (stringUserAgent != nil) {
227233
[adjustConfig setUserAgent:stringUserAgent];
@@ -270,6 +276,7 @@ void _AdjustTrackEvent(const char* eventToken,
270276
double revenue,
271277
const char* currency,
272278
const char* receipt,
279+
const char* receiptBase64,
273280
const char* productId,
274281
const char* transactionId,
275282
const char* callbackId,
@@ -324,6 +331,14 @@ void _AdjustTrackEvent(const char* eventToken,
324331
[event setReceipt:[stringReceipt dataUsingEncoding:NSUTF8StringEncoding]];
325332
}
326333

334+
// Base64 encoded receipt.
335+
if (receiptBase64 != NULL) {
336+
// If both (receipt and receiptBase64) set, receiptBase64 will be used.
337+
NSString *stringReceiptBase64 = [NSString stringWithUTF8String:receiptBase64];
338+
NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:stringReceiptBase64 options:0];
339+
[event setReceipt:decodedData];
340+
}
341+
327342
// Callback ID.
328343
if (callbackId != NULL) {
329344
NSString *stringCallbackId = [NSString stringWithUTF8String:callbackId];
@@ -881,6 +896,33 @@ void _AdjustVerifyAppStorePurchase(const char* transactionId,
881896
}];
882897
}
883898

899+
void _AdjustProcessDeeplink(const char* url, const char* sceneName) {
900+
NSString *strSceneName = isStringValid(sceneName) == true ? [NSString stringWithUTF8String:sceneName] : nil;
901+
if (url != NULL) {
902+
NSString *stringUrl = [NSString stringWithUTF8String:url];
903+
NSURL *nsUrl;
904+
if ([NSString instancesRespondToSelector:@selector(stringByAddingPercentEncodingWithAllowedCharacters:)]) {
905+
nsUrl = [NSURL URLWithString:[stringUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
906+
} else {
907+
#pragma clang diagnostic push
908+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
909+
nsUrl = [NSURL URLWithString:[stringUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
910+
}
911+
#pragma clang diagnostic pop
912+
913+
[Adjust processDeeplink:nsUrl completionHandler:^(NSString * _Nonnull resolvedLink) {
914+
if (strSceneName == nil) {
915+
return;
916+
}
917+
if (resolvedLink == nil) {
918+
return;
919+
}
920+
const char* resolvedLinkCString = [resolvedLink UTF8String];
921+
UnitySendMessage([strSceneName UTF8String], "GetNativeResolvedLink", resolvedLinkCString);
922+
}];
923+
}
924+
}
925+
884926
void _AdjustSetTestOptions(const char* baseUrl,
885927
const char* gdprUrl,
886928
const char* subscriptionUrl,

0 commit comments

Comments
 (0)