diff --git a/Assets/Adjust/Scripts/Adjust.cs b/Assets/Adjust/Scripts/Adjust.cs index f812d258..34eb4bc2 100644 --- a/Assets/Adjust/Scripts/Adjust.cs +++ b/Assets/Adjust/Scripts/Adjust.cs @@ -573,7 +573,6 @@ public static void GetIdfa(Action callback) AdjustiOS.GetIdfa(callback); #elif UNITY_ANDROID Debug.Log("[Adjust]: Error! IDFA is not available on Android platform."); - return; #else Debug.Log(errorMsgPlatform); #endif @@ -590,7 +589,38 @@ public static void GetIdfv(Action callback) AdjustiOS.GetIdfv(callback); #elif UNITY_ANDROID Debug.Log("[Adjust]: Error! IDFV is not available on Android platform."); - return; +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void GetGoogleAdId(Action callback) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + Debug.Log("[Adjust]: Error! Google Advertising ID is not available on iOS platform."); +#elif UNITY_ANDROID + AdjustAndroid.GetGoogleAdId(callback); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void GetAmazonAdId(Action callback) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + Debug.Log("[Adjust]: Error! Amazon Fire Advertising ID is not available on iOS platform."); +#elif UNITY_ANDROID + AdjustAndroid.GetAmazonAdId(callback); #else Debug.Log(errorMsgPlatform); #endif @@ -622,8 +652,7 @@ public static void GetLastDeeplink(Action callback) #if UNITY_IOS AdjustiOS.GetLastDeeplink(callback); #elif UNITY_ANDROID - Debug.Log("[Adjust]: Error! Last deeplink getter is not available on Android platform."); - return; + AdjustAndroid.GetLastDeeplink(callback); #else Debug.Log(errorMsgPlatform); #endif diff --git a/Assets/Adjust/Scripts/AdjustAndroid.cs b/Assets/Adjust/Scripts/AdjustAndroid.cs index f88491c0..67933bae 100644 --- a/Assets/Adjust/Scripts/AdjustAndroid.cs +++ b/Assets/Adjust/Scripts/AdjustAndroid.cs @@ -8,7 +8,7 @@ namespace AdjustSdk #if UNITY_ANDROID public class AdjustAndroid { - private const string sdkPrefix = "unity5.0.1"; + private const string sdkPrefix = "unity5.0.2"; private static bool isDeferredDeeplinkOpeningEnabled = true; private static AndroidJavaClass ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust"); private static AndroidJavaObject ajoCurrentActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic("currentActivity"); @@ -562,7 +562,7 @@ public static void GetAttribution(Action onAttributionRead) // android specific methods public static void GetGoogleAdId(Action onDeviceIdsRead) { - DeviceIdsReadListener onDeviceIdsReadProxy = new DeviceIdsReadListener(onDeviceIdsRead); + GoogleAdIdReadListener onDeviceIdsReadProxy = new GoogleAdIdReadListener(onDeviceIdsRead); ajcAdjust.CallStatic("getGoogleAdId", ajoCurrentActivity, onDeviceIdsReadProxy); } @@ -578,6 +578,12 @@ public static void GetSdkVersion(Action onSdkVersionRead) ajcAdjust.CallStatic("getSdkVersion", onSdkVersionReadProxy); } + public static void GetLastDeeplink(Action onLastDeeplinkRead) + { + LastDeeplinkListener onLastDeeplinkReadProxy = new LastDeeplinkListener(onLastDeeplinkRead); + ajcAdjust.CallStatic("getLastDeeplink", ajoCurrentActivity, onLastDeeplinkReadProxy); + } + public static void VerifyPlayStorePurchase( AdjustPlayStorePurchase purchase, Action verificationInfoCallback) @@ -686,7 +692,6 @@ public static void OnPause(string testingArgument = null) } // private & helper classes - // TODO: add AndroidJavaObject null instance handling to each proxy private class AttributionChangedListener : AndroidJavaProxy { private Action callback; @@ -696,33 +701,40 @@ public AttributionChangedListener(Action pCallback) : base("c this.callback = pCallback; } - // method must be lowercase to match Android method signature - public void onAttributionChanged(AndroidJavaObject attribution) + // native method: + // void onAttributionChanged(AdjustAttribution attribution); + public void onAttributionChanged(AndroidJavaObject ajoAttribution) { - if (callback == null) + if (this.callback == null) { return; } + if (ajoAttribution == null) + { + this.callback(null); + return; + } + AdjustAttribution adjustAttribution = new AdjustAttribution(); - adjustAttribution.TrackerName = attribution.Get(AdjustUtils.KeyTrackerName) == "" ? - null : attribution.Get(AdjustUtils.KeyTrackerName); - adjustAttribution.TrackerToken = attribution.Get(AdjustUtils.KeyTrackerToken) == "" ? - null : attribution.Get(AdjustUtils.KeyTrackerToken); - adjustAttribution.Network = attribution.Get(AdjustUtils.KeyNetwork) == "" ? - null : attribution.Get(AdjustUtils.KeyNetwork); - adjustAttribution.Campaign = attribution.Get(AdjustUtils.KeyCampaign) == "" ? - null : attribution.Get(AdjustUtils.KeyCampaign); - adjustAttribution.Adgroup = attribution.Get(AdjustUtils.KeyAdgroup) == "" ? - null : attribution.Get(AdjustUtils.KeyAdgroup); - adjustAttribution.Creative = attribution.Get(AdjustUtils.KeyCreative) == "" ? - null : attribution.Get(AdjustUtils.KeyCreative); - adjustAttribution.ClickLabel = attribution.Get(AdjustUtils.KeyClickLabel) == "" ? - null : attribution.Get(AdjustUtils.KeyClickLabel); - adjustAttribution.CostType = attribution.Get(AdjustUtils.KeyCostType) == "" ? - null : attribution.Get(AdjustUtils.KeyCostType); - AndroidJavaObject ajoCostAmount = attribution.Get(AdjustUtils.KeyCostAmount) == null ? - null : attribution.Get(AdjustUtils.KeyCostAmount); + adjustAttribution.TrackerName = ajoAttribution.Get(AdjustUtils.KeyTrackerName) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyTrackerName); + adjustAttribution.TrackerToken = ajoAttribution.Get(AdjustUtils.KeyTrackerToken) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyTrackerToken); + adjustAttribution.Network = ajoAttribution.Get(AdjustUtils.KeyNetwork) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyNetwork); + adjustAttribution.Campaign = ajoAttribution.Get(AdjustUtils.KeyCampaign) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyCampaign); + adjustAttribution.Adgroup = ajoAttribution.Get(AdjustUtils.KeyAdgroup) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyAdgroup); + adjustAttribution.Creative = ajoAttribution.Get(AdjustUtils.KeyCreative) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyCreative); + adjustAttribution.ClickLabel = ajoAttribution.Get(AdjustUtils.KeyClickLabel) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyClickLabel); + adjustAttribution.CostType = ajoAttribution.Get(AdjustUtils.KeyCostType) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyCostType); + AndroidJavaObject ajoCostAmount = ajoAttribution.Get(AdjustUtils.KeyCostAmount) == null ? + null : ajoAttribution.Get(AdjustUtils.KeyCostAmount); if (ajoCostAmount == null) { adjustAttribution.CostAmount = null; @@ -732,11 +744,12 @@ public void onAttributionChanged(AndroidJavaObject attribution) double costAmount = ajoCostAmount.Call("doubleValue"); adjustAttribution.CostAmount = costAmount; } - adjustAttribution.CostCurrency = attribution.Get(AdjustUtils.KeyCostCurrency) == "" ? - null : attribution.Get(AdjustUtils.KeyCostCurrency); - adjustAttribution.FbInstallReferrer = attribution.Get(AdjustUtils.KeyFbInstallReferrer) == "" ? - null : attribution.Get(AdjustUtils.KeyFbInstallReferrer); - callback(adjustAttribution); + adjustAttribution.CostCurrency = ajoAttribution.Get(AdjustUtils.KeyCostCurrency) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyCostCurrency); + adjustAttribution.FbInstallReferrer = ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer); + + this.callback(adjustAttribution); } } @@ -749,16 +762,17 @@ public DeferredDeeplinkListener(Action pCallback) : base("com.adjust.sdk this.callback = pCallback; } - // method must be lowercase to match Android method signature + // native method: + // boolean launchReceivedDeeplink(Uri deeplink); public bool launchReceivedDeeplink(AndroidJavaObject deeplink) { - if (callback == null) + if (this.callback == null) { return isDeferredDeeplinkOpeningEnabled; } - string deeplinkURL = deeplink.Call("toString"); - callback(deeplinkURL); + string strDeeplink = deeplink.Call("toString"); + callback(strDeeplink); return isDeferredDeeplinkOpeningEnabled; } } @@ -772,15 +786,18 @@ public EventTrackingSucceededListener(Action pCallback) : ba this.callback = pCallback; } - // method must be lowercase to match Android method signature + // native method: + // void onEventTrackingSucceeded(AdjustEventSuccess eventSuccessResponseData); public void onEventTrackingSucceeded(AndroidJavaObject eventSuccessData) { - if (callback == null) + if (this.callback == null) { return; } + if (eventSuccessData == null) { + this.callback(null); return; } @@ -809,7 +826,7 @@ public void onEventTrackingSucceeded(AndroidJavaObject eventSuccessData) // Native Android SDK added special logic to send Unity friendly values as of v4.15.0. } - callback(adjustEventSuccess); + this.callback(adjustEventSuccess); } } @@ -822,15 +839,18 @@ public EventTrackingFailedListener(Action pCallback) : base( this.callback = pCallback; } - // method must be lowercase to match Android method signature + // native method: + // void onEventTrackingFailed(AdjustEventFailure eventFailureResponseData); public void onEventTrackingFailed(AndroidJavaObject eventFailureData) { - if (callback == null) + if (this.callback == null) { return; } + if (eventFailureData == null) { + this.callback(null); return; } @@ -860,7 +880,7 @@ public void onEventTrackingFailed(AndroidJavaObject eventFailureData) // Native Android SDK added special logic to send Unity friendly values as of v4.15.0. } - callback(adjustEventFailure); + this.callback(adjustEventFailure); } } @@ -873,15 +893,18 @@ public SessionTrackingSucceededListener(Action pCallback) this.callback = pCallback; } - // method must be lowercase to match Android method signature + // native method: + // void onSessionTrackingSucceeded(AdjustSessionSuccess sessionSuccessResponseData); public void onSessionTrackingSucceeded(AndroidJavaObject sessionSuccessData) { - if (callback == null) + if (this.callback == null) { return; } + if (sessionSuccessData == null) { + this.callback(null); return; } @@ -906,7 +929,7 @@ public void onSessionTrackingSucceeded(AndroidJavaObject sessionSuccessData) // Native Android SDK added special logic to send Unity friendly values as of v4.15.0. } - callback(adjustSessionSuccess); + this.callback(adjustSessionSuccess); } } @@ -919,15 +942,18 @@ public SessionTrackingFailedListener(Action pCallback) : b this.callback = pCallback; } - // method must be lowercase to match Android method signature + // native method: + // void onSessionTrackingFailed(AdjustSessionFailure failureResponseData); public void onSessionTrackingFailed(AndroidJavaObject sessionFailureData) { - if (callback == null) + if (this.callback == null) { return; } + if (sessionFailureData == null) { + this.callback(null); return; } @@ -953,41 +979,29 @@ public void onSessionTrackingFailed(AndroidJavaObject sessionFailureData) // Native Android SDK added special logic to send Unity friendly values as of v4.15.0. } - callback(adjustSessionFailure); + this.callback(adjustSessionFailure); } } - private class DeviceIdsReadListener : AndroidJavaProxy + private class GoogleAdIdReadListener : AndroidJavaProxy { - private Action onPlayAdIdReadCallback; - - public DeviceIdsReadListener(Action pCallback) : base("com.adjust.sdk.OnDeviceIdsRead") - { - this.onPlayAdIdReadCallback = pCallback; - } + private Action callback; - // method must be lowercase to match Android method signature - public void onGoogleAdIdRead(string playAdId) + public GoogleAdIdReadListener(Action pCallback) : base("com.adjust.sdk.OnGoogleAdIdReadListener") { - if (onPlayAdIdReadCallback == null) - { - return; - } - - this.onPlayAdIdReadCallback(playAdId); + this.callback = pCallback; } - // handling of null object - public void onGoogleAdIdRead(AndroidJavaObject ajoAdId) + // native method: + // void onGoogleAdIdRead(String googleAdId); + public void onGoogleAdIdRead(string adid) { - if (ajoAdId == null) + if (this.callback == null) { - string adId = null; - this.onGoogleAdIdRead(adId); return; } - this.onGoogleAdIdRead(ajoAdId.Call("toString")); + this.callback(adid); } } @@ -1000,20 +1014,27 @@ public VerificationResultListener(Action pCall this.callback = pCallback; } - public void onVerificationFinished(AndroidJavaObject verificationInfo) + // native method: + // void onVerificationFinished(AdjustPurchaseVerificationResult result); + public void onVerificationFinished(AndroidJavaObject ajoVerificationInfo) { - AdjustPurchaseVerificationResult purchaseVerificationResult = new AdjustPurchaseVerificationResult(); - // verification status - purchaseVerificationResult.VerificationStatus = verificationInfo.Get(AdjustUtils.KeyVerificationStatus); - // status code - purchaseVerificationResult.Code = verificationInfo.Get(AdjustUtils.KeyCode); - // message - purchaseVerificationResult.Message = verificationInfo.Get(AdjustUtils.KeyMessage); - - if (callback != null) + if (this.callback == null) + { + return; + } + + if (ajoVerificationInfo == null) { - callback(purchaseVerificationResult); + this.callback(null); + return; } + + AdjustPurchaseVerificationResult purchaseVerificationResult = new AdjustPurchaseVerificationResult(); + purchaseVerificationResult.VerificationStatus = ajoVerificationInfo.Get(AdjustUtils.KeyVerificationStatus); + purchaseVerificationResult.Code = ajoVerificationInfo.Get(AdjustUtils.KeyCode); + purchaseVerificationResult.Message = ajoVerificationInfo.Get(AdjustUtils.KeyMessage); + + this.callback(purchaseVerificationResult); } } @@ -1026,69 +1047,62 @@ public DeeplinkResolutionListener(Action pCallback) : base("com.adjust.s this.callback = pCallback; } + // native method: + // void onDeeplinkResolved(String resolvedLink); public void onDeeplinkResolved(string resolvedLink) { - if (callback != null) + if (this.callback == null) { - callback(resolvedLink); + return; } + + this.callback(resolvedLink); } } private class AdidReadListener : AndroidJavaProxy { - private Action onAdidReadCallback; + private Action callback; public AdidReadListener(Action pCallback) : base("com.adjust.sdk.OnAdidReadListener") { - this.onAdidReadCallback = pCallback; + this.callback = pCallback; } - // method must be lowercase to match Android method signature + // native method: + // void onAdidRead(String adid); public void onAdidRead(string adid) { - if (onAdidReadCallback == null) + if (this.callback == null) { return; } - this.onAdidReadCallback(adid); - } - - // handling of null object - public void onAdidRead(AndroidJavaObject ajoAdid) - { - if (ajoAdid == null) - { - string adid = null; - this.onAdidRead(adid); - return; - } - - this.onAdidRead(ajoAdid.Call("toString")); + this.callback(adid); } } private class AttributionReadListener : AndroidJavaProxy { - private Action onAttributionReadCallback; + private Action callback; public AttributionReadListener(Action pCallback) : base("com.adjust.sdk.OnAttributionReadListener") { - this.onAttributionReadCallback = pCallback; + this.callback = pCallback; } - // method must be lowercase to match Android method signature + // native method: + // void onAttributionRead(AdjustAttribution attribution); public void onAttributionRead(AndroidJavaObject ajoAttribution) { - if (this.onAttributionReadCallback == null) + if (this.callback == null) { return; } if (ajoAttribution == null) { - this.onAttributionReadCallback(null); + this.callback(null); return; } @@ -1125,101 +1139,105 @@ public void onAttributionRead(AndroidJavaObject ajoAttribution) adjustAttribution.FbInstallReferrer = ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer) == "" ? null : ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer); - this.onAttributionReadCallback(adjustAttribution); + this.callback(adjustAttribution); } } private class AmazonAdIdReadListener : AndroidJavaProxy { - private Action onAmazonAdIdReadCallback; + private Action callback; public AmazonAdIdReadListener(Action pCallback) : base("com.adjust.sdk.OnAmazonAdIdReadListener") { - this.onAmazonAdIdReadCallback = pCallback; + this.callback = pCallback; } - // method must be lowercase to match Android method signature + // native method: + // void onAmazonAdIdRead(String amazonAdId); public void onAmazonAdIdRead(string amazonAdId) { - if (this.onAmazonAdIdReadCallback == null) + if (this.callback == null) { return; } - this.onAmazonAdIdReadCallback(amazonAdId); - } - - // handling of null object - public void onAmazonAdIdRead(AndroidJavaObject ajoAmazonAdId) - { - if (ajoAmazonAdId == null) - { - string amazonAdId = null; - this.onAmazonAdIdRead(amazonAdId); - return; - } - - this.onAmazonAdIdRead(ajoAmazonAdId.Call("toString")); + this.callback(amazonAdId); } } private class SdkVersionReadListener : AndroidJavaProxy { - private Action onSdkVersionReadCallback; + private Action callback; private string sdkPrefix; public SdkVersionReadListener(Action pCallback, string sdkPrefix) : base("com.adjust.sdk.OnSdkVersionReadListener") { - this.onSdkVersionReadCallback = pCallback; + this.callback = pCallback; this.sdkPrefix = sdkPrefix; } - // method must be lowercase to match Android method signature + // native method: + // void onSdkVersionRead(String sdkVersion); public void onSdkVersionRead(string sdkVersion) { - if (this.onSdkVersionReadCallback == null) + if (this.callback == null) { return; } - this.onSdkVersionReadCallback(this.sdkPrefix + "@" + sdkVersion); + this.callback(this.sdkPrefix + "@" + sdkVersion); + } + } + + private class IsEnabledListener : AndroidJavaProxy + { + private Action callback; + + public IsEnabledListener(Action pCallback) : base("com.adjust.sdk.OnIsEnabledListener") + { + this.callback = pCallback; } - // handling of null object - public void onSdkVersionRead(AndroidJavaObject ajoSdkVersion) + // native method: + // void onIsEnabledRead(boolean isEnabled); + public void onIsEnabledRead(bool isEnabled) { - if (ajoSdkVersion == null) + if (this.callback == null) { - string sdkVersion = null; - this.onSdkVersionRead(sdkVersion); return; } - this.onSdkVersionRead(ajoSdkVersion.Call("toString")); + this.callback(isEnabled); } } - private class IsEnabledListener : AndroidJavaProxy + private class LastDeeplinkListener : AndroidJavaProxy { - private Action onIsEnabledCallback; + private Action callback; - public IsEnabledListener(Action pCallback) : base("com.adjust.sdk.OnIsEnabledListener") + public LastDeeplinkListener(Action pCallback) : base("com.adjust.sdk.OnLastDeeplinkReadListener") { - this.onIsEnabledCallback = pCallback; + this.callback = pCallback; } - // method must be lowercase to match Android method signature - public void onIsEnabledRead(bool isEnabled) + // native method: + // void onLastDeeplinkRead(Uri deeplink); + public void onLastDeeplinkRead(AndroidJavaObject ajoLastDeeplink) { - if (this.onIsEnabledCallback == null) + if (this.callback == null) { return; } - this.onIsEnabledCallback(isEnabled); + if (ajoLastDeeplink == null) + { + this.callback(null); + } + else + { + this.callback(ajoLastDeeplink.Call("toString")); + } } - - // not handling null for primitive data type } } #endif diff --git a/Assets/Adjust/Scripts/AdjustiOS.cs b/Assets/Adjust/Scripts/AdjustiOS.cs index 2b21c4b3..c38f7284 100644 --- a/Assets/Adjust/Scripts/AdjustiOS.cs +++ b/Assets/Adjust/Scripts/AdjustiOS.cs @@ -8,7 +8,7 @@ namespace AdjustSdk #if UNITY_IOS public class AdjustiOS { - private const string sdkPrefix = "unity5.0.1"; + private const string sdkPrefix = "unity5.0.2"; // app callbacks as method parameters private static List> appIsEnabledGetterCallbacks; diff --git a/Assets/Adjust/package.json b/Assets/Adjust/package.json index 125790de..17cf4758 100644 --- a/Assets/Adjust/package.json +++ b/Assets/Adjust/package.json @@ -1,6 +1,6 @@ { "name": "com.adjust.sdk", - "version": "5.0.1", + "version": "5.0.2", "unity": "2019.4", "displayName": "Adjust", "license": "MIT", diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a320517..9e24f0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +### Version 5.0.2 (27th August 2024) +#### Added +- Enabled obtaining of the last opened deep link (`Adjust.GetLastDeeplink`) on Android platform. + +#### Fixed +- Fixed method for getting Google Play Advertising ID (https://github.com/adjust/unity_sdk/issues/305). +- Fixed ambiguous overloads errors occurring when invoking some of the asynchronous getter methods on Android platform (https://github.com/adjust/unity_sdk/issues/288). + +#### Native SDKs +- [iOS@v5.0.0][ios_sdk_v5.0.0] +- [Android@v5.0.0][android_sdk_v5.0.0] + +--- + ### Version 5.0.1 (19th August 2024) #### Fixed - Fixed handling of deferred deep links on iOS platform. diff --git a/VERSION b/VERSION index 6b244dcd..a1ef0cae 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.0.1 +5.0.2