Beispiel #1
0
 public static void Init(string buildVersion, bool usePersistentPath, Dictionary <string, object> defaultValues, Endpoint endpoint = Endpoint.Sandbox)
 {
     if (string.IsNullOrEmpty(Application.cloudProjectId))
     {
         throw new Exception("You must enable Analytics to be able to use AutoTune");
     }
     GetInstance()._projectId           = Application.cloudProjectId;
     GetInstance()._clientDefaultConfig = new SegmentConfig(CLIENT_DEFAULT_SEGMENT, CLIENT_DEFAULT_GROUP, defaultValues, "client_default");
     GetInstance()._storePath           = ((!usePersistentPath) ? Application.temporaryCachePath : Application.persistentDataPath);
     GetInstance()._buildVersion        = buildVersion;
     GetInstance()._endpoint            = endpoint;
     GetInstance().LoadCacheSegmentConfig();
     _prInstance.SetBuildVersion(buildVersion);
     ServicePointManager.ServerCertificateValidationCallback = (RemoteCertificateValidationCallback)Delegate.Combine(ServicePointManager.ServerCertificateValidationCallback, (RemoteCertificateValidationCallback)((object o, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true));
 }
        /// <summary>
        /// Setups the AutoTune API. Make sure you call this before
        /// anything.
        /// <param name="sheetId">The google sheet id where you defined the segments and configs.</param>
        /// <param name="buildVersion">The build version.</param>
        /// <param name="usePersistentPath">True to use persistentDataPath for storing segment config, otherwise temporaryCachePath would be use.</param>
        /// <param name="defaultValues">The default values that will be used in case of network error.</param>
        /// </summary>
        public static void Init(string sheetId,
                                string buildVersion,
                                bool usePersistentPath,
                                Dictionary <string, object> defaultValues
                                )
        {
            GetInstance()._sheetId             = sheetId;
            GetInstance()._clientDefaultConfig = new SegmentConfig(CLIENT_DEFAULT_SEGMENT, CLIENT_DEFAULT_GROUP, defaultValues, "client_default");

            // Application.persistentDataPath can only be called from the main thread so we cache it in init
            GetInstance()._storePath    = usePersistentPath ? Application.persistentDataPath : Application.temporaryCachePath;
            GetInstance()._buildVersion = buildVersion;

            // load cache segment config last after all other variables has been set
            GetInstance().LoadCacheSegmentConfig();
            _prInstance.SetBuildVersion(buildVersion);
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
        }