コード例 #1
0
ファイル: AdjustWindows.cs プロジェクト: eliatlas/unity_sdk
        public static void Start(AdjustConfig adjustConfig)
        {
            string logLevelString = null;
            string environment    = adjustConfig.environment.ToLowercaseString();

            Action <Dictionary <string, string> > attributionChangedAction    = null;
            Action <Dictionary <string, string> > sessionSuccessChangedAction = null;
            Action <Dictionary <string, string> > sessionFailureChangedAction = null;
            Action <Dictionary <string, string> > eventSuccessChangedAction   = null;
            Action <Dictionary <string, string> > eventFailureChangedAction   = null;
            Func <string, bool> deeplinkResponseFunc = null;

            if (adjustConfig.logLevel.HasValue)
            {
                logLevelString = adjustConfig.logLevel.Value.ToLowercaseString();
            }

            if (adjustConfig.attributionChangedDelegate != null)
            {
                attributionChangedAction = (attributionMap) =>
                {
                    var attribution = new AdjustAttribution(attributionMap);
                    adjustConfig.attributionChangedDelegate(attribution);
                };
            }

            if (adjustConfig.sessionSuccessDelegate != null)
            {
                sessionSuccessChangedAction = (sessionMap) =>
                {
                    var sessionData = new AdjustSessionSuccess(sessionMap);
                    adjustConfig.sessionSuccessDelegate(sessionData);
                };
            }

            if (adjustConfig.sessionFailureDelegate != null)
            {
                sessionFailureChangedAction = (sessionMap) =>
                {
                    var sessionData = new AdjustSessionFailure(sessionMap);
                    adjustConfig.sessionFailureDelegate(sessionData);
                };
            }

            if (adjustConfig.eventSuccessDelegate != null)
            {
                eventSuccessChangedAction = (eventMap) =>
                {
                    var eventData = new AdjustEventSuccess(eventMap);
                    adjustConfig.eventSuccessDelegate(eventData);
                };
            }

            if (adjustConfig.eventFailureDelegate != null)
            {
                eventFailureChangedAction = (eventMap) =>
                {
                    var eventData = new AdjustEventFailure(eventMap);
                    adjustConfig.eventFailureDelegate(eventData);
                };
            }

            if (adjustConfig.deferredDeeplinkDelegate != null)
            {
                deeplinkResponseFunc = uri =>
                {
                    if (adjustConfig.launchDeferredDeeplink)
                    {
                        adjustConfig.deferredDeeplinkDelegate(uri);
                    }

                    return(adjustConfig.launchDeferredDeeplink);
                };
            }

            bool sendInBackground = false;

            if (adjustConfig.sendInBackground.HasValue)
            {
                sendInBackground = adjustConfig.sendInBackground.Value;
            }

            double delayStartSeconds = 0;

            if (adjustConfig.delayStart.HasValue)
            {
                delayStartSeconds = adjustConfig.delayStart.Value;
            }

            AdjustConfigDto adjustConfigDto = new AdjustConfigDto {
                AppToken                     = adjustConfig.appToken,
                Environment                  = environment,
                SdkPrefix                    = sdkPrefix,
                SendInBackground             = sendInBackground,
                DelayStart                   = delayStartSeconds,
                UserAgent                    = adjustConfig.userAgent,
                DefaultTracker               = adjustConfig.defaultTracker,
                EventBufferingEnabled        = adjustConfig.eventBufferingEnabled,
                LaunchDeferredDeeplink       = adjustConfig.launchDeferredDeeplink,
                LogLevelString               = logLevelString,
                LogDelegate                  = adjustConfig.logDelegate,
                ActionAttributionChangedData = attributionChangedAction,
                ActionSessionSuccessData     = sessionSuccessChangedAction,
                ActionSessionFailureData     = sessionFailureChangedAction,
                ActionEventSuccessData       = eventSuccessChangedAction,
                ActionEventFailureData       = eventFailureChangedAction,
                FuncDeeplinkResponseData     = deeplinkResponseFunc,
                IsDeviceKnown                = adjustConfig.isDeviceKnown,
                SecretId                     = adjustConfig.secretId,
                Info1 = adjustConfig.info1,
                Info2 = adjustConfig.info2,
                Info3 = adjustConfig.info3,
                Info4 = adjustConfig.info4
            };

            AdjustWinInterface.ApplicationLaunching(adjustConfigDto);
            AdjustWinInterface.ApplicationActivated();
            appLaunched = true;
        }