Skip to content

Commit ef6c368

Browse files
authored
Merge pull request #275 from adjust/v4340
Version 4.34.0
2 parents 323e43b + 08f51ce commit ef6c368

39 files changed

+747
-76
lines changed

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

+50-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.33.2";
11+
private const string sdkPrefix = "unity4.34.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");
@@ -18,6 +18,7 @@ public class AdjustAndroid
1818
private static EventTrackingSucceededListener onEventTrackingSucceededListener;
1919
private static SessionTrackingFailedListener onSessionTrackingFailedListener;
2020
private static SessionTrackingSucceededListener onSessionTrackingSucceededListener;
21+
private static VerificationInfoListener onVerificationInfoListener;
2122

2223
public static void Start(AdjustConfig adjustConfig)
2324
{
@@ -290,6 +291,18 @@ public static void TrackEvent(AdjustEvent adjustEvent)
290291
ajoAdjustEvent.Call("setCallbackId", adjustEvent.callbackId);
291292
}
292293

294+
// Check if user has added product ID to the event.
295+
if (adjustEvent.productId != null)
296+
{
297+
ajoAdjustEvent.Call("setProductId", adjustEvent.productId);
298+
}
299+
300+
// Check if user has added purchase token to the event.
301+
if (adjustEvent.purchaseToken != null)
302+
{
303+
ajoAdjustEvent.Call("setPurchaseToken", adjustEvent.purchaseToken);
304+
}
305+
293306
// Track the event.
294307
ajcAdjust.CallStatic("trackEvent", ajoAdjustEvent);
295308
}
@@ -638,6 +651,16 @@ public static string GetSdkVersion()
638651
return sdkPrefix + "@" + nativeSdkVersion;
639652
}
640653

654+
public static void VerifyPlayStorePurchase(AdjustPlayStorePurchase purchase, Action<AdjustPurchaseVerificationInfo> verificationInfoCallback)
655+
{
656+
AndroidJavaObject ajoPurchase = new AndroidJavaObject("com.adjust.sdk.AdjustPurchase",
657+
purchase.productId,
658+
purchase.purchaseToken);
659+
onVerificationInfoListener = new VerificationInfoListener(verificationInfoCallback);
660+
661+
ajcAdjust.CallStatic("verifyPurchase", ajoPurchase, onVerificationInfoListener);
662+
}
663+
641664
// Used for testing only.
642665
public static void SetTestOptions(Dictionary<string, string> testOptions)
643666
{
@@ -952,6 +975,32 @@ public void onGoogleAdIdRead(AndroidJavaObject ajoAdId)
952975
}
953976
}
954977

978+
private class VerificationInfoListener : AndroidJavaProxy
979+
{
980+
private Action<AdjustPurchaseVerificationInfo> callback;
981+
982+
public VerificationInfoListener(Action<AdjustPurchaseVerificationInfo> pCallback) : base("com.adjust.sdk.OnPurchaseVerificationFinishedListener")
983+
{
984+
this.callback = pCallback;
985+
}
986+
987+
public void onVerificationFinished(AndroidJavaObject verificationInfo)
988+
{
989+
AdjustPurchaseVerificationInfo purchaseVerificationInfo = new AdjustPurchaseVerificationInfo();
990+
// verification status
991+
purchaseVerificationInfo.verificationStatus = verificationInfo.Get<string>(AdjustUtils.KeyVerificationStatus);
992+
// status code
993+
purchaseVerificationInfo.code = verificationInfo.Get<int>(AdjustUtils.KeyCode);
994+
// message
995+
purchaseVerificationInfo.message = verificationInfo.Get<string>(AdjustUtils.KeyMessage);
996+
997+
if (callback != null)
998+
{
999+
callback(purchaseVerificationInfo);
1000+
}
1001+
}
1002+
}
1003+
9551004
// Private & helper methods.
9561005
private static bool IsAppSecretSet(AdjustConfig adjustConfig)
9571006
{

Diff for: Assets/Adjust/Android/Test/adjust-test-library.aar

96 Bytes
Binary file not shown.

Diff for: Assets/Adjust/Android/Test/adjust-test-options.aar

58 Bytes
Binary file not shown.

Diff for: Assets/Adjust/Android/adjust-android.jar

13.6 KB
Binary file not shown.

Diff for: Assets/Adjust/Editor/AdjustSettings.asset

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_PrefabParentObject: {fileID: 0}
7+
m_PrefabInternal: {fileID: 0}
8+
m_GameObject: {fileID: 0}
9+
m_Enabled: 1
10+
m_EditorHideFlags: 0
11+
m_Script: {fileID: 11500000, guid: ea4d495dc6d5ba64b90db7afda6a48a4, type: 3}
12+
m_Name: AdjustSettings
13+
m_EditorClassIdentifier:
14+
_iOSFrameworkAdSupport: 1
15+
_iOSFrameworkAdServices: 0
16+
_iOSFrameworkAppTrackingTransparency: 0
17+
_iOSFrameworkStoreKit: 0
18+
_androidPermissionInternet: 1
19+
_androidPermissionInstallReferrerService: 1
20+
_androidPermissionAdId: 1
21+
_androidPermissionAccessNetworkState: 0
22+
_iOSUserTrackingUsageDescription:
23+
_iOSUrlIdentifier:
24+
_iOSUrlSchemes: []
25+
_iOSUniversalLinksDomains: []
26+
androidUriSchemes: []

Diff for: Assets/Adjust/Editor/AdjustSettings.asset.meta

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

Diff for: Assets/Adjust/Test/CommandExecutor.cs

+71-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@ public class CommandExecutor
2020
private string _baseUrl;
2121
private string _gdprUrl;
2222
private string _subscriptionUrl;
23+
private string _purchaseVerificationUrl;
2324
private Command _command;
2425
private ITestLibrary _testLibrary;
2526

26-
public CommandExecutor(ITestLibrary testLibrary, string baseUrl, string gdprUrl, string subscriptionUrl)
27+
public CommandExecutor(
28+
ITestLibrary testLibrary,
29+
string baseUrl,
30+
string gdprUrl,
31+
string subscriptionUrl,
32+
string purchaseVerificationUrl)
2733
{
2834
_baseUrl = baseUrl;
2935
_gdprUrl = gdprUrl;
3036
_subscriptionUrl = subscriptionUrl;
37+
_purchaseVerificationUrl = purchaseVerificationUrl;
3138
_testLibrary = testLibrary;
3239
}
3340

@@ -74,6 +81,7 @@ public void ExecuteCommand(Command command)
7481
case "measurementConsent": MeasurementConsent(); break;
7582
case "trackAdRevenueV2": TrackAdRevenueV2(); break;
7683
case "getLastDeeplink": GetLastDeeplink(); break;
84+
case "verifyPurchase": VerifyPurchase(); break;
7785
default: CommandNotFound(_command.ClassName, _command.MethodName); break;
7886
}
7987
}
@@ -90,6 +98,7 @@ private void TestOptions()
9098
testOptions[AdjustUtils.KeyTestOptionsBaseUrl] = _baseUrl;
9199
testOptions[AdjustUtils.KeyTestOptionsGdprUrl] = _gdprUrl;
92100
testOptions[AdjustUtils.KeyTestOptionsSubscriptionUrl] = _subscriptionUrl;
101+
testOptions[AdjustUtils.KeyTestOptionsPurchaseVerificationUrl] = _purchaseVerificationUrl;
93102

94103
if (_command.ContainsParameter("basePath"))
95104
{
@@ -553,6 +562,30 @@ private void Event()
553562
var callbackId = _command.GetFirstParameterValue("callbackId");
554563
adjustEvent.setCallbackId(callbackId);
555564
}
565+
566+
if (_command.ContainsParameter("transactionId"))
567+
{
568+
var transactionId = _command.GetFirstParameterValue("transactionId");
569+
adjustEvent.setTransactionId(transactionId);
570+
}
571+
572+
if (_command.ContainsParameter("productId"))
573+
{
574+
var productId = _command.GetFirstParameterValue("productId");
575+
adjustEvent.setProductId(productId);
576+
}
577+
578+
if (_command.ContainsParameter("receipt"))
579+
{
580+
var receipt = _command.GetFirstParameterValue("receipt");
581+
adjustEvent.setReceipt(receipt);
582+
}
583+
584+
if (_command.ContainsParameter("purchaseToken"))
585+
{
586+
var purchaseToken = _command.GetFirstParameterValue("purchaseToken");
587+
adjustEvent.setPurchaseToken(purchaseToken);
588+
}
556589
}
557590

558591
private void TrackEvent()
@@ -941,10 +974,46 @@ private void GetLastDeeplink()
941974
string localExtraPath = ExtraPath;
942975
string lastDeeplink = Adjust.getLastDeeplink();
943976
_testLibrary.AddInfoToSend("last_deeplink", lastDeeplink);
944-
_testLibrary.SendInfoToServer(localExtraPath);
977+
_testLibrary.SendInfoToServer(localExtraPath);
945978
#endif
946979
}
947980

981+
private void VerifyPurchase()
982+
{
983+
#if UNITY_IOS
984+
string transactionId = _command.GetFirstParameterValue("transactionId");
985+
string productId = _command.GetFirstParameterValue("productId");
986+
string receipt = _command.GetFirstParameterValue("receipt");
987+
988+
AdjustAppStorePurchase purchase = new AdjustAppStorePurchase(
989+
transactionId,
990+
productId,
991+
receipt);
992+
993+
Adjust.verifyAppStorePurchase(purchase, VerificationInfoCallback);
994+
#elif UNITY_ANDROID
995+
string productId = _command.GetFirstParameterValue("productId");
996+
string purchaseToken = _command.GetFirstParameterValue("purchaseToken");
997+
998+
AdjustPlayStorePurchase purchase = new AdjustPlayStorePurchase(
999+
productId,
1000+
purchaseToken);
1001+
1002+
Adjust.verifyPlayStorePurchase(purchase, VerificationInfoCallback);
1003+
#endif
1004+
}
1005+
1006+
// helper methods
1007+
1008+
private void VerificationInfoCallback(AdjustPurchaseVerificationInfo verificationInfo)
1009+
{
1010+
string localExtraPath = ExtraPath;
1011+
_testLibrary.AddInfoToSend("verification_status", verificationInfo.verificationStatus);
1012+
_testLibrary.AddInfoToSend("code", verificationInfo.code.ToString());
1013+
_testLibrary.AddInfoToSend("message", verificationInfo.message);
1014+
_testLibrary.SendInfoToServer(localExtraPath);
1015+
}
1016+
9481017
private void CommandNotFound(string className, string methodName)
9491018
{
9501019
TestApp.Log("Adjust Test: Method '" + methodName + "' not found for class '" + className + "'");

Diff for: Assets/Adjust/Test/TestApp.cs

+21-9
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ public class TestApp : MonoBehaviour
1212
#if UNITY_ANDROID
1313
private const string PORT = ":8443";
1414
private const string PROTOCOL = "https://";
15-
private const string IP = "192.168.86.44";
15+
private const string IP = "192.168.8.98";
1616
#elif UNITY_IOS
1717
private const string PORT = ":8080";
1818
private const string PROTOCOL = "http://";
19-
private const string IP = "192.168.86.44";
19+
private const string IP = "192.168.8.98";
2020
private TestLibraryiOS _testLibraryiOS;
2121
#else
2222
private const string PORT = ":8080";
@@ -26,6 +26,7 @@ public class TestApp : MonoBehaviour
2626
private const string BASE_URL = PROTOCOL + IP + PORT;
2727
private const string GDPR_URL = PROTOCOL + IP + PORT;
2828
private const string SUBSCRIPTION_URL = PROTOCOL + IP + PORT;
29+
private const string PURCHASE_VERIFICATION_URL = PROTOCOL + IP + PORT;
2930
private const string CONTROL_URL = "ws://" + IP + ":1987";
3031

3132
void OnGUI()
@@ -43,10 +44,8 @@ private void StartTestSession()
4344
_testLibraryiOS = testLibrary as TestLibraryiOS;
4445
#endif
4546
// Set specific tests to run.
46-
// testLibrary.AddTest("current/eventBuffering/Test_EventBuffering_sensitive_packets");
47-
// testLibrary.AddTest("Test_AdRevenue_ad_revenue_v2");
48-
// testLibrary.AddTest("Test_AdRevenue_ad_revenue_v2_invalid");
49-
// testLibrary.AddTestDirectory ("third-party-sharing");
47+
// testLibrary.AddTest("Test_PurchaseVerification_android_after_install");
48+
// testLibrary.AddTestDirectory ("purchase-verification");
5049

5150
Log("Starting test session.");
5251
testLibrary.StartTestSession();
@@ -55,11 +54,24 @@ private void StartTestSession()
5554
private ITestLibrary GetPlatformSpecificTestLibrary()
5655
{
5756
#if UNITY_IOS
58-
return new TestLibraryiOS(BASE_URL, GDPR_URL, SUBSCRIPTION_URL, CONTROL_URL);
57+
return new TestLibraryiOS(
58+
BASE_URL,
59+
GDPR_URL,
60+
SUBSCRIPTION_URL,
61+
PURCHASE_VERIFICATION_URL,
62+
CONTROL_URL);
5963
#elif UNITY_ANDROID
60-
return new TestLibraryAndroid(BASE_URL, GDPR_URL, SUBSCRIPTION_URL, CONTROL_URL);
64+
return new TestLibraryAndroid(
65+
BASE_URL,
66+
GDPR_URL,
67+
SUBSCRIPTION_URL,
68+
PURCHASE_VERIFICATION_URL,
69+
CONTROL_URL);
6170
#elif (UNITY_WSA || UNITY_WP8)
62-
return new TestLibraryWindows(BASE_URL, CONTROL_URL, GDPR_URL);
71+
return new TestLibraryWindows(
72+
BASE_URL,
73+
CONTROL_URL,
74+
GDPR_URL);
6375
#else
6476
Debug.Log("Cannot run integration tests (Error in TestApp.GetPlatformSpecificTestLibrary(...)). None of the supported platforms selected.");
6577
return null;

Diff for: Assets/Adjust/Test/TestLibraryAndroid.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@ public class TestLibraryAndroid : ITestLibrary
88
private AndroidJavaObject ajoTestLibrary;
99
private CommandListenerAndroid onCommandReceivedListener;
1010

11-
public TestLibraryAndroid(string baseUrl, string gdprUrl, string subscriptionUrl, string controlUrl)
11+
public TestLibraryAndroid(
12+
string baseUrl,
13+
string gdprUrl,
14+
string subscriptionUrl,
15+
string purchaseVerificationUrl,
16+
string controlUrl)
1217
{
13-
CommandExecutor commandExecutor = new CommandExecutor(this, baseUrl, gdprUrl, subscriptionUrl);
18+
CommandExecutor commandExecutor = new CommandExecutor(
19+
this,
20+
baseUrl,
21+
gdprUrl,
22+
subscriptionUrl,
23+
purchaseVerificationUrl);
1424
onCommandReceivedListener = new CommandListenerAndroid(commandExecutor);
1525
ajoTestLibrary = new AndroidJavaObject(
1626
"com.adjust.test.TestLibrary",

Diff for: Assets/Adjust/Test/TestLibraryiOS.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@ public class TestLibraryiOS : ITestLibrary
88
#if UNITY_IOS
99
private CommandExecutor _commandExecutor;
1010

11-
public TestLibraryiOS(string baseUrl, string gdprUrl, string subscriptionUrl, string controlUrl)
11+
public TestLibraryiOS(
12+
string baseUrl,
13+
string gdprUrl,
14+
string subscriptionUrl,
15+
string purchaseVerificationUrl,
16+
string controlUrl)
1217
{
13-
_commandExecutor = new CommandExecutor(this, baseUrl, gdprUrl, subscriptionUrl);
18+
_commandExecutor = new CommandExecutor(
19+
this,
20+
baseUrl,
21+
gdprUrl,
22+
subscriptionUrl,
23+
purchaseVerificationUrl);
1424
TestLibraryBridgeiOS.Initialize(baseUrl, controlUrl);
1525
}
1626

0 commit comments

Comments
 (0)