Пример #1
0
        public override void OnCreate()
        {
            base.OnCreate();

            // Configure Adjust.
            const String appToken    = "2fm9gkqubvpc";
            const String environment = AdjustConfig.EnvironmentSandbox;
            AdjustConfig config      = new AdjustConfig(this, appToken, environment);

            // Change the log level.
            config.SetLogLevel(LogLevel.Verbose);

            // Enable event buffering.
            // config.SetEventBufferingEnabled((Java.Lang.Boolean)true);

            // Enable background tracking.
            config.SetSendInBackground(true);

            // Set default tracker.
            // config.SetDefaultTracker("{YourDefaultTracker}");

            // Set attribution callback.
            config.SetOnAttributionChangedListener(this);

            // Set session callbacks.
            config.SetOnSessionTrackingFailedListener(this);
            config.SetOnSessionTrackingSucceededListener(this);

            // Set event callbacks.
            config.SetOnEventTrackingFailedListener(this);
            config.SetOnEventTrackingSucceededListener(this);

            // Set deferred deeplink callback.
            config.SetOnDeeplinkResponseListener(this);

            // Add session callback parameters.
            Adjust.AddSessionCallbackParameter("scp_foo", "scp_bar");
            Adjust.AddSessionCallbackParameter("scp_key", "scp_value");

            // Remove session callback parameters.
            Adjust.RemoveSessionCallbackParameter("scp_foo");
            Adjust.RemoveSessionCallbackParameter("scp_key");

            // Add session partner parameters.
            Adjust.AddSessionPartnerParameter("spp_a", "spp_b");
            Adjust.AddSessionPartnerParameter("spp_x", "spp_y");

            // Remove session partner parameters.
            Adjust.RemoveSessionPartnerParameter("scp_a");
            Adjust.RemoveSessionPartnerParameter("scp_x");

            // Clear all session callback parameters.
            Adjust.ResetSessionCallbackParameters();

            // Clear all session partner parameters.
            Adjust.ResetSessionPartnerParameters();

            Adjust.OnCreate(config);

            // Put the SDK in offline mode.
            // Adjust.SetOfflineMode(true);

            // Disable the SDK.
            // Adjust.Enabled = false;

            // Send push notification token once you have obtained it or when it changes the value.
            Adjust.SetPushToken("YourPushNotificationToken");

            RegisterActivityLifecycleCallbacks(new ActivityLifecycleCallbacks());
        }
Пример #2
0
        private void Config()
        {
            var configNumber = 0;

            if (Command.ContainsParameter("configName"))
            {
                var configName = Command.GetFirstParameterValue("configName");
                configNumber = int.Parse(configName.Substring(configName.Length - 1));
            }

            AdjustConfig adjustConfig;
            LogLevel     logLevel = null;

            if (Command.ContainsParameter("logLevel"))
            {
                var logLevelString = Command.GetFirstParameterValue("logLevel");
                switch (logLevelString)
                {
                case "verbose":
                    logLevel = LogLevel.Verbose;
                    break;

                case "debug":
                    logLevel = LogLevel.Debug;
                    break;

                case "info":
                    logLevel = LogLevel.Info;
                    break;

                case "warn":
                    logLevel = LogLevel.Warn;
                    break;

                case "error":
                    logLevel = LogLevel.Error;
                    break;

                case "assert":
                    logLevel = LogLevel.Assert;
                    break;

                case "suppress":
                    logLevel = LogLevel.Supress;
                    break;
                }

                Console.WriteLine(TAG + ": TestApp LogLevel = {0}", logLevel);
            }

            if (_savedConfigs.ContainsKey(configNumber))
            {
                adjustConfig = _savedConfigs[configNumber];
            }
            else
            {
                var environment = Command.GetFirstParameterValue("environment");
                var appToken    = Command.GetFirstParameterValue("appToken");
                adjustConfig = new AdjustConfig(_context, appToken, environment);

                if (logLevel != null)
                {
                    adjustConfig.SetLogLevel(logLevel);
                }
                else
                {
                    adjustConfig.SetLogLevel(LogLevel.Verbose);
                }

                _savedConfigs.Add(configNumber, adjustConfig);
            }

            if (Command.ContainsParameter("sdkPrefix"))
            {
                adjustConfig.SetSdkPrefix(Command.GetFirstParameterValue("sdkPrefix"));
            }

            if (Command.ContainsParameter("defaultTracker"))
            {
                adjustConfig.SetDefaultTracker(Command.GetFirstParameterValue("defaultTracker"));
            }

            if (Command.ContainsParameter("externalDeviceId"))
            {
                adjustConfig.SetExternalDeviceId(Command.GetFirstParameterValue("externalDeviceId"));
            }

            if (Command.ContainsParameter("delayStart"))
            {
                var delayStartStr = Command.GetFirstParameterValue("delayStart");
                var delayStart    = double.Parse(delayStartStr);
                Console.WriteLine(TAG + ": Delay start set to: " + delayStart);
                adjustConfig.SetDelayStart(delayStart);
            }

            if (Command.ContainsParameter("appSecret"))
            {
                var appSecretList = Command.Parameters["appSecret"];
                Console.WriteLine(TAG + ": Received AppSecret array: " + string.Join(",", appSecretList));

                if (!string.IsNullOrEmpty(appSecretList[0]) && appSecretList.Count == 5)
                {
                    long secretId, info1, info2, info3, info4;
                    long.TryParse(appSecretList[0], out secretId);
                    long.TryParse(appSecretList[1], out info1);
                    long.TryParse(appSecretList[2], out info2);
                    long.TryParse(appSecretList[3], out info3);
                    long.TryParse(appSecretList[4], out info4);

                    adjustConfig.SetAppSecret(secretId, info1, info2, info3, info4);
                }
                else
                {
                    Console.WriteLine(TAG + ": App secret list does not contain 5 elements! Skip setting app secret.");
                }
            }

            if (Command.ContainsParameter("deviceKnown"))
            {
                var deviceKnownS = Command.GetFirstParameterValue("deviceKnown");
                var deviceKnown  = deviceKnownS.ToLower() == "true";
                adjustConfig.SetDeviceKnown(deviceKnown);
            }

            if (Command.ContainsParameter("eventBufferingEnabled"))
            {
                var eventBufferingEnabledS = Command.GetFirstParameterValue("eventBufferingEnabled");
                var eventBufferingEnabled  = new Java.Lang.Boolean(eventBufferingEnabledS.ToLower() == "true");
                adjustConfig.SetEventBufferingEnabled(eventBufferingEnabled);
            }

            if (Command.ContainsParameter("sendInBackground"))
            {
                var sendInBackgroundS = Command.GetFirstParameterValue("sendInBackground");
                var sendInBackground  = sendInBackgroundS.ToLower() == "true";
                adjustConfig.SetSendInBackground(sendInBackground);
            }

            if (Command.ContainsParameter("userAgent"))
            {
                var userAgent = Command.GetFirstParameterValue("userAgent");
                adjustConfig.SetUserAgent(userAgent);
            }

            if (Command.ContainsParameter("deferredDeeplinkCallback"))
            {
                adjustConfig.SetOnDeeplinkResponseListener(this);
            }

            if (Command.ContainsParameter("attributionCallbackSendAll"))
            {
                adjustConfig.SetOnAttributionChangedListener(this);
            }

            if (Command.ContainsParameter("sessionCallbackSendSuccess"))
            {
                adjustConfig.SetOnSessionTrackingSucceededListener(this);
            }

            if (Command.ContainsParameter("sessionCallbackSendFailure"))
            {
                adjustConfig.SetOnSessionTrackingFailedListener(this);
            }

            if (Command.ContainsParameter("eventCallbackSendSuccess"))
            {
                adjustConfig.SetOnEventTrackingSucceededListener(this);
            }

            if (Command.ContainsParameter("eventCallbackSendFailure"))
            {
                adjustConfig.SetOnEventTrackingFailedListener(this);
            }
        }