diff --git a/Assets/Adjust/Native/Editor/Dependencies.xml b/Assets/Adjust/Native/Editor/Dependencies.xml index 031ec4cf..c6820b9d 100644 --- a/Assets/Adjust/Native/Editor/Dependencies.xml +++ b/Assets/Adjust/Native/Editor/Dependencies.xml @@ -1,7 +1,7 @@ - + diff --git a/Assets/Adjust/Scripts/AdjustAndroid.cs b/Assets/Adjust/Scripts/AdjustAndroid.cs index a7a64cdc..4f24d42d 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.3"; + private const string sdkPrefix = "unity5.0.4"; 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"); @@ -154,8 +154,10 @@ public static void InitSdk(AdjustConfig adjustConfig) // check if user has set max number of event deduplication IDs if (adjustConfig.EventDeduplicationIdsMaxSize != null) { - AndroidJavaObject ajoEventDeduplicationIdsMaxSize = new AndroidJavaObject("java.lang.Integer", adjustConfig.EventDeduplicationIdsMaxSize); - ajoAdjustConfig.Call("setEventDeduplicationIdsMaxSize", ajoEventDeduplicationIdsMaxSize); + using (AndroidJavaObject ajoEventDeduplicationIdsMaxSize = new AndroidJavaObject("java.lang.Integer", adjustConfig.EventDeduplicationIdsMaxSize)) + { + ajoAdjustConfig.Call("setEventDeduplicationIdsMaxSize", ajoEventDeduplicationIdsMaxSize); + } } // check if user has set custom URL strategy @@ -163,15 +165,17 @@ public static void InitSdk(AdjustConfig adjustConfig) adjustConfig.ShouldUseSubdomains != null && adjustConfig.IsDataResidency != null) { - var ajoUrlStrategyDomains = new AndroidJavaObject("java.util.ArrayList"); - foreach (string domain in adjustConfig.UrlStrategyDomains) + using (var ajoUrlStrategyDomains = new AndroidJavaObject("java.util.ArrayList")) { - ajoUrlStrategyDomains.Call("add", domain); - } - ajoAdjustConfig.Call("setUrlStrategy", - ajoUrlStrategyDomains, - adjustConfig.ShouldUseSubdomains, - adjustConfig.IsDataResidency); + foreach (string domain in adjustConfig.UrlStrategyDomains) + { + ajoUrlStrategyDomains.Call("add", domain); + } + ajoAdjustConfig.Call("setUrlStrategy", + ajoUrlStrategyDomains, + adjustConfig.ShouldUseSubdomains, + adjustConfig.IsDataResidency); + } } // check attribution changed delagate @@ -222,62 +226,64 @@ public static void InitSdk(AdjustConfig adjustConfig) public static void TrackEvent(AdjustEvent adjustEvent) { - AndroidJavaObject ajoAdjustEvent = new AndroidJavaObject("com.adjust.sdk.AdjustEvent", adjustEvent.EventToken); - - // check if user has set revenue for the event - if (adjustEvent.Revenue != null) + using (AndroidJavaObject ajoAdjustEvent = + new AndroidJavaObject("com.adjust.sdk.AdjustEvent", adjustEvent.EventToken)) { - ajoAdjustEvent.Call("setRevenue", (double)adjustEvent.Revenue, adjustEvent.Currency); - } + // check if user has set revenue for the event + if (adjustEvent.Revenue != null) + { + ajoAdjustEvent.Call("setRevenue", (double)adjustEvent.Revenue, adjustEvent.Currency); + } - // check if user has added any callback parameters to the event - if (adjustEvent.CallbackParameters != null) - { - for (int i = 0; i < adjustEvent.CallbackParameters.Count; i += 2) + // check if user has added any callback parameters to the event + if (adjustEvent.CallbackParameters != null) { - string key = adjustEvent.CallbackParameters[i]; - string value = adjustEvent.CallbackParameters[i + 1]; - ajoAdjustEvent.Call("addCallbackParameter", key, value); + for (int i = 0; i < adjustEvent.CallbackParameters.Count; i += 2) + { + string key = adjustEvent.CallbackParameters[i]; + string value = adjustEvent.CallbackParameters[i + 1]; + ajoAdjustEvent.Call("addCallbackParameter", key, value); + } } - } - // check if user has added any partner parameters to the event - if (adjustEvent.PartnerParameters != null) - { - for (int i = 0; i < adjustEvent.PartnerParameters.Count; i += 2) + // check if user has added any partner parameters to the event + if (adjustEvent.PartnerParameters != null) { - string key = adjustEvent.PartnerParameters[i]; - string value = adjustEvent.PartnerParameters[i + 1]; - ajoAdjustEvent.Call("addPartnerParameter", key, value); + for (int i = 0; i < adjustEvent.PartnerParameters.Count; i += 2) + { + string key = adjustEvent.PartnerParameters[i]; + string value = adjustEvent.PartnerParameters[i + 1]; + ajoAdjustEvent.Call("addPartnerParameter", key, value); + } } - } - // check if user has set deduplication ID for the event - if (adjustEvent.DeduplicationId != null) - { - ajoAdjustEvent.Call("setDeduplicationId", adjustEvent.DeduplicationId); - } + // check if user has set deduplication ID for the event + if (adjustEvent.DeduplicationId != null) + { + ajoAdjustEvent.Call("setDeduplicationId", adjustEvent.DeduplicationId); + } - // check if user has added callback ID to the event - if (adjustEvent.CallbackId != null) - { - ajoAdjustEvent.Call("setCallbackId", adjustEvent.CallbackId); - } + // check if user has added callback ID to the event + if (adjustEvent.CallbackId != null) + { + ajoAdjustEvent.Call("setCallbackId", adjustEvent.CallbackId); + } - // check if user has added product ID to the event - if (adjustEvent.ProductId != null) - { - ajoAdjustEvent.Call("setProductId", adjustEvent.ProductId); - } + // check if user has added product ID to the event + if (adjustEvent.ProductId != null) + { + ajoAdjustEvent.Call("setProductId", adjustEvent.ProductId); + } - // check if user has added purchase token to the event - if (adjustEvent.PurchaseToken != null) - { - ajoAdjustEvent.Call("setPurchaseToken", adjustEvent.PurchaseToken); - } + // check if user has added purchase token to the event + if (adjustEvent.PurchaseToken != null) + { + ajoAdjustEvent.Call("setPurchaseToken", adjustEvent.PurchaseToken); + } - // Track the event. - ajcAdjust.CallStatic("trackEvent", ajoAdjustEvent); + // track the event + ajcAdjust.CallStatic("trackEvent", ajoAdjustEvent); + } } public static void Enable() @@ -386,114 +392,125 @@ public static void RemoveGlobalCallbackParameters() public static void ProcessDeeplink(AdjustDeeplink deeplink) { - AndroidJavaClass ajcUri = new AndroidJavaClass("android.net.Uri"); - AndroidJavaObject ajoUri = ajcUri.CallStatic("parse", deeplink.Deeplink); - AndroidJavaObject ajoAdjustDeeplink = new AndroidJavaObject("com.adjust.sdk.AdjustDeeplink", ajoUri); - ajcAdjust.CallStatic("processDeeplink", ajoAdjustDeeplink, ajoCurrentActivity); + using (AndroidJavaClass ajcUri = new AndroidJavaClass("android.net.Uri")) + using (AndroidJavaObject ajoUri = ajcUri.CallStatic("parse", deeplink.Deeplink)) + using (AndroidJavaObject ajoAdjustDeeplink = new AndroidJavaObject("com.adjust.sdk.AdjustDeeplink", ajoUri)) + { + ajcAdjust.CallStatic("processDeeplink", ajoAdjustDeeplink, ajoCurrentActivity); + } } public static void TrackAdRevenue(AdjustAdRevenue adRevenue) { - AndroidJavaObject ajoAdjustAdRevenue = new AndroidJavaObject("com.adjust.sdk.AdjustAdRevenue", adRevenue.Source); - - // check if user has set revenue - if (adRevenue.Revenue != null) + using (AndroidJavaObject ajoAdjustAdRevenue = + new AndroidJavaObject("com.adjust.sdk.AdjustAdRevenue", adRevenue.Source)) { - AndroidJavaObject ajoRevenue = new AndroidJavaObject("java.lang.Double", adRevenue.Revenue); - ajoAdjustAdRevenue.Call("setRevenue", ajoRevenue, adRevenue.Currency); - } + // check if user has set revenue + if (adRevenue.Revenue != null) + { + using (AndroidJavaObject ajoRevenue = new AndroidJavaObject("java.lang.Double", adRevenue.Revenue)) + { + ajoAdjustAdRevenue.Call("setRevenue", ajoRevenue, adRevenue.Currency); + } + } - // check if user has set ad impressions count - if (adRevenue.AdImpressionsCount != null) - { - AndroidJavaObject ajoAdImpressionsCount = new AndroidJavaObject("java.lang.Integer", adRevenue.AdImpressionsCount); - ajoAdjustAdRevenue.Call("setAdImpressionsCount", ajoAdImpressionsCount); - } + // check if user has set ad impressions count + if (adRevenue.AdImpressionsCount != null) + { + using (AndroidJavaObject ajoAdImpressionsCount = + new AndroidJavaObject("java.lang.Integer", adRevenue.AdImpressionsCount)) + { + ajoAdjustAdRevenue.Call("setAdImpressionsCount", ajoAdImpressionsCount); + } + } - // check if user has set ad revenue network - if (adRevenue.AdRevenueNetwork != null) - { - ajoAdjustAdRevenue.Call("setAdRevenueNetwork", adRevenue.AdRevenueNetwork); - } + // check if user has set ad revenue network + if (adRevenue.AdRevenueNetwork != null) + { + ajoAdjustAdRevenue.Call("setAdRevenueNetwork", adRevenue.AdRevenueNetwork); + } - // check if user has set ad revenue unit - if (adRevenue.AdRevenueUnit != null) - { - ajoAdjustAdRevenue.Call("setAdRevenueUnit", adRevenue.AdRevenueUnit); - } + // check if user has set ad revenue unit + if (adRevenue.AdRevenueUnit != null) + { + ajoAdjustAdRevenue.Call("setAdRevenueUnit", adRevenue.AdRevenueUnit); + } - // check if user has set ad revenue placement - if (adRevenue.AdRevenuePlacement != null) - { - ajoAdjustAdRevenue.Call("setAdRevenuePlacement", adRevenue.AdRevenuePlacement); - } + // check if user has set ad revenue placement + if (adRevenue.AdRevenuePlacement != null) + { + ajoAdjustAdRevenue.Call("setAdRevenuePlacement", adRevenue.AdRevenuePlacement); + } - // check if user has added any callback parameters - if (adRevenue.CallbackParameters != null) - { - for (int i = 0; i < adRevenue.CallbackParameters.Count; i += 2) + // check if user has added any callback parameters + if (adRevenue.CallbackParameters != null) { - string key = adRevenue.CallbackParameters[i]; - string value = adRevenue.CallbackParameters[i + 1]; - ajoAdjustAdRevenue.Call("addCallbackParameter", key, value); + for (int i = 0; i < adRevenue.CallbackParameters.Count; i += 2) + { + string key = adRevenue.CallbackParameters[i]; + string value = adRevenue.CallbackParameters[i + 1]; + ajoAdjustAdRevenue.Call("addCallbackParameter", key, value); + } } - } - // check if user has added any partner parameters - if (adRevenue.PartnerParameters != null) - { - for (int i = 0; i < adRevenue.PartnerParameters.Count; i += 2) + // check if user has added any partner parameters + if (adRevenue.PartnerParameters != null) { - string key = adRevenue.PartnerParameters[i]; - string value = adRevenue.PartnerParameters[i + 1]; - ajoAdjustAdRevenue.Call("addPartnerParameter", key, value); + for (int i = 0; i < adRevenue.PartnerParameters.Count; i += 2) + { + string key = adRevenue.PartnerParameters[i]; + string value = adRevenue.PartnerParameters[i + 1]; + ajoAdjustAdRevenue.Call("addPartnerParameter", key, value); + } } - } - // track ad revenue. - ajcAdjust.CallStatic("trackAdRevenue", ajoAdjustAdRevenue); + // track ad revenue + ajcAdjust.CallStatic("trackAdRevenue", ajoAdjustAdRevenue); + } } public static void TrackPlayStoreSubscription(AdjustPlayStoreSubscription subscription) { - AndroidJavaObject ajoSubscription = new AndroidJavaObject("com.adjust.sdk.AdjustPlayStoreSubscription", + using (AndroidJavaObject ajoSubscription = new AndroidJavaObject( + "com.adjust.sdk.AdjustPlayStoreSubscription", Convert.ToInt64(subscription.Price), subscription.Currency, subscription.ProductId, subscription.OrderId, subscription.Signature, - subscription.PurchaseToken); - - // check if user has set purchase time for subscription - if (subscription.PurchaseTime != null) + subscription.PurchaseToken)) { - ajoSubscription.Call("setPurchaseTime", Convert.ToInt64(subscription.PurchaseTime)); - } + // check if user has set purchase time for subscription + if (subscription.PurchaseTime != null) + { + ajoSubscription.Call("setPurchaseTime", Convert.ToInt64(subscription.PurchaseTime)); + } - // check if user has added any callback parameters to the subscription - if (subscription.CallbackParameters != null) - { - for (int i = 0; i < subscription.CallbackParameters.Count; i += 2) + // check if user has added any callback parameters to the subscription + if (subscription.CallbackParameters != null) { - string key = subscription.CallbackParameters[i]; - string value = subscription.CallbackParameters[i + 1]; - ajoSubscription.Call("addCallbackParameter", key, value); + for (int i = 0; i < subscription.CallbackParameters.Count; i += 2) + { + string key = subscription.CallbackParameters[i]; + string value = subscription.CallbackParameters[i + 1]; + ajoSubscription.Call("addCallbackParameter", key, value); + } } - } - // check if user has added any partner parameters to the subscription - if (subscription.PartnerParameters != null) - { - for (int i = 0; i < subscription.PartnerParameters.Count; i += 2) + // check if user has added any partner parameters to the subscription + if (subscription.PartnerParameters != null) { - string key = subscription.PartnerParameters[i]; - string value = subscription.PartnerParameters[i + 1]; - ajoSubscription.Call("addPartnerParameter", key, value); + for (int i = 0; i < subscription.PartnerParameters.Count; i += 2) + { + string key = subscription.PartnerParameters[i]; + string value = subscription.PartnerParameters[i + 1]; + ajoSubscription.Call("addPartnerParameter", key, value); + } } - } - // track the subscription - ajcAdjust.CallStatic("trackPlayStoreSubscription", ajoSubscription); + // track the subscription + ajcAdjust.CallStatic("trackPlayStoreSubscription", ajoSubscription); + } } public static void TrackThirdPartySharing(AdjustThirdPartySharing thirdPartySharing) @@ -588,84 +605,92 @@ public static void VerifyPlayStorePurchase( AdjustPlayStorePurchase purchase, Action verificationInfoCallback) { - AndroidJavaObject ajoPurchase = new AndroidJavaObject("com.adjust.sdk.AdjustPlayStorePurchase", - purchase.ProductId, - purchase.PurchaseToken); onVerificationResultListener = new VerificationResultListener(verificationInfoCallback); - - ajcAdjust.CallStatic("verifyPlayStorePurchase", ajoPurchase, onVerificationResultListener); + using (AndroidJavaObject ajoPurchase = new AndroidJavaObject("com.adjust.sdk.AdjustPlayStorePurchase", + purchase.ProductId, + purchase.PurchaseToken)) + { + ajcAdjust.CallStatic("verifyPlayStorePurchase", ajoPurchase, onVerificationResultListener); + } } public static void ProcessAndResolveDeeplink(AdjustDeeplink deeplink, Action resolvedLinkCallback) { onDeeplinkResolvedListener = new DeeplinkResolutionListener(resolvedLinkCallback); - AndroidJavaClass ajcUri = new AndroidJavaClass("android.net.Uri"); - AndroidJavaObject ajoUri = ajcUri.CallStatic("parse", deeplink.Deeplink); - AndroidJavaObject ajoAdjustDeeplink = new AndroidJavaObject("com.adjust.sdk.AdjustDeeplink", ajoUri); - ajcAdjust.CallStatic("processAndResolveDeeplink", ajoAdjustDeeplink, ajoCurrentActivity, onDeeplinkResolvedListener); + using (AndroidJavaClass ajcUri = new AndroidJavaClass("android.net.Uri")) + using (AndroidJavaObject ajoUri = ajcUri.CallStatic("parse", deeplink.Deeplink)) + using (AndroidJavaObject ajoAdjustDeeplink = new AndroidJavaObject("com.adjust.sdk.AdjustDeeplink", ajoUri)) + { + ajcAdjust.CallStatic( + "processAndResolveDeeplink", + ajoAdjustDeeplink, + ajoCurrentActivity, + onDeeplinkResolvedListener); + } } public static void VerifyAndTrackPlayStorePurchase( AdjustEvent adjustEvent, Action verificationInfoCallback) { - AndroidJavaObject ajoAdjustEvent = new AndroidJavaObject("com.adjust.sdk.AdjustEvent", adjustEvent.EventToken); - - // check if user has set revenue for the event - if (adjustEvent.Revenue != null) - { - ajoAdjustEvent.Call("setRevenue", (double)adjustEvent.Revenue, adjustEvent.Currency); - } - - // check if user has added any callback parameters to the event - if (adjustEvent.CallbackParameters != null) + onVerifyAndTrackListener = new VerificationResultListener(verificationInfoCallback); + using (AndroidJavaObject ajoAdjustEvent = + new AndroidJavaObject("com.adjust.sdk.AdjustEvent", adjustEvent.EventToken)) { - for (int i = 0; i < adjustEvent.CallbackParameters.Count; i += 2) + // check if user has set revenue for the event + if (adjustEvent.Revenue != null) { - string key = adjustEvent.CallbackParameters[i]; - string value = adjustEvent.CallbackParameters[i + 1]; - ajoAdjustEvent.Call("addCallbackParameter", key, value); + ajoAdjustEvent.Call("setRevenue", (double)adjustEvent.Revenue, adjustEvent.Currency); } - } - // check if user has added any partner parameters to the event - if (adjustEvent.PartnerParameters != null) - { - for (int i = 0; i < adjustEvent.PartnerParameters.Count; i += 2) + // check if user has added any callback parameters to the event + if (adjustEvent.CallbackParameters != null) { - string key = adjustEvent.PartnerParameters[i]; - string value = adjustEvent.PartnerParameters[i + 1]; - ajoAdjustEvent.Call("addPartnerParameter", key, value); + for (int i = 0; i < adjustEvent.CallbackParameters.Count; i += 2) + { + string key = adjustEvent.CallbackParameters[i]; + string value = adjustEvent.CallbackParameters[i + 1]; + ajoAdjustEvent.Call("addCallbackParameter", key, value); + } } - } - // check if user has set deduplication ID for the event - if (adjustEvent.DeduplicationId != null) - { - ajoAdjustEvent.Call("setDeduplicationId", adjustEvent.DeduplicationId); - } + // check if user has added any partner parameters to the event + if (adjustEvent.PartnerParameters != null) + { + for (int i = 0; i < adjustEvent.PartnerParameters.Count; i += 2) + { + string key = adjustEvent.PartnerParameters[i]; + string value = adjustEvent.PartnerParameters[i + 1]; + ajoAdjustEvent.Call("addPartnerParameter", key, value); + } + } - // check if user has added callback ID to the event - if (adjustEvent.CallbackId != null) - { - ajoAdjustEvent.Call("setCallbackId", adjustEvent.CallbackId); - } + // check if user has set deduplication ID for the event + if (adjustEvent.DeduplicationId != null) + { + ajoAdjustEvent.Call("setDeduplicationId", adjustEvent.DeduplicationId); + } - // check if user has added product ID to the event - if (adjustEvent.ProductId != null) - { - ajoAdjustEvent.Call("setProductId", adjustEvent.ProductId); - } + // check if user has added callback ID to the event + if (adjustEvent.CallbackId != null) + { + ajoAdjustEvent.Call("setCallbackId", adjustEvent.CallbackId); + } - // check if user has added purchase token to the event - if (adjustEvent.PurchaseToken != null) - { - ajoAdjustEvent.Call("setPurchaseToken", adjustEvent.PurchaseToken); - } + // check if user has added product ID to the event + if (adjustEvent.ProductId != null) + { + ajoAdjustEvent.Call("setProductId", adjustEvent.ProductId); + } - onVerifyAndTrackListener = new VerificationResultListener(verificationInfoCallback); + // check if user has added purchase token to the event + if (adjustEvent.PurchaseToken != null) + { + ajoAdjustEvent.Call("setPurchaseToken", adjustEvent.PurchaseToken); + } - ajcAdjust.CallStatic("verifyAndTrackPlayStorePurchase", ajoAdjustEvent, onVerifyAndTrackListener); + ajcAdjust.CallStatic("verifyAndTrackPlayStorePurchase", ajoAdjustEvent, onVerifyAndTrackListener); + } } // used for testing only @@ -717,37 +742,38 @@ public void onAttributionChanged(AndroidJavaObject ajoAttribution) } AdjustAttribution adjustAttribution = new AdjustAttribution(); - 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; - } - else + string trackerName = ajoAttribution.Get(AdjustUtils.KeyTrackerName); + adjustAttribution.TrackerName = trackerName == "" ? null : trackerName; + string trackerToken = ajoAttribution.Get(AdjustUtils.KeyTrackerToken); + adjustAttribution.TrackerToken = trackerToken == "" ? null : trackerToken; + string network = ajoAttribution.Get(AdjustUtils.KeyNetwork); + adjustAttribution.Network = network == "" ? null : network; + string campaign = ajoAttribution.Get(AdjustUtils.KeyCampaign); + adjustAttribution.Campaign = campaign == "" ? null : campaign; + string adgroup = ajoAttribution.Get(AdjustUtils.KeyAdgroup); + adjustAttribution.Adgroup = adgroup == "" ? null : adgroup; + string creative = ajoAttribution.Get(AdjustUtils.KeyCreative); + adjustAttribution.Creative = creative == "" ? null : creative; + string clickLabel = ajoAttribution.Get(AdjustUtils.KeyClickLabel); + adjustAttribution.ClickLabel = clickLabel == "" ? null : clickLabel; + string costType = ajoAttribution.Get(AdjustUtils.KeyCostType); + adjustAttribution.CostType = costType == "" ? null : costType; + using (AndroidJavaObject ajoCostAmount = ajoAttribution.Get(AdjustUtils.KeyCostAmount)) { - double costAmount = ajoCostAmount.Call("doubleValue"); - adjustAttribution.CostAmount = costAmount; + if (ajoCostAmount == null) + { + adjustAttribution.CostAmount = null; + } + else + { + double costAmount = ajoCostAmount.Call("doubleValue"); + adjustAttribution.CostAmount = costAmount; + } } - adjustAttribution.CostCurrency = ajoAttribution.Get(AdjustUtils.KeyCostCurrency) == "" ? - null : ajoAttribution.Get(AdjustUtils.KeyCostCurrency); - adjustAttribution.FbInstallReferrer = ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer) == "" ? - null : ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer); + string costCurrency = ajoAttribution.Get(AdjustUtils.KeyCostCurrency); + adjustAttribution.CostCurrency = costCurrency == "" ? null : costCurrency; + string fbInstallReferrer = ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer); + adjustAttribution.FbInstallReferrer = fbInstallReferrer == "" ? null : fbInstallReferrer; this.callback(adjustAttribution); } @@ -802,22 +828,23 @@ public void onEventTrackingSucceeded(AndroidJavaObject eventSuccessData) } AdjustEventSuccess adjustEventSuccess = new AdjustEventSuccess(); - adjustEventSuccess.Adid = eventSuccessData.Get(AdjustUtils.KeyAdid) == "" ? - null : eventSuccessData.Get(AdjustUtils.KeyAdid); - adjustEventSuccess.Message = eventSuccessData.Get(AdjustUtils.KeyMessage) == "" ? - null : eventSuccessData.Get(AdjustUtils.KeyMessage); - adjustEventSuccess.Timestamp = eventSuccessData.Get(AdjustUtils.KeyTimestamp) == "" ? - null : eventSuccessData.Get(AdjustUtils.KeyTimestamp); - adjustEventSuccess.EventToken = eventSuccessData.Get(AdjustUtils.KeyEventToken) == "" ? - null : eventSuccessData.Get(AdjustUtils.KeyEventToken); - adjustEventSuccess.CallbackId = eventSuccessData.Get(AdjustUtils.KeyCallbackId) == "" ? - null : eventSuccessData.Get(AdjustUtils.KeyCallbackId); - + string adid = eventSuccessData.Get(AdjustUtils.KeyAdid); + adjustEventSuccess.Adid = adid == "" ? null : adid; + string message = eventSuccessData.Get(AdjustUtils.KeyMessage); + adjustEventSuccess.Message = message == "" ? null : message; + string timestamp = eventSuccessData.Get(AdjustUtils.KeyTimestamp); + adjustEventSuccess.Timestamp = timestamp == "" ? null : timestamp; + string eventToken = eventSuccessData.Get(AdjustUtils.KeyEventToken); + adjustEventSuccess.EventToken = eventToken == "" ? null : eventToken; + string callbackId = eventSuccessData.Get(AdjustUtils.KeyCallbackId); + adjustEventSuccess.CallbackId = callbackId == "" ? null : callbackId; try { - AndroidJavaObject ajoJsonResponse = eventSuccessData.Get(AdjustUtils.KeyJsonResponse); - string jsonResponseString = ajoJsonResponse.Call("toString"); - adjustEventSuccess.BuildJsonResponseFromString(jsonResponseString); + using (AndroidJavaObject ajoJsonResponse = eventSuccessData.Get(AdjustUtils.KeyJsonResponse)) + { + string jsonResponseString = ajoJsonResponse.Call("toString"); + adjustEventSuccess.BuildJsonResponseFromString(jsonResponseString); + } } catch (Exception) { @@ -855,23 +882,24 @@ public void onEventTrackingFailed(AndroidJavaObject eventFailureData) } AdjustEventFailure adjustEventFailure = new AdjustEventFailure(); - adjustEventFailure.Adid = eventFailureData.Get(AdjustUtils.KeyAdid) == "" ? - null : eventFailureData.Get(AdjustUtils.KeyAdid); - adjustEventFailure.Message = eventFailureData.Get(AdjustUtils.KeyMessage) == "" ? - null : eventFailureData.Get(AdjustUtils.KeyMessage); + string adid = eventFailureData.Get(AdjustUtils.KeyAdid); + adjustEventFailure.Adid = adid == "" ? null : adid; + string message = eventFailureData.Get(AdjustUtils.KeyMessage); + adjustEventFailure.Message = message == "" ? null : message; adjustEventFailure.WillRetry = eventFailureData.Get(AdjustUtils.KeyWillRetry); - adjustEventFailure.Timestamp = eventFailureData.Get(AdjustUtils.KeyTimestamp) == "" ? - null : eventFailureData.Get(AdjustUtils.KeyTimestamp); - adjustEventFailure.EventToken = eventFailureData.Get(AdjustUtils.KeyEventToken) == "" ? - null : eventFailureData.Get(AdjustUtils.KeyEventToken); - adjustEventFailure.CallbackId = eventFailureData.Get(AdjustUtils.KeyCallbackId) == "" ? - null : eventFailureData.Get(AdjustUtils.KeyCallbackId); - + string timestamp = eventFailureData.Get(AdjustUtils.KeyTimestamp); + adjustEventFailure.Timestamp = timestamp == "" ? null : timestamp; + string eventToken = eventFailureData.Get(AdjustUtils.KeyEventToken); + adjustEventFailure.EventToken = eventToken == "" ? null : eventToken; + string callbackId = eventFailureData.Get(AdjustUtils.KeyCallbackId); + adjustEventFailure.CallbackId = callbackId == "" ? null : callbackId; try { - AndroidJavaObject ajoJsonResponse = eventFailureData.Get(AdjustUtils.KeyJsonResponse); - string jsonResponseString = ajoJsonResponse.Call("toString"); - adjustEventFailure.BuildJsonResponseFromString(jsonResponseString); + using (AndroidJavaObject ajoJsonResponse = eventFailureData.Get(AdjustUtils.KeyJsonResponse)) + { + string jsonResponseString = ajoJsonResponse.Call("toString"); + adjustEventFailure.BuildJsonResponseFromString(jsonResponseString); + } } catch (Exception) { @@ -879,7 +907,7 @@ public void onEventTrackingFailed(AndroidJavaObject eventFailureData) // Native Android SDK should send empty JSON object if none available as of v4.12.5. // Native Android SDK added special logic to send Unity friendly values as of v4.15.0. } - + this.callback(adjustEventFailure); } } @@ -909,18 +937,19 @@ public void onSessionTrackingSucceeded(AndroidJavaObject sessionSuccessData) } AdjustSessionSuccess adjustSessionSuccess = new AdjustSessionSuccess(); - adjustSessionSuccess.Adid = sessionSuccessData.Get(AdjustUtils.KeyAdid) == "" ? - null : sessionSuccessData.Get(AdjustUtils.KeyAdid); - adjustSessionSuccess.Message = sessionSuccessData.Get(AdjustUtils.KeyMessage) == "" ? - null : sessionSuccessData.Get(AdjustUtils.KeyMessage); - adjustSessionSuccess.Timestamp = sessionSuccessData.Get(AdjustUtils.KeyTimestamp) == "" ? - null : sessionSuccessData.Get(AdjustUtils.KeyTimestamp); - + string adid = sessionSuccessData.Get(AdjustUtils.KeyAdid); + adjustSessionSuccess.Adid = adid == "" ? null : adid; + string message = sessionSuccessData.Get(AdjustUtils.KeyMessage); + adjustSessionSuccess.Message = message == "" ? null : message; + string timestamp = sessionSuccessData.Get(AdjustUtils.KeyTimestamp); + adjustSessionSuccess.Timestamp = timestamp == "" ? null : timestamp; try { - AndroidJavaObject ajoJsonResponse = sessionSuccessData.Get(AdjustUtils.KeyJsonResponse); - string jsonResponseString = ajoJsonResponse.Call("toString"); - adjustSessionSuccess.BuildJsonResponseFromString(jsonResponseString); + using (AndroidJavaObject ajoJsonResponse = sessionSuccessData.Get(AdjustUtils.KeyJsonResponse)) + { + string jsonResponseString = ajoJsonResponse.Call("toString"); + adjustSessionSuccess.BuildJsonResponseFromString(jsonResponseString); + } } catch (Exception) { @@ -958,19 +987,20 @@ public void onSessionTrackingFailed(AndroidJavaObject sessionFailureData) } AdjustSessionFailure adjustSessionFailure = new AdjustSessionFailure(); - adjustSessionFailure.Adid = sessionFailureData.Get(AdjustUtils.KeyAdid) == "" ? - null : sessionFailureData.Get(AdjustUtils.KeyAdid); - adjustSessionFailure.Message = sessionFailureData.Get(AdjustUtils.KeyMessage) == "" ? - null : sessionFailureData.Get(AdjustUtils.KeyMessage); + string adid = sessionFailureData.Get(AdjustUtils.KeyAdid); + adjustSessionFailure.Adid = adid == "" ? null : adid; + string message = sessionFailureData.Get(AdjustUtils.KeyMessage); + adjustSessionFailure.Message = message == "" ? null : message; adjustSessionFailure.WillRetry = sessionFailureData.Get(AdjustUtils.KeyWillRetry); - adjustSessionFailure.Timestamp = sessionFailureData.Get(AdjustUtils.KeyTimestamp) == "" ? - null : sessionFailureData.Get(AdjustUtils.KeyTimestamp); - + string timestamp = sessionFailureData.Get(AdjustUtils.KeyTimestamp); + adjustSessionFailure.Timestamp = timestamp == "" ? null : timestamp; try { - AndroidJavaObject ajoJsonResponse = sessionFailureData.Get(AdjustUtils.KeyJsonResponse); - string jsonResponseString = ajoJsonResponse.Call("toString"); - adjustSessionFailure.BuildJsonResponseFromString(jsonResponseString); + using (AndroidJavaObject ajoJsonResponse = sessionFailureData.Get(AdjustUtils.KeyJsonResponse)) + { + string jsonResponseString = ajoJsonResponse.Call("toString"); + adjustSessionFailure.BuildJsonResponseFromString(jsonResponseString); + } } catch (Exception) { @@ -1107,37 +1137,38 @@ public void onAttributionRead(AndroidJavaObject ajoAttribution) } AdjustAttribution adjustAttribution = new AdjustAttribution(); - 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; - } - else + string trackerName = ajoAttribution.Get(AdjustUtils.KeyTrackerName); + adjustAttribution.TrackerName = trackerName == "" ? null : trackerName; + string trackerToken = ajoAttribution.Get(AdjustUtils.KeyTrackerToken); + adjustAttribution.TrackerToken = trackerToken == "" ? null : trackerToken; + string network = ajoAttribution.Get(AdjustUtils.KeyNetwork); + adjustAttribution.Network = network == "" ? null : network; + string campaign = ajoAttribution.Get(AdjustUtils.KeyCampaign); + adjustAttribution.Campaign = campaign == "" ? null : campaign; + string adgroup = ajoAttribution.Get(AdjustUtils.KeyAdgroup); + adjustAttribution.Adgroup = adgroup == "" ? null : adgroup; + string creative = ajoAttribution.Get(AdjustUtils.KeyCreative); + adjustAttribution.Creative = creative == "" ? null : creative; + string clickLabel = ajoAttribution.Get(AdjustUtils.KeyClickLabel); + adjustAttribution.ClickLabel = clickLabel == "" ? null : clickLabel; + string costType = ajoAttribution.Get(AdjustUtils.KeyCostType); + adjustAttribution.CostType = costType == "" ? null : costType; + using (AndroidJavaObject ajoCostAmount = ajoAttribution.Get(AdjustUtils.KeyCostAmount)) { - double costAmount = ajoCostAmount.Call("doubleValue"); - adjustAttribution.CostAmount = costAmount; + if (ajoCostAmount == null) + { + adjustAttribution.CostAmount = null; + } + else + { + double costAmount = ajoCostAmount.Call("doubleValue"); + adjustAttribution.CostAmount = costAmount; + } } - adjustAttribution.CostCurrency = ajoAttribution.Get(AdjustUtils.KeyCostCurrency) == "" ? - null : ajoAttribution.Get(AdjustUtils.KeyCostCurrency); - adjustAttribution.FbInstallReferrer = ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer) == "" ? - null : ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer); + string costCurrency = ajoAttribution.Get(AdjustUtils.KeyCostCurrency); + adjustAttribution.CostCurrency = costCurrency == "" ? null : costCurrency; + string fbInstallReferrer = ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer); + adjustAttribution.FbInstallReferrer = fbInstallReferrer == "" ? null : fbInstallReferrer; this.callback(adjustAttribution); } diff --git a/Assets/Adjust/Scripts/AdjustiOS.cs b/Assets/Adjust/Scripts/AdjustiOS.cs index c68376e9..60922d52 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.3"; + private const string sdkPrefix = "unity5.0.4"; // app callbacks as method parameters private static List> appIsEnabledGetterCallbacks; diff --git a/Assets/Adjust/Scripts/Editor/AdjustEditor.cs b/Assets/Adjust/Scripts/Editor/AdjustEditor.cs index b38095fb..ba1e1fbf 100644 --- a/Assets/Adjust/Scripts/Editor/AdjustEditor.cs +++ b/Assets/Adjust/Scripts/Editor/AdjustEditor.cs @@ -10,75 +10,21 @@ #if UNITY_IOS using UnityEditor.iOS.Xcode; #endif +#if UNITY_2019_3_OR_NEWER +using UnityEditor.iOS.Xcode.Extensions; +#endif namespace AdjustSdk { public class AdjustEditor : AssetPostprocessor { - [MenuItem("Assets/Adjust/Export Unity Package")] - public static void ExportAdjustUnityPackage() - { - string exportedFileName = "Adjust.unitypackage"; - string assetsPath = "Assets/Adjust"; - List assetsToExport = new List(); - - // Adjust Assets. - assetsToExport.Add(assetsPath + "/3rd Party/SimpleJSON.cs"); - - assetsToExport.Add(assetsPath + "/Android/adjust-android.jar"); - assetsToExport.Add(assetsPath + "/Android/AdjustAndroid.cs"); - assetsToExport.Add(assetsPath + "/Android/AdjustAndroidManifest.xml"); - - assetsToExport.Add(assetsPath + "/Editor/AdjustEditor.cs"); - assetsToExport.Add(assetsPath + "/Editor/AdjustSettings.cs"); - assetsToExport.Add(assetsPath + "/Editor/AdjustSettingsEditor.cs"); - assetsToExport.Add(assetsPath + "/Editor/AdjustCustomEditor.cs"); - assetsToExport.Add(assetsPath + "/Editor/AdjustEditorPreprocessor.cs"); - - assetsToExport.Add(assetsPath + "/ExampleGUI/ExampleGUI.cs"); - assetsToExport.Add(assetsPath + "/ExampleGUI/ExampleGUI.prefab"); - assetsToExport.Add(assetsPath + "/ExampleGUI/ExampleGUI.unity"); - - assetsToExport.Add(assetsPath + "/iOS/ADJAttribution.h"); - assetsToExport.Add(assetsPath + "/iOS/ADJConfig.h"); - assetsToExport.Add(assetsPath + "/iOS/ADJEvent.h"); - assetsToExport.Add(assetsPath + "/iOS/ADJEventFailure.h"); - assetsToExport.Add(assetsPath + "/iOS/ADJEventSuccess.h"); - assetsToExport.Add(assetsPath + "/iOS/ADJLogger.h"); - assetsToExport.Add(assetsPath + "/iOS/ADJSessionFailure.h"); - assetsToExport.Add(assetsPath + "/iOS/ADJSessionSuccess.h"); - assetsToExport.Add(assetsPath + "/iOS/ADJSubscription.h"); - assetsToExport.Add(assetsPath + "/iOS/Adjust.h"); - assetsToExport.Add(assetsPath + "/iOS/AdjustiOS.cs"); - assetsToExport.Add(assetsPath + "/iOS/AdjustSdk.a"); - assetsToExport.Add(assetsPath + "/iOS/AdjustUnity.h"); - assetsToExport.Add(assetsPath + "/iOS/AdjustUnity.mm"); - assetsToExport.Add(assetsPath + "/iOS/AdjustUnityDelegate.h"); - assetsToExport.Add(assetsPath + "/iOS/AdjustUnityDelegate.mm"); - - assetsToExport.Add(assetsPath + "/Prefab/Adjust.prefab"); - - assetsToExport.Add(assetsPath + "/Unity/Adjust.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustAppStoreSubscription.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustAttribution.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustConfig.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustEnvironment.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustEvent.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustEventFailure.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustEventSuccess.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustLogLevel.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustPlayStoreSubscription.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustSessionFailure.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustSessionSuccess.cs"); - assetsToExport.Add(assetsPath + "/Unity/AdjustUtils.cs"); - - AssetDatabase.ExportPackage( - assetsToExport.ToArray(), - exportedFileName, - ExportPackageOptions.IncludeDependencies | ExportPackageOptions.Interactive); - } + private const int AdjustEditorPostProcesssBuildPriority = 90; + private const string TargetUnityIphonePodfileLine = "target 'Unity-iPhone' do"; + private const string UseFrameworksPodfileLine = "use_frameworks!"; + private const string UseFrameworksDynamicPodfileLine = "use_frameworks! :linkage => :dynamic"; + private const string UseFrameworksStaticPodfileLine = "use_frameworks! :linkage => :static"; - [PostProcessBuild] + [PostProcessBuild(AdjustEditorPostProcesssBuildPriority)] public static void OnPostprocessBuild(BuildTarget target, string projectPath) { RunPostBuildScript(target: target, projectPath: projectPath); @@ -169,17 +115,9 @@ private static void RunPostBuildScript(BuildTarget target, string projectPath = Debug.Log("[Adjust]: Obj-C exceptions enabled successfully."); } - if (xcodeProject.ContainsFileByProjectPath("Libraries/Adjust/Native/iOS/AdjustSigSdk.a")) - { - if (!string.IsNullOrEmpty(xcodeTargetUnityFramework)) - { - xcodeProject.AddBuildProperty(xcodeTargetUnityFramework, "OTHER_LDFLAGS", "-force_load $(PROJECT_DIR)/Libraries/Adjust/Native/iOS/AdjustSigSdk.a"); - } - else - { - xcodeProject.AddBuildProperty(xcodeTarget, "OTHER_LDFLAGS", "-force_load $(PROJECT_DIR)/Libraries/Adjust/Native/iOS/AdjustSigSdk.a"); - } - } + // potential AdjustSigSdk.xcframework embedding + Debug.Log("[Adjust]: Checking whether AdjustSigSdk.xcframework needs to be embedded or not..."); + EmbedAdjustSignatureIfNeeded(projectPath, xcodeProject, xcodeTarget); // Save the changes to Xcode project file. xcodeProject.WriteToFile(xcodeProjectPath); @@ -188,6 +126,93 @@ private static void RunPostBuildScript(BuildTarget target, string projectPath = } #if UNITY_IOS + // dynamic xcframework embedding logic adjusted and taken from: + // https://github.com/AppLovin/AppLovin-MAX-Unity-Plugin/blob/master/DemoApp/Assets/MaxSdk/Scripts/IntegrationManager/Editor/AppLovinPostProcessiOS.cs + private static void EmbedAdjustSignatureIfNeeded(string buildPath, PBXProject project, string targetGuid) + { + var podsDirectory = Path.Combine(buildPath, "Pods"); + + if (!Directory.Exists(podsDirectory) || !ShouldEmbedDynamicLibraries(buildPath)) + { + Debug.Log("[Adjust]: No need to embed AdjustSigSdk.xcframework."); + return; + } + + var dynamicLibraryPathToEmbed = GetAdjustSignaturePathToEmbed(podsDirectory, buildPath); + if (dynamicLibraryPathToEmbed == null) { + return; + } + + Debug.Log("[Adjust]: It needs to be embedded. Starting the embedding process..."); +#if UNITY_2019_3_OR_NEWER + var fileGuid = project.AddFile(dynamicLibraryPathToEmbed, dynamicLibraryPathToEmbed); + project.AddFileToEmbedFrameworks(targetGuid, fileGuid); +#else + string runpathSearchPaths; + runpathSearchPaths = project.GetBuildPropertyForAnyConfig(targetGuid, "LD_RUNPATH_SEARCH_PATHS"); + runpathSearchPaths += string.IsNullOrEmpty(runpathSearchPaths) ? "" : " "; + + // check if runtime search paths already contains the required search paths for dynamic libraries + if (runpathSearchPaths.Contains("@executable_path/Frameworks")) { + return; + } + + runpathSearchPaths += "@executable_path/Frameworks"; + project.SetBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", runpathSearchPaths); +#endif + Debug.Log("[Adjust]: Embedding process completed."); + } + + private static bool ShouldEmbedDynamicLibraries(string buildPath) + { + var podfilePath = Path.Combine(buildPath, "Podfile"); + if (!File.Exists(podfilePath)) { + return false; + } + + // if the Podfile doesn't have a `Unity-iPhone` target, we should embed the dynamic libraries + var lines = File.ReadAllLines(podfilePath); + var containsUnityIphoneTarget = lines.Any(line => line.Contains(TargetUnityIphonePodfileLine)); + if (!containsUnityIphoneTarget) { + return true; + } + + // if the Podfile does not have a `use_frameworks! :linkage => static` line, we should not embed the dynamic libraries + var useFrameworksStaticLineIndex = Array.FindIndex(lines, line => line.Contains(UseFrameworksStaticPodfileLine)); + if (useFrameworksStaticLineIndex == -1) { + return false; + } + + // if more than one of the `use_frameworks!` lines are present, CocoaPods will use the last one + var useFrameworksLineIndex = Array.FindIndex(lines, line => line.Trim() == UseFrameworksPodfileLine); // check for exact line to avoid matching `use_frameworks! :linkage => static/dynamic` + var useFrameworksDynamicLineIndex = Array.FindIndex(lines, line => line.Contains(UseFrameworksDynamicPodfileLine)); + + // check if `use_frameworks! :linkage => :static` is the last line of the three + // if it is, we should embed the dynamic libraries + return useFrameworksLineIndex < useFrameworksStaticLineIndex && useFrameworksDynamicLineIndex < useFrameworksStaticLineIndex; + } + + private static string GetAdjustSignaturePathToEmbed(string podsDirectory, string buildPath) + { + var adjustSignatureFrameworkToEmbed = "AdjustSigSdk.xcframework"; + + // both .framework and .xcframework are directories, not files + var directories = Directory.GetDirectories(podsDirectory, adjustSignatureFrameworkToEmbed, SearchOption.AllDirectories); + if (directories.Length <= 0) { + return null; + } + + var dynamicLibraryAbsolutePath = directories[0]; + var relativePath = GetDynamicLibraryRelativePath(dynamicLibraryAbsolutePath); + return relativePath; + } + + private static string GetDynamicLibraryRelativePath(string dynamicLibraryAbsolutePath) + { + var index = dynamicLibraryAbsolutePath.LastIndexOf("Pods", StringComparison.Ordinal); + return dynamicLibraryAbsolutePath.Substring(index); + } + private static void HandlePlistIosChanges(string projectPath) { const string UserTrackingUsageDescriptionKey = "NSUserTrackingUsageDescription"; diff --git a/Assets/Adjust/Scripts/Editor/AdjustSettings.cs b/Assets/Adjust/Scripts/Editor/AdjustSettings.cs index c5332e81..6953ce24 100644 --- a/Assets/Adjust/Scripts/Editor/AdjustSettings.cs +++ b/Assets/Adjust/Scripts/Editor/AdjustSettings.cs @@ -56,35 +56,27 @@ public static AdjustSettings Instance } var assetPath = AssetDatabase.GUIDToAssetPath(guids[0]).Replace("AdjustSettings.cs", "AdjustSettings.asset"); - Debug.Log("READ PATH = " + assetPath); // AdjustSettings.asset will be stored inside of the Adjust/Resources directory if (assetPath.StartsWith("Assets")) { // plugin located in Assets directory string rootDir = assetPath.Replace("/Adjust/Scripts/Editor/AdjustSettings.asset", ""); - Debug.Log("ROOT DIR = " + rootDir); string adjustResourcesPath = Path.Combine(rootDir, "Adjust/Resources"); - Debug.Log("ADJUST RESOURCES DIR = " + adjustResourcesPath); if (!Directory.Exists(adjustResourcesPath)) { - Debug.Log("CREATING ADJUST RESOURCES DIR = " + adjustResourcesPath); Directory.CreateDirectory(adjustResourcesPath); } assetPath = Path.Combine(rootDir, AdjustSettingsExportPath); - Debug.Log("FINAL ASSET PATH = " + assetPath); } else { // plugin located in Packages folder string adjustResourcesPath = Path.Combine("Assets", "Adjust/Resources"); - Debug.Log("ADJUST RESOURCES DIR = " + adjustResourcesPath); if (!Directory.Exists(adjustResourcesPath)) { - Debug.Log("CREATING ADJUST RESOURCES DIR = " + adjustResourcesPath); Directory.CreateDirectory(adjustResourcesPath); } assetPath = Path.Combine("Assets", AdjustSettingsExportPath); - Debug.Log("FINAL ASSET PATH = " + assetPath); } AssetDatabase.CreateAsset(instance, assetPath); diff --git a/Assets/Adjust/package.json b/Assets/Adjust/package.json index 7e3a04e0..97284f9d 100644 --- a/Assets/Adjust/package.json +++ b/Assets/Adjust/package.json @@ -1,6 +1,6 @@ { "name": "com.adjust.sdk", - "version": "5.0.3", + "version": "5.0.4", "unity": "2019.4", "displayName": "Adjust", "license": "MIT", diff --git a/Assets/Adjust/Example.meta b/Assets/Example.meta similarity index 100% rename from Assets/Adjust/Example.meta rename to Assets/Example.meta diff --git a/Assets/Adjust/Example/Example.cs b/Assets/Example/Example.cs similarity index 100% rename from Assets/Adjust/Example/Example.cs rename to Assets/Example/Example.cs diff --git a/Assets/Adjust/Example/Example.cs.meta b/Assets/Example/Example.cs.meta similarity index 100% rename from Assets/Adjust/Example/Example.cs.meta rename to Assets/Example/Example.cs.meta diff --git a/Assets/Adjust/Example/Example.prefab b/Assets/Example/Example.prefab similarity index 100% rename from Assets/Adjust/Example/Example.prefab rename to Assets/Example/Example.prefab diff --git a/Assets/Adjust/Example/Example.prefab.meta b/Assets/Example/Example.prefab.meta similarity index 100% rename from Assets/Adjust/Example/Example.prefab.meta rename to Assets/Example/Example.prefab.meta diff --git a/Assets/Adjust/Example/Example.unity b/Assets/Example/Example.unity similarity index 100% rename from Assets/Adjust/Example/Example.unity rename to Assets/Example/Example.unity diff --git a/Assets/Adjust/Example/Example.unity.meta b/Assets/Example/Example.unity.meta similarity index 100% rename from Assets/Adjust/Example/Example.unity.meta rename to Assets/Example/Example.unity.meta diff --git a/Assets/Test/TestApp/TestApp.prefab b/Assets/Test/TestApp/TestApp.prefab new file mode 100644 index 00000000..7f9a5a52 --- /dev/null +++ b/Assets/Test/TestApp/TestApp.prefab @@ -0,0 +1,53 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &100000 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 6 + m_Component: + - component: {fileID: 400000} + - component: {fileID: 114599351951650296} + m_Layer: 0 + m_Name: TestApp + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &400000 +Transform: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 100000} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 0} + m_RootGameObject: {fileID: 100000} + m_IsPrefabAsset: 1 +--- !u!114 &114599351951650296 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 100000} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c420967931ab34a33abb412b340a032b, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Test/TestApp/TestApp.prefab.meta b/Assets/Test/TestApp/TestApp.prefab.meta new file mode 100644 index 00000000..5dddd5ae --- /dev/null +++ b/Assets/Test/TestApp/TestApp.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f84348a1b95794d65a306136fa7f800a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Test/TestApp/TestApp.unity b/Assets/Test/TestApp/TestApp.unity index 8d8ce546..ac856262 100644 --- a/Assets/Test/TestApp/TestApp.unity +++ b/Assets/Test/TestApp/TestApp.unity @@ -13,7 +13,7 @@ OcclusionCullingSettings: --- !u!104 &2 RenderSettings: m_ObjectHideFlags: 0 - serializedVersion: 8 + serializedVersion: 9 m_Fog: 0 m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_FogMode: 3 @@ -39,6 +39,7 @@ RenderSettings: m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 --- !u!157 &4 LightmapSettings: m_ObjectHideFlags: 0 @@ -54,11 +55,10 @@ LightmapSettings: m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 0 m_LightmapEditorSettings: - serializedVersion: 9 + serializedVersion: 10 m_Resolution: 1 m_BakeResolution: 50 - m_TextureWidth: 1024 - m_TextureHeight: 1024 + m_AtlasSize: 1024 m_AO: 0 m_AOMaxDistance: 1 m_CompAOExponent: 0 @@ -113,6 +113,48 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1001 &264065920 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 400000, guid: f84348a1b95794d65a306136fa7f800a, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: f84348a1b95794d65a306136fa7f800a, type: 2} + propertyPath: m_LocalPosition.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: f84348a1b95794d65a306136fa7f800a, type: 2} + propertyPath: m_LocalPosition.z + value: -10 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: f84348a1b95794d65a306136fa7f800a, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: f84348a1b95794d65a306136fa7f800a, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: f84348a1b95794d65a306136fa7f800a, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: f84348a1b95794d65a306136fa7f800a, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: f84348a1b95794d65a306136fa7f800a, type: 2} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: f84348a1b95794d65a306136fa7f800a, type: 2} + m_IsPrefabAsset: 0 --- !u!1001 &1452326133 Prefab: m_ObjectHideFlags: 0 @@ -153,45 +195,5 @@ Prefab: value: 1 objectReference: {fileID: 0} m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} - m_IsPrefabParent: 0 ---- !u!1 &1736520634 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 - m_Component: - - component: {fileID: 1736520636} - - component: {fileID: 1736520635} - m_Layer: 0 - m_Name: TestApp - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1736520635 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1736520634} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c420967931ab34a33abb412b340a032b, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!4 &1736520636 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1736520634} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_SourcePrefab: {fileID: 100100000, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + m_IsPrefabAsset: 0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 58aebc1b..25e0b356 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +### Version 5.0.4 (18th October 2024) +#### Changed +- Updated minimal supported Unity version to `2018.2`. +- Improved support for properly linking Adjust SDK dependencies regardless of the EDM4U iOS Resolver settings. With this change, there is no longer need to uncheck the `Link frameworks statically` option from EDM4U iOS Resolver settings. This should address issues like https://github.com/adjust/unity_sdk/issues/308#issuecomment-2417099823. +- Improved handling and disposal of `AndroidJavaObject` instances (https://github.com/adjust/unity_sdk/pull/303). +- Removed `Example` directory from `.unitypackage`. Example scene is now part of the repository only. This should address this issue: https://github.com/adjust/unity_sdk/issues/311. +- Removed the `Assets` menu item logic from `AdjustEditor` script which was generating SDK's `.unitypackage`. + +#### Native SDKs +- [iOS@v5.0.1][ios_sdk_v5.0.1] +- [Android@v5.0.1][android_sdk_v5.0.1] + +--- + ### Version 5.0.3 (17th September 2024) #### Fixed - Fixed not functional URL strategy feature for Android platform. @@ -1368,6 +1382,7 @@ Kudos to [Ivan](https://github.com/MatkovIvan) and [Evgeny](https://github.com/e [android_sdk_v4.38.2]: https://github.com/adjust/android_sdk/tree/v4.38.2 [android_sdk_v4.38.3]: https://github.com/adjust/android_sdk/tree/v4.38.3 [android_sdk_v5.0.0]: https://github.com/adjust/android_sdk/tree/v5.0.0 +[android_sdk_v5.0.1]: https://github.com/adjust/android_sdk/tree/v5.0.1 [windows_sdk_v4.12.0]: https://github.com/adjust/windows_sdk/tree/v4.12.0 [windows_sdk_v4.13.0]: https://github.com/adjust/windows_sdk/tree/v4.13.0 diff --git a/VERSION b/VERSION index 50e2274e..2d6c0bcf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.0.3 +5.0.4