Exemplo n.º 1
0
        public static void Start(AdjustConfig adjustConfig)
        {
            AndroidJavaObject androidJavaObject = (adjustConfig.environment != AdjustEnvironment.Sandbox) ? new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic <AndroidJavaObject>("ENVIRONMENT_PRODUCTION") : new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic <AndroidJavaObject>("ENVIRONMENT_SANDBOX");
            bool?allowSuppressLogLevel          = adjustConfig.allowSuppressLogLevel;
            AndroidJavaObject androidJavaObject2;

            if (allowSuppressLogLevel != null)
            {
                androidJavaObject2 = new AndroidJavaObject("com.adjust.sdk.AdjustConfig", new object[]
                {
                    AdjustAndroid.ajoCurrentActivity,
                    adjustConfig.appToken,
                    androidJavaObject,
                    adjustConfig.allowSuppressLogLevel
                });
            }
            else
            {
                androidJavaObject2 = new AndroidJavaObject("com.adjust.sdk.AdjustConfig", new object[]
                {
                    AdjustAndroid.ajoCurrentActivity,
                    adjustConfig.appToken,
                    androidJavaObject
                });
            }
            AdjustAndroid.launchDeferredDeeplink = adjustConfig.launchDeferredDeeplink;
            AdjustLogLevel?logLevel = adjustConfig.logLevel;

            if (logLevel != null)
            {
                AndroidJavaObject @static;
                if (adjustConfig.logLevel.Value.ToUppercaseString().Equals("SUPPRESS"))
                {
                    @static = new AndroidJavaClass("com.adjust.sdk.LogLevel").GetStatic <AndroidJavaObject>("SUPRESS");
                }
                else
                {
                    @static = new AndroidJavaClass("com.adjust.sdk.LogLevel").GetStatic <AndroidJavaObject>(adjustConfig.logLevel.Value.ToUppercaseString());
                }
                if (@static != null)
                {
                    androidJavaObject2.Call("setLogLevel", new object[]
                    {
                        @static
                    });
                }
            }
            androidJavaObject2.Call("setSdkPrefix", new object[]
            {
                "unity4.14.1"
            });
            double?delayStart = adjustConfig.delayStart;

            if (delayStart != null)
            {
                androidJavaObject2.Call("setDelayStart", new object[]
                {
                    adjustConfig.delayStart
                });
            }
            bool?eventBufferingEnabled = adjustConfig.eventBufferingEnabled;

            if (eventBufferingEnabled != null)
            {
                AndroidJavaObject androidJavaObject3 = new AndroidJavaObject("java.lang.Boolean", new object[]
                {
                    adjustConfig.eventBufferingEnabled.Value
                });
                androidJavaObject2.Call("setEventBufferingEnabled", new object[]
                {
                    androidJavaObject3
                });
            }
            bool?sendInBackground = adjustConfig.sendInBackground;

            if (sendInBackground != null)
            {
                androidJavaObject2.Call("setSendInBackground", new object[]
                {
                    adjustConfig.sendInBackground.Value
                });
            }
            if (adjustConfig.userAgent != null)
            {
                androidJavaObject2.Call("setUserAgent", new object[]
                {
                    adjustConfig.userAgent
                });
            }
            if (!string.IsNullOrEmpty(adjustConfig.processName))
            {
                androidJavaObject2.Call("setProcessName", new object[]
                {
                    adjustConfig.processName
                });
            }
            if (adjustConfig.defaultTracker != null)
            {
                androidJavaObject2.Call("setDefaultTracker", new object[]
                {
                    adjustConfig.defaultTracker
                });
            }
            if (AdjustAndroid.IsAppSecretSet(adjustConfig))
            {
                androidJavaObject2.Call("setAppSecret", new object[]
                {
                    adjustConfig.secretId.Value,
                    adjustConfig.info1.Value,
                    adjustConfig.info2.Value,
                    adjustConfig.info3.Value,
                    adjustConfig.info4.Value
                });
            }
            if (adjustConfig.isDeviceKnown != null)
            {
                androidJavaObject2.Call("setDeviceKnown", new object[]
                {
                    adjustConfig.isDeviceKnown.Value
                });
            }
            if (adjustConfig.readImei != null)
            {
                androidJavaObject2.Call("setReadMobileEquipmentIdentity", new object[]
                {
                    adjustConfig.readImei.Value
                });
            }
            if (adjustConfig.attributionChangedDelegate != null)
            {
                AdjustAndroid.onAttributionChangedListener = new AdjustAndroid.AttributionChangeListener(adjustConfig.attributionChangedDelegate);
                androidJavaObject2.Call("setOnAttributionChangedListener", new object[]
                {
                    AdjustAndroid.onAttributionChangedListener
                });
            }
            if (adjustConfig.eventSuccessDelegate != null)
            {
                AdjustAndroid.onEventTrackingSucceededListener = new AdjustAndroid.EventTrackingSucceededListener(adjustConfig.eventSuccessDelegate);
                androidJavaObject2.Call("setOnEventTrackingSucceededListener", new object[]
                {
                    AdjustAndroid.onEventTrackingSucceededListener
                });
            }
            if (adjustConfig.eventFailureDelegate != null)
            {
                AdjustAndroid.onEventTrackingFailedListener = new AdjustAndroid.EventTrackingFailedListener(adjustConfig.eventFailureDelegate);
                androidJavaObject2.Call("setOnEventTrackingFailedListener", new object[]
                {
                    AdjustAndroid.onEventTrackingFailedListener
                });
            }
            if (adjustConfig.sessionSuccessDelegate != null)
            {
                AdjustAndroid.onSessionTrackingSucceededListener = new AdjustAndroid.SessionTrackingSucceededListener(adjustConfig.sessionSuccessDelegate);
                androidJavaObject2.Call("setOnSessionTrackingSucceededListener", new object[]
                {
                    AdjustAndroid.onSessionTrackingSucceededListener
                });
            }
            if (adjustConfig.sessionFailureDelegate != null)
            {
                AdjustAndroid.onSessionTrackingFailedListener = new AdjustAndroid.SessionTrackingFailedListener(adjustConfig.sessionFailureDelegate);
                androidJavaObject2.Call("setOnSessionTrackingFailedListener", new object[]
                {
                    AdjustAndroid.onSessionTrackingFailedListener
                });
            }
            if (adjustConfig.deferredDeeplinkDelegate != null)
            {
                AdjustAndroid.onDeferredDeeplinkListener = new AdjustAndroid.DeferredDeeplinkListener(adjustConfig.deferredDeeplinkDelegate);
                androidJavaObject2.Call("setOnDeeplinkResponseListener", new object[]
                {
                    AdjustAndroid.onDeferredDeeplinkListener
                });
            }
            AdjustAndroid.ajcAdjust.CallStatic("onCreate", new object[]
            {
                androidJavaObject2
            });
            AdjustAndroid.ajcAdjust.CallStatic("onResume", new object[0]);
        }