コード例 #1
0
    private void StartAppCenter()
    {
        if (Settings == null)
        {
            Debug.LogError("App Center isn't configured!");
            return;
        }
        var services = Settings.Services;

        PrepareEventHandlers(services);
        InvokeInitializingServices();
        AppCenter.SetWrapperSdk();
        AppCenter.CacheStorageSize(Settings.MaxStorageSize.Size);
        if (Settings.CustomLogUrl.UseCustomUrl)
        {
            AppCenter.CacheLogUrl(Settings.CustomLogUrl.Url);
        }
        var appSecret        = AppCenter.ParseAndSaveSecretForPlatform(Settings.AppSecret);
        var advancedSettings = GetComponent <AppCenterBehaviorAdvanced>();

        if (IsStartFromAppCenterBehavior(advancedSettings))
        {
            AppCenter.LogLevel = Settings.InitialLogLevel;
            if (Settings.CustomLogUrl.UseCustomUrl)
            {
                AppCenter.SetLogUrl(Settings.CustomLogUrl.Url);
            }
            if (Settings.MaxStorageSize.UseCustomMaxStorageSize && Settings.MaxStorageSize.Size > 0)
            {
                AppCenterInternal.SetMaxStorageSize(Settings.MaxStorageSize.Size);
            }
            var startupType = GetStartupType(advancedSettings);
            if (startupType != StartupType.Skip)
            {
                var transmissionTargetToken = GetTransmissionTargetToken(advancedSettings);
                var appSecretString         = GetAppSecretString(appSecret, transmissionTargetToken, startupType);
                if (string.IsNullOrEmpty(appSecretString))
                {
                    AppCenterInternal.Start(services);
                }
                else
                {
                    AppCenterInternal.Start(appSecretString, services);
                }
            }
        }
#if UNITY_IOS || UNITY_ANDROID
        else
        {
            foreach (var service in services)
            {
#if UNITY_IOS || UNITY_ANDROID
                // On iOS and Android we start crash service here, to give app an opportunity to assign handlers after crash and restart in Awake method
                var startCrashes = service.GetMethod("StartCrashes");
                if (startCrashes != null)
                {
                    startCrashes.Invoke(null, null);
                }
#endif
            }
        }
#endif
        InvokeInitializedServices();
        if (Started != null)
        {
            Started.Invoke();
        }
    }