diff --git a/Assets/Adjust/Adjust.cs b/Assets/Adjust/Adjust.cs index f6e57818..34d3246b 100644 --- a/Assets/Adjust/Adjust.cs +++ b/Assets/Adjust/Adjust.cs @@ -19,7 +19,7 @@ public class Adjust : MonoBehaviour public AdjustLogLevel logLevel = AdjustLogLevel.Info; public AdjustEnvironment environment = AdjustEnvironment.Sandbox; -#if UNITY_IOS + #if UNITY_IOS // Delegate references for iOS callback triggering private static Action deferredDeeplinkDelegate = null; private static Action eventSuccessDelegate = null; @@ -27,424 +27,535 @@ public class Adjust : MonoBehaviour private static Action sessionSuccessDelegate = null; private static Action sessionFailureDelegate = null; private static Action attributionChangedDelegate = null; -#endif + #endif void Awake() { - DontDestroyOnLoad(transform.gameObject); - - if (!this.startManually) + if (!Application.isEditor) { - AdjustConfig adjustConfig = new AdjustConfig(this.appToken, this.environment, (this.logLevel == AdjustLogLevel.Suppress)); - adjustConfig.setLogLevel(this.logLevel); - adjustConfig.setSendInBackground(this.sendInBackground); - adjustConfig.setEventBufferingEnabled(this.eventBuffering); - adjustConfig.setLaunchDeferredDeeplink(this.launchDeferredDeeplink); - Adjust.start(adjustConfig); + DontDestroyOnLoad(transform.gameObject); + + if (!this.startManually) + { + AdjustConfig adjustConfig = new AdjustConfig(this.appToken, this.environment, (this.logLevel == AdjustLogLevel.Suppress)); + adjustConfig.setLogLevel(this.logLevel); + adjustConfig.setSendInBackground(this.sendInBackground); + adjustConfig.setEventBufferingEnabled(this.eventBuffering); + adjustConfig.setLaunchDeferredDeeplink(this.launchDeferredDeeplink); + Adjust.start(adjustConfig); + } } } void OnApplicationPause(bool pauseStatus) { -#if UNITY_IOS - // No action, iOS SDK is subscribed to iOS lifecycle notifications. -#elif UNITY_ANDROID - if (pauseStatus) + if (!Application.isEditor) { - AdjustAndroid.OnPause(); + #if UNITY_IOS + // No action, iOS SDK is subscribed to iOS lifecycle notifications. + #elif UNITY_ANDROID + if (pauseStatus) + { + AdjustAndroid.OnPause(); + } + else + { + AdjustAndroid.OnResume(); + } + #elif (UNITY_WSA || UNITY_WP8) + if (pauseStatus) + { + AdjustWindows.OnPause(); + } + else + { + AdjustWindows.OnResume(); + } + #else + Debug.Log(errorMsgPlatform); + #endif } - else - { - AdjustAndroid.OnResume(); - } -#elif (UNITY_WSA || UNITY_WP8) - if (pauseStatus) - { - AdjustWindows.OnPause(); - } - else - { - AdjustWindows.OnResume(); - } -#else - Debug.Log(errorMsgPlatform); -#endif } public static void start(AdjustConfig adjustConfig) { - if (adjustConfig == null) + if (!Application.isEditor) { - Debug.Log("Adjust: Missing config to start."); - return; + if (adjustConfig == null) + { + Debug.Log("Adjust: Missing config to start."); + return; + } + #if UNITY_IOS + Adjust.eventSuccessDelegate = adjustConfig.getEventSuccessDelegate(); + Adjust.eventFailureDelegate = adjustConfig.getEventFailureDelegate(); + Adjust.sessionSuccessDelegate = adjustConfig.getSessionSuccessDelegate(); + Adjust.sessionFailureDelegate = adjustConfig.getSessionFailureDelegate(); + Adjust.deferredDeeplinkDelegate = adjustConfig.getDeferredDeeplinkDelegate(); + Adjust.attributionChangedDelegate = adjustConfig.getAttributionChangedDelegate(); + AdjustiOS.Start(adjustConfig); + #elif UNITY_ANDROID + AdjustAndroid.Start(adjustConfig); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.Start(adjustConfig); + #else + Debug.Log(errorMsgPlatform); + #endif } -#if UNITY_IOS - Adjust.eventSuccessDelegate = adjustConfig.getEventSuccessDelegate(); - Adjust.eventFailureDelegate = adjustConfig.getEventFailureDelegate(); - Adjust.sessionSuccessDelegate = adjustConfig.getSessionSuccessDelegate(); - Adjust.sessionFailureDelegate = adjustConfig.getSessionFailureDelegate(); - Adjust.deferredDeeplinkDelegate = adjustConfig.getDeferredDeeplinkDelegate(); - Adjust.attributionChangedDelegate = adjustConfig.getAttributionChangedDelegate(); - AdjustiOS.Start(adjustConfig); -#elif UNITY_ANDROID - AdjustAndroid.Start(adjustConfig); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.Start(adjustConfig); -#else - Debug.Log(errorMsgPlatform); -#endif } public static void trackEvent(AdjustEvent adjustEvent) { - if (adjustEvent == null) + if (!Application.isEditor) { - Debug.Log("Adjust: Missing event to track."); - return; + if (adjustEvent == null) + { + Debug.Log("Adjust: Missing event to track."); + return; + } + #if UNITY_IOS + AdjustiOS.TrackEvent(adjustEvent); + #elif UNITY_ANDROID + AdjustAndroid.TrackEvent(adjustEvent); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.TrackEvent(adjustEvent); + #else + Debug.Log(errorMsgPlatform); + #endif } -#if UNITY_IOS - AdjustiOS.TrackEvent(adjustEvent); -#elif UNITY_ANDROID - AdjustAndroid.TrackEvent(adjustEvent); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.TrackEvent(adjustEvent); -#else - Debug.Log(errorMsgPlatform); -#endif } public static void setEnabled(bool enabled) { -#if UNITY_IOS - AdjustiOS.SetEnabled(enabled); -#elif UNITY_ANDROID - AdjustAndroid.SetEnabled(enabled); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.SetEnabled(enabled); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.SetEnabled(enabled); + #elif UNITY_ANDROID + AdjustAndroid.SetEnabled(enabled); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.SetEnabled(enabled); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static bool isEnabled() { -#if UNITY_IOS - return AdjustiOS.IsEnabled(); -#elif UNITY_ANDROID - return AdjustAndroid.IsEnabled(); -#elif (UNITY_WSA || UNITY_WP8) - return AdjustWindows.IsEnabled(); -#else - Debug.Log(errorMsgPlatform); - return false; -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + return AdjustiOS.IsEnabled(); + #elif UNITY_ANDROID + return AdjustAndroid.IsEnabled(); + #elif (UNITY_WSA || UNITY_WP8) + return AdjustWindows.IsEnabled(); + #else + Debug.Log(errorMsgPlatform); + return false; + #endif + } + else + { + return false; + } } public static void setOfflineMode(bool enabled) { -#if UNITY_IOS - AdjustiOS.SetOfflineMode(enabled); -#elif UNITY_ANDROID - AdjustAndroid.SetOfflineMode(enabled); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.SetOfflineMode(enabled); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.SetOfflineMode(enabled); + #elif UNITY_ANDROID + AdjustAndroid.SetOfflineMode(enabled); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.SetOfflineMode(enabled); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static void setDeviceToken(string deviceToken) { -#if UNITY_IOS - AdjustiOS.SetDeviceToken(deviceToken); -#elif UNITY_ANDROID - AdjustAndroid.SetDeviceToken(deviceToken); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.SetDeviceToken(deviceToken); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.SetDeviceToken(deviceToken); + #elif UNITY_ANDROID + AdjustAndroid.SetDeviceToken(deviceToken); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.SetDeviceToken(deviceToken); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static void appWillOpenUrl(string url) { -#if UNITY_IOS - AdjustiOS.AppWillOpenUrl(url); -#elif UNITY_ANDROID - AdjustAndroid.AppWillOpenUrl(url); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.AppWillOpenUrl(url); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.AppWillOpenUrl(url); + #elif UNITY_ANDROID + AdjustAndroid.AppWillOpenUrl(url); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.AppWillOpenUrl(url); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static void sendFirstPackages() { -#if UNITY_IOS - AdjustiOS.SendFirstPackages(); -#elif UNITY_ANDROID - AdjustAndroid.SendFirstPackages(); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.SendFirstPackages(); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.SendFirstPackages(); + #elif UNITY_ANDROID + AdjustAndroid.SendFirstPackages(); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.SendFirstPackages(); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static void addSessionPartnerParameter(string key, string value) { -#if UNITY_IOS - AdjustiOS.AddSessionPartnerParameter(key, value); -#elif UNITY_ANDROID - AdjustAndroid.AddSessionPartnerParameter(key, value); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.AddSessionPartnerParameter(key, value); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.AddSessionPartnerParameter(key, value); + #elif UNITY_ANDROID + AdjustAndroid.AddSessionPartnerParameter(key, value); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.AddSessionPartnerParameter(key, value); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static void addSessionCallbackParameter(string key, string value) { -#if UNITY_IOS - AdjustiOS.AddSessionCallbackParameter(key, value); -#elif UNITY_ANDROID - AdjustAndroid.AddSessionCallbackParameter(key, value); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.AddSessionCallbackParameter(key, value); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.AddSessionCallbackParameter(key, value); + #elif UNITY_ANDROID + AdjustAndroid.AddSessionCallbackParameter(key, value); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.AddSessionCallbackParameter(key, value); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static void removeSessionPartnerParameter(string key) { -#if UNITY_IOS - AdjustiOS.RemoveSessionPartnerParameter(key); -#elif UNITY_ANDROID - AdjustAndroid.RemoveSessionPartnerParameter(key); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.RemoveSessionPartnerParameter(key); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.RemoveSessionPartnerParameter(key); + #elif UNITY_ANDROID + AdjustAndroid.RemoveSessionPartnerParameter(key); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.RemoveSessionPartnerParameter(key); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static void removeSessionCallbackParameter(string key) { -#if UNITY_IOS - AdjustiOS.RemoveSessionCallbackParameter(key); -#elif UNITY_ANDROID - AdjustAndroid.RemoveSessionCallbackParameter(key); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.RemoveSessionCallbackParameter(key); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.RemoveSessionCallbackParameter(key); + #elif UNITY_ANDROID + AdjustAndroid.RemoveSessionCallbackParameter(key); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.RemoveSessionCallbackParameter(key); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static void resetSessionPartnerParameters() { -#if UNITY_IOS - AdjustiOS.ResetSessionPartnerParameters(); -#elif UNITY_ANDROID - AdjustAndroid.ResetSessionPartnerParameters(); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.ResetSessionPartnerParameters(); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.ResetSessionPartnerParameters(); + #elif UNITY_ANDROID + AdjustAndroid.ResetSessionPartnerParameters(); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.ResetSessionPartnerParameters(); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static void resetSessionCallbackParameters() { -#if UNITY_IOS - AdjustiOS.ResetSessionCallbackParameters(); -#elif UNITY_ANDROID - AdjustAndroid.ResetSessionCallbackParameters(); -#elif (UNITY_WSA || UNITY_WP8) - AdjustWindows.ResetSessionCallbackParameters(); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + AdjustiOS.ResetSessionCallbackParameters(); + #elif UNITY_ANDROID + AdjustAndroid.ResetSessionCallbackParameters(); + #elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.ResetSessionCallbackParameters(); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static string getAdid() { -#if UNITY_IOS - return AdjustiOS.GetAdid(); -#elif UNITY_ANDROID - return AdjustAndroid.GetAdid(); -#elif (UNITY_WSA || UNITY_WP8) - return AdjustWindows.GetAdid(); -#else - Debug.Log(errorMsgPlatform); - return string.Empty; -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + return AdjustiOS.GetAdid(); + #elif UNITY_ANDROID + return AdjustAndroid.GetAdid(); + #elif (UNITY_WSA || UNITY_WP8) + return AdjustWindows.GetAdid(); + #else + Debug.Log(errorMsgPlatform); + return string.Empty; + #endif + } + else + { + return string.Empty; + } } public static AdjustAttribution getAttribution() { -#if UNITY_IOS - return AdjustiOS.GetAttribution(); -#elif UNITY_ANDROID - return AdjustAndroid.GetAttribution(); -#elif (UNITY_WSA || UNITY_WP8) - return AdjustWindows.GetAttribution(); -#else - Debug.Log(errorMsgPlatform); - return null; -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + return AdjustiOS.GetAttribution(); + #elif UNITY_ANDROID + return AdjustAndroid.GetAttribution(); + #elif (UNITY_WSA || UNITY_WP8) + return AdjustWindows.GetAttribution(); + #else + Debug.Log(errorMsgPlatform); + return null; + #endif + } + else + { + return null; + } } public static string getWinAdid() { -#if UNITY_IOS - Debug.Log("Adjust: Error! Windows Advertising ID is not available on iOS platform."); - return string.Empty; -#elif UNITY_ANDROID - Debug.Log("Adjust: Error! Windows Advertising ID is not available on Android platform."); - return string.Empty; -#elif (UNITY_WSA || UNITY_WP8) - return AdjustWindows.GetWinAdId(); -#else - Debug.Log(errorMsgPlatform); - return string.Empty; -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + Debug.Log("Adjust: Error! Windows Advertising ID is not available on iOS platform."); + return string.Empty; + #elif UNITY_ANDROID + Debug.Log("Adjust: Error! Windows Advertising ID is not available on Android platform."); + return string.Empty; + #elif (UNITY_WSA || UNITY_WP8) + return AdjustWindows.GetWinAdId(); + #else + Debug.Log(errorMsgPlatform); + return string.Empty; + #endif + } + else + { + return string.Empty; + } } public static string getIdfa() { -#if UNITY_IOS - return AdjustiOS.GetIdfa(); -#elif UNITY_ANDROID - Debug.Log("Adjust: Error! IDFA is not available on Android platform."); - return string.Empty; -#elif (UNITY_WSA || UNITY_WP8) - Debug.Log("Adjust: Error! IDFA is not available on Windows platform."); - return string.Empty; -#else - Debug.Log(errorMsgPlatform); - return string.Empty; -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + return AdjustiOS.GetIdfa(); + #elif UNITY_ANDROID + Debug.Log("Adjust: Error! IDFA is not available on Android platform."); + return string.Empty; + #elif (UNITY_WSA || UNITY_WP8) + Debug.Log("Adjust: Error! IDFA is not available on Windows platform."); + return string.Empty; + #else + Debug.Log(errorMsgPlatform); + return string.Empty; + #endif + } + else + { + return string.Empty; + } } [Obsolete("This method is intended for testing purposes only. Do not use it.")] public static void setReferrer(string referrer) { -#if UNITY_IOS - Debug.Log("Adjust: Install referrer is not available on iOS platform."); -#elif UNITY_ANDROID - AdjustAndroid.SetReferrer(referrer); -#elif (UNITY_WSA || UNITY_WP8) - Debug.Log("Adjust: Error! Install referrer is not available on Windows platform."); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + Debug.Log("Adjust: Install referrer is not available on iOS platform."); + #elif UNITY_ANDROID + AdjustAndroid.SetReferrer(referrer); + #elif (UNITY_WSA || UNITY_WP8) + Debug.Log("Adjust: Error! Install referrer is not available on Windows platform."); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static void getGoogleAdId(Action onDeviceIdsRead) { -#if UNITY_IOS - Debug.Log("Adjust: Google Play Advertising ID is not available on iOS platform."); - onDeviceIdsRead(string.Empty); -#elif UNITY_ANDROID - AdjustAndroid.GetGoogleAdId(onDeviceIdsRead); -#elif (UNITY_WSA || UNITY_WP8) - Debug.Log("Adjust: Google Play Advertising ID is not available on Windows platform."); - onDeviceIdsRead(string.Empty); -#else - Debug.Log(errorMsgPlatform); -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + Debug.Log("Adjust: Google Play Advertising ID is not available on iOS platform."); + onDeviceIdsRead(string.Empty); + #elif UNITY_ANDROID + AdjustAndroid.GetGoogleAdId(onDeviceIdsRead); + #elif (UNITY_WSA || UNITY_WP8) + Debug.Log("Adjust: Google Play Advertising ID is not available on Windows platform."); + onDeviceIdsRead(string.Empty); + #else + Debug.Log(errorMsgPlatform); + #endif + } } public static string getAmazonAdId() { -#if UNITY_IOS - Debug.Log("Adjust: Amazon Advertising ID is not available on iOS platform."); - return string.Empty; -#elif UNITY_ANDROID - return AdjustAndroid.GetAmazonAdId(); -#elif (UNITY_WSA || UNITY_WP8) - Debug.Log("Adjust: Amazon Advertising ID not available on Windows platform."); - return string.Empty; -#else - Debug.Log(errorMsgPlatform); - return string.Empty; -#endif + if (!Application.isEditor) + { + #if UNITY_IOS + Debug.Log("Adjust: Amazon Advertising ID is not available on iOS platform."); + return string.Empty; + #elif UNITY_ANDROID + return AdjustAndroid.GetAmazonAdId(); + #elif (UNITY_WSA || UNITY_WP8) + Debug.Log("Adjust: Amazon Advertising ID not available on Windows platform."); + return string.Empty; + #else + Debug.Log(errorMsgPlatform); + return string.Empty; + #endif + } + else + { + return string.Empty; + } } #if UNITY_IOS public void GetNativeAttribution(string attributionData) { - if (Adjust.attributionChangedDelegate == null) + if (!Application.isEditor) { - Debug.Log("Adjust: Attribution changed delegate was not set."); - return; + if (Adjust.attributionChangedDelegate == null) + { + Debug.Log("Adjust: Attribution changed delegate was not set."); + return; + } + + var attribution = new AdjustAttribution(attributionData); + Adjust.attributionChangedDelegate(attribution); } - - var attribution = new AdjustAttribution(attributionData); - Adjust.attributionChangedDelegate(attribution); } public void GetNativeEventSuccess(string eventSuccessData) { - if (Adjust.eventSuccessDelegate == null) + if (!Application.isEditor) { - Debug.Log("Adjust: Event success delegate was not set."); - return; + if (Adjust.eventSuccessDelegate == null) + { + Debug.Log("Adjust: Event success delegate was not set."); + return; + } + + var eventSuccess = new AdjustEventSuccess(eventSuccessData); + Adjust.eventSuccessDelegate(eventSuccess); } - - var eventSuccess = new AdjustEventSuccess(eventSuccessData); - Adjust.eventSuccessDelegate(eventSuccess); } public void GetNativeEventFailure(string eventFailureData) { - if (Adjust.eventFailureDelegate == null) + if (!Application.isEditor) { - Debug.Log("Adjust: Event failure delegate was not set."); - return; + if (Adjust.eventFailureDelegate == null) + { + Debug.Log("Adjust: Event failure delegate was not set."); + return; + } + + var eventFailure = new AdjustEventFailure(eventFailureData); + Adjust.eventFailureDelegate(eventFailure); } - - var eventFailure = new AdjustEventFailure(eventFailureData); - Adjust.eventFailureDelegate(eventFailure); } public void GetNativeSessionSuccess(string sessionSuccessData) { - if (Adjust.sessionSuccessDelegate == null) + if (!Application.isEditor) { - Debug.Log("Adjust: Session success delegate was not set."); - return; + if (Adjust.sessionSuccessDelegate == null) + { + Debug.Log("Adjust: Session success delegate was not set."); + return; + } + + var sessionSuccess = new AdjustSessionSuccess(sessionSuccessData); + Adjust.sessionSuccessDelegate(sessionSuccess); } - - var sessionSuccess = new AdjustSessionSuccess(sessionSuccessData); - Adjust.sessionSuccessDelegate(sessionSuccess); } public void GetNativeSessionFailure(string sessionFailureData) { - if (Adjust.sessionFailureDelegate == null) + if (!Application.isEditor) { - Debug.Log("Adjust: Session failure delegate was not set."); - return; + if (Adjust.sessionFailureDelegate == null) + { + Debug.Log("Adjust: Session failure delegate was not set."); + return; + } + + var sessionFailure = new AdjustSessionFailure(sessionFailureData); + Adjust.sessionFailureDelegate(sessionFailure); } - - var sessionFailure = new AdjustSessionFailure(sessionFailureData); - Adjust.sessionFailureDelegate(sessionFailure); } public void GetNativeDeferredDeeplink(string deeplinkURL) { - if (Adjust.deferredDeeplinkDelegate == null) + if (!Application.isEditor) { - Debug.Log("Adjust: Deferred deeplink delegate was not set."); - return; - } + if (Adjust.deferredDeeplinkDelegate == null) + { + Debug.Log("Adjust: Deferred deeplink delegate was not set."); + return; + } - Adjust.deferredDeeplinkDelegate(deeplinkURL); + Adjust.deferredDeeplinkDelegate(deeplinkURL); + } } #endif } diff --git a/Assets/Adjust/Android/AdjustAndroid.cs b/Assets/Adjust/Android/AdjustAndroid.cs index d0a0e541..9498d996 100644 --- a/Assets/Adjust/Android/AdjustAndroid.cs +++ b/Assets/Adjust/Android/AdjustAndroid.cs @@ -9,7 +9,7 @@ namespace com.adjust.sdk #if UNITY_ANDROID public class AdjustAndroid { - private const string sdkPrefix = "unity4.12.1"; + private const string sdkPrefix = "unity4.12.2"; private static bool launchDeferredDeeplink = true; diff --git a/Assets/Adjust/Windows/AdjustWindows.cs b/Assets/Adjust/Windows/AdjustWindows.cs index b134097b..81474619 100644 --- a/Assets/Adjust/Windows/AdjustWindows.cs +++ b/Assets/Adjust/Windows/AdjustWindows.cs @@ -16,7 +16,7 @@ namespace com.adjust.sdk { public class AdjustWindows { - private const string sdkPrefix = "unity4.12.1"; + private const string sdkPrefix = "unity4.12.2"; private static bool appLaunched = false; public static void Start(AdjustConfig adjustConfig) diff --git a/Assets/Adjust/iOS/AdjustUnity.mm b/Assets/Adjust/iOS/AdjustUnity.mm index 76b952b9..a00ed756 100644 --- a/Assets/Adjust/iOS/AdjustUnity.mm +++ b/Assets/Adjust/iOS/AdjustUnity.mm @@ -14,7 +14,7 @@ - (id)init { @end // Method for converting JSON stirng parameters into NSArray object. -NSArray* ConvertArrayParameters(const char* cStringJsonArrayParameters) { +NSArray* convertArrayParameters(const char* cStringJsonArrayParameters) { if (cStringJsonArrayParameters == NULL) { return nil; } @@ -36,6 +36,23 @@ - (id)init { return arrayParameters; } +BOOL isStringValid(const char* cString) { + if (cString == NULL) { + return false; + } + + NSString *objcString = [NSString stringWithUTF8String:cString]; + if (objcString == nil) { + return false; + } + + if ([objcString isEqualToString:@"ADJ_INVALID"]) { + return false; + } + + return true; +} + extern "C" { void addValueOrEmpty(NSMutableDictionary *dictionary, NSString *key, NSObject *value) { @@ -46,37 +63,36 @@ void addValueOrEmpty(NSMutableDictionary *dictionary, NSString *key, NSObject *v } } - void _AdjustLaunchApp( - const char* appToken, - const char* environment, - const char* sdkPrefix, - int allowSuppressLogLevel, - int logLevel, - int isDeviceKnown, - int eventBuffering, - int sendInBackground, - long secretId, - long info1, - long info2, - long info3, - long info4, - double delayStart, - const char* userAgent, - const char* defaultTracker, - int launchDeferredDeeplink, - const char* sceneName, - int isAttributionCallbackImplemented, - int isEventSuccessCallbackImplemented, - int isEventFailureCallbackImplemented, - int isSessionSuccessCallbackImplemented, - int isSessionFailureCallbackImplemented, - int isDeferredDeeplinkCallbackImplemented) { - NSString *stringSdkPrefix = [NSString stringWithUTF8String:sdkPrefix]; - NSString *stringAppToken = [NSString stringWithUTF8String:appToken]; - NSString *stringEnvironment = [NSString stringWithUTF8String:environment]; - NSString *stringUserAgent = [NSString stringWithUTF8String:userAgent]; - NSString *stringDefaultTracker = [NSString stringWithUTF8String:defaultTracker]; - NSString *stringSceneName = [NSString stringWithUTF8String:sceneName]; + void _AdjustLaunchApp(const char* appToken, + const char* environment, + const char* sdkPrefix, + const char* userAgent, + const char* defaultTracker, + const char* sceneName, + int allowSuppressLogLevel, + int logLevel, + int isDeviceKnown, + int eventBuffering, + int sendInBackground, + long secretId, + long info1, + long info2, + long info3, + long info4, + double delayStart, + int launchDeferredDeeplink, + int isAttributionCallbackImplemented, + int isEventSuccessCallbackImplemented, + int isEventFailureCallbackImplemented, + int isSessionSuccessCallbackImplemented, + int isSessionFailureCallbackImplemented, + int isDeferredDeeplinkCallbackImplemented) { + NSString *stringAppToken = isStringValid(appToken) == true ? [NSString stringWithUTF8String:appToken] : nil; + NSString *stringEnvironment = isStringValid(environment) == true ? [NSString stringWithUTF8String:environment] : nil; + NSString *stringSdkPrefix = isStringValid(sdkPrefix) == true ? [NSString stringWithUTF8String:sdkPrefix] : nil; + NSString *stringUserAgent = isStringValid(userAgent) == true ? [NSString stringWithUTF8String:userAgent] : nil; + NSString *stringDefaultTracker = isStringValid(defaultTracker) == true ? [NSString stringWithUTF8String:defaultTracker] : nil; + NSString *stringSceneName = isStringValid(sceneName) == true ? [NSString stringWithUTF8String:sceneName] : nil; ADJConfig *adjustConfig; @@ -92,9 +108,12 @@ void _AdjustLaunchApp( [adjustConfig setSdkPrefix:stringSdkPrefix]; // Attribution delegate & other delegates - if (isAttributionCallbackImplemented || isEventSuccessCallbackImplemented || - isEventFailureCallbackImplemented || isSessionSuccessCallbackImplemented || - isSessionFailureCallbackImplemented || isDeferredDeeplinkCallbackImplemented) { + if (isAttributionCallbackImplemented + || isEventSuccessCallbackImplemented + || isEventFailureCallbackImplemented + || isSessionSuccessCallbackImplemented + || isSessionFailureCallbackImplemented + || isDeferredDeeplinkCallbackImplemented) { [adjustConfig setDelegate: [AdjustUnityDelegate getInstanceWithSwizzleOfAttributionCallback:isAttributionCallbackImplemented eventSucceededCallback:isEventSuccessCallbackImplemented @@ -127,16 +146,12 @@ void _AdjustLaunchApp( [adjustConfig setDelayStart:delayStart]; } - if (stringUserAgent != NULL) { - if ([stringUserAgent length] > 0) { - [adjustConfig setUserAgent:stringUserAgent]; - } + if (stringUserAgent != nil) { + [adjustConfig setUserAgent:stringUserAgent]; } - if (stringDefaultTracker != NULL) { - if ([stringDefaultTracker length] > 0) { - [adjustConfig setDefaultTracker:stringDefaultTracker]; - } + if (stringDefaultTracker != nil) { + [adjustConfig setDefaultTracker:stringDefaultTracker]; } if (secretId != -1 && info1 != -1 && info2 != -1 && info3 != -1 && info4 != 1) { @@ -145,12 +160,17 @@ void _AdjustLaunchApp( // Launch adjust instance. [Adjust appDidLaunch:adjustConfig]; - - // Since v4.7.0 session is not automatically started after calling appDidLaunch, thus calling trackSubsessionStart. [Adjust trackSubsessionStart]; } - void _AdjustTrackEvent(const char* eventToken, double revenue, const char* currency, const char* receipt, const char* transactionId, int isReceiptSet, const char* jsonCallbackParameters, const char* jsonPartnerParameters) { + void _AdjustTrackEvent(const char* eventToken, + double revenue, + const char* currency, + const char* receipt, + const char* transactionId, + int isReceiptSet, + const char* jsonCallbackParameters, + const char* jsonPartnerParameters) { NSString *stringEventToken = [NSString stringWithUTF8String:eventToken]; ADJEvent *event = [ADJEvent eventWithEventToken:stringEventToken]; @@ -161,7 +181,7 @@ void _AdjustTrackEvent(const char* eventToken, double revenue, const char* curre [event setRevenue:revenue currency:stringCurrency]; } - NSArray *arrayCallbackParameters = ConvertArrayParameters(jsonCallbackParameters); + NSArray *arrayCallbackParameters = convertArrayParameters(jsonCallbackParameters); if (arrayCallbackParameters != nil) { NSUInteger count = [arrayCallbackParameters count]; @@ -177,7 +197,7 @@ void _AdjustTrackEvent(const char* eventToken, double revenue, const char* curre } } - NSArray *arrayPartnerParameters = ConvertArrayParameters(jsonPartnerParameters); + NSArray *arrayPartnerParameters = convertArrayParameters(jsonPartnerParameters); if (arrayPartnerParameters != nil) { NSUInteger count = [arrayPartnerParameters count]; diff --git a/Assets/Adjust/iOS/AdjustiOS.cs b/Assets/Adjust/iOS/AdjustiOS.cs index d37cf82b..d74a98d9 100644 --- a/Assets/Adjust/iOS/AdjustiOS.cs +++ b/Assets/Adjust/iOS/AdjustiOS.cs @@ -9,13 +9,16 @@ namespace com.adjust.sdk #if UNITY_IOS public class AdjustiOS { - private const string sdkPrefix = "unity4.12.1"; + private const string sdkPrefix = "unity4.12.2"; [DllImport("__Internal")] private static extern void _AdjustLaunchApp( string appToken, string environment, string sdkPrefix, + string userAgent, + string defaultTracker, + string sceneName, int allowSuppressLogLevel, int logLevel, int isDeviceKnown, @@ -27,10 +30,7 @@ private static extern void _AdjustLaunchApp( long info3, long info4, double delayStart, - string userAgent, - string defaultTracker, int launchDeferredDeeplink, - string sceneName, int isAttributionCallbackImplemented, int isEventSuccessCallbackImplemented, int isEventFailureCallbackImplemented, @@ -98,10 +98,10 @@ public AdjustiOS() {} public static void Start(AdjustConfig adjustConfig) { - string appToken = adjustConfig.appToken; - string sceneName = adjustConfig.sceneName; - string userAgent = adjustConfig.userAgent != null ? adjustConfig.userAgent : String.Empty; - string defaultTracker = adjustConfig.defaultTracker != null ? adjustConfig.defaultTracker : String.Empty; + string appToken = adjustConfig.appToken != null ? adjustConfig.appToken : "ADJ_INVALID"; + string sceneName = adjustConfig.sceneName != null ? adjustConfig.sceneName : "ADJ_INVALID"; + string userAgent = adjustConfig.userAgent != null ? adjustConfig.userAgent : "ADJ_INVALID"; + string defaultTracker = adjustConfig.defaultTracker != null ? adjustConfig.defaultTracker : "ADJ_INVALID"; string environment = adjustConfig.environment.ToLowercaseString(); long info1 = AdjustUtils.ConvertLong(adjustConfig.info1); @@ -130,6 +130,9 @@ public static void Start(AdjustConfig adjustConfig) appToken, environment, sdkPrefix, + userAgent, + defaultTracker, + sceneName, allowSuppressLogLevel, logLevel, isDeviceKnown, @@ -141,10 +144,7 @@ public static void Start(AdjustConfig adjustConfig) info3, info4, delayStart, - userAgent, - defaultTracker, launchDeferredDeeplink, - sceneName, isAttributionCallbackImplemented, isEventSuccessCallbackImplemented, isEventFailureCallbackImplemented, diff --git a/CHANGELOG.md b/CHANGELOG.md index 5605a4a2..ef72c724 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +### Version 4.12.2 (9th February 2018) +#### Fixed +- Fixed Adjust SDK behaviour once tried to be run in `Editor` - no errors displayed anymore. +- Fixed random crashes on iOS 10.1.x devices when trying to initialise SDK. + +#### Native SDKs +- [iOS@v4.12.1][ios_sdk_v4.12.1] +- [Android@v4.12.1][android_sdk_v4.12.1] +- [Windows@v4.12.0][windows_sdk_v4.12.0] + +--- + ### Version 4.12.1 (1st February 2018) #### Native changes - https://github.com/adjust/android_sdk/blob/master/CHANGELOG.md#version-4121-31st-january-2018 diff --git a/VERSION b/VERSION index 53cf85e1..f1cd7de1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.12.1 +4.12.2 diff --git a/doc/migrate.md b/doc/migrate.md index e4d4aa2d..70a55bf6 100644 --- a/doc/migrate.md +++ b/doc/migrate.md @@ -1,4 +1,4 @@ -## Migrate your Adjust SDK for Unity3d to 4.12.1 from 3.4.4 +## Migrate your Adjust SDK for Unity3d to 4.12.2 from 3.4.4 ### Migration procedure @@ -9,7 +9,7 @@ keeping in `Assets/Plugins` folder. For migration purposes, we have prepared the Adjust SDK uninstall script written in Python (`adjust_uninstall.py`). -Migration to version 4.12.1 of our SDK requires the following steps: +Migration to version 4.12.2 of our SDK requires the following steps: 1. Copy the `adjust_uninstall.py` script to your root Unity project directory and run it. This script should delete all adjust source files from the previous SDK version you had.