void StartFetchData() { isFetchInProgress = true; Task fetchTask = FirebaseRemoteConfig.FetchAsync(GetCacheExpiration()); fetchTask.ContinueWith(FetchComplete); }
/** * Fetch discount from server. */ private async System.Threading.Tasks.Task FetchDiscount() { mPriceTextView.SetText(LOADING_PHRASE_CONFIG_KEY, null); long cacheExpiration = 3600; // 1 hour in seconds. // If in developer mode cacheExpiration is set to 0 so each fetch will retrieve values from // the server. if (mFirebaseRemoteConfig.Info.ConfigSettings.IsDeveloperModeEnabled) { cacheExpiration = 0; } try { await mFirebaseRemoteConfig.FetchAsync(cacheExpiration); Toast.MakeText(this, "Fetch Succeeded", ToastLength.Long).Show(); // Once the config is successfully fetched it must be activated before newly fetched // values are returned. mFirebaseRemoteConfig.ActivateFetched(); } catch { Toast.MakeText(this, "Fetch Failed", ToastLength.Long).Show(); } DisplayPrice(); }
private static void UpdateRemoteSettings() { SetUserProperties(); if (!IsInitialized) { return; } Task fetchTask; if (Debug.isDebugBuild) { // Default interval is 12 hours, let's make it zero for the purpose of testing fetchTask = FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero); var settings = FirebaseRemoteConfig.Settings; settings.IsDeveloperMode = true; FirebaseRemoteConfig.Settings = settings; } else { fetchTask = FirebaseRemoteConfig.FetchAsync(); } PerformRemoteSettingsFetch(fetchTask); }
private void Awake() { manager = GetComponent <UIManager>(); FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread <DependencyStatus>((task) => { DependencyStatus status = task.Result; if (status == DependencyStatus.Available) { App = FirebaseApp.DefaultInstance; Auth = FirebaseAuth.DefaultInstance; functions = FirebaseFunctions.DefaultInstance; functionReference = functions.GetHttpsCallable("RequestMessage"); manager.TurnOff(manager.AuthBlocker); manager.TurnOff(manager.AnalyticsBlocker); App.SetEditorDatabaseUrl("https://fir-n-ix.firebaseio.com/"); dbReference = FirebaseDatabase.DefaultInstance.RootReference; FirebaseMessaging.TokenReceived += OnTokenReceived; FirebaseMessaging.MessageReceived += OnMessageReceived; FirebaseMessaging.TokenRegistrationOnInitEnabled = true; defaults.Add("RemoteTest", 25); FirebaseRemoteConfig.SetDefaults(defaults); FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero).ContinueWithOnMainThread((remoteConfigTask) => { FirebaseRemoteConfig.ActivateFetched(); RemoteConfigResult = FirebaseRemoteConfig.GetValue("RemoteTest").StringValue; manager.TurnOff(manager.RemoteConfigBlocker); }); storage = FirebaseStorage.DefaultInstance; } else { Debug.Log(string.Format("Can't resolve all Firebase dependencies: {0}", status)); } }); }
private static Task FetchDataAsync() { Debug.Log("FazApp: Fetching own interstitial data..."); Task fetchTask = FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero); return(fetchTask.ContinueWith(FetchComplete)); }
private Task FetchDataAsync() { this.Log("[FIREBASE] Fetching own interstitial data...", LogLevel.FrameworkInfo); Task fetchTask = FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero); return(fetchTask.ContinueWith(FetchComplete)); }
private void fetchRemoteConfigDataAsync() { Task fetchTask = FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero); fetchTask.ContinueWith(fetchComplete); return; }
public Task FetchDataAsync() { Debug.Log("Fetching data..."); Task fetchTask = FirebaseRemoteConfig.FetchAsync( TimeSpan.Zero); return(fetchTask.ContinueWithOnMainThread(FetchComplete)); }
private static void RemoteSettingsAsyncUpdate() { if (!setupReady) { return; } // remote settings, async rsActivateFetched = false; FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero).ContinueWith(RemoteSettingsFetch); //Task fetchTask = FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero); //fetchTask.ContinueWith(RemoteSettingsFetch); Debug.Log("Remote Settings: Start async update."); }
private static async UniTask OnRemote(TimeSpan cache) { try { await FirebaseRemoteConfig.FetchAsync(cache); FirebaseRemoteConfig.ActivateFetched(); await UniTask.SwitchToMainThread(); StencilRemote.NotifyRemoteConfig(); } catch (Exception e) { Debug.LogError($"Firebase Remote Config failed. {e.InnerException?.Message}"); } }
public static IEnumerator FetchFirebaseConfigs() { Subject <bool> configSubject = new Subject <bool>(); Task configTask; try { ConfigSettings settings = default(ConfigSettings); settings.IsDeveloperMode = false; FirebaseRemoteConfig.Settings = settings; configTask = FirebaseRemoteConfig.FetchAsync(TimeSpan.FromMinutes(12.0)).ContinueWith(delegate { configSubject.OnNext(value: true); }); } catch (InitializationException ex) { Analytics.CustomEvent("FirebaseInitializationException", new Dictionary <string, object> { { "InitializationException", true } }); UnityEngine.Debug.LogWarning("ConfigLoader.FetchFirebaseConfigs " + ex.Message); yield break; } catch (Exception ex2) { Analytics.CustomEvent("FirebaseException", new Dictionary <string, object> { { "Exception", true } }); UnityEngine.Debug.LogWarning("ConfigLoader.FetchFirebaseConfigs " + ex2.Message); yield break; } yield return(configSubject.Take(1).Timeout(TimeSpan.FromSeconds(10.0)).ToYieldInstruction(throwOnError: false)); if (configTask != null && configTask.IsCompleted && FirebaseRemoteConfig.Info.LastFetchStatus == LastFetchStatus.Success) { m_configs = ParseConfigsFromFirebase(); } Fetched = true; }
/// <summary> /// Calls FetchAsync and ActivateFetched on FirebaseRemoteConfig, initializing its values and /// triggering provided callbacks once. /// </summary> /// <param name="callback">Callback to schedule after RemoteConfig is initialized.</param> /// <param name="forceRefresh">If true, force refresh of RemoteConfig params.</param> public static void RemoteConfigActivateFetched(Action callback, bool forceRefresh = false) { lock (activateFetchCallbacks) { if (activateFetched && !forceRefresh) { callback(); return; } else { activateFetchCallbacks.Add(callback); } if (!fetching) { #if UNITY_EDITOR var settings = FirebaseRemoteConfig.Settings; settings.IsDeveloperMode = true; FirebaseRemoteConfig.Settings = settings; #endif // Get the default values from the current SyncTargets. var syncObjects = Resources.FindObjectsOfTypeAll <RemoteConfigSyncBehaviour>(); var syncTargets = SyncTargetManager.FindTargets(syncObjects).GetFlattenedTargets(); var defaultValues = new Dictionary <string, object>(); foreach (var target in syncTargets.Values) { defaultValues[target.FullKeyString] = target.Value; } Initialize(status => { FirebaseRemoteConfig.SetDefaults(defaultValues); FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero).ContinueWith(task => { lock (activateFetchCallbacks) { fetching = false; activateFetched = true; var newlyActivated = FirebaseRemoteConfig.ActivateFetched(); CallActivateFetchedCallbacks(); } }); }); } } }
public void FetchRemoteConfig() { #if remote_config FirebaseRemoteConfig.FetchAsync().ContinueWith(task => { if (task.IsCanceled) { Analytics.LogError("Firebase Fetch RemoteConfig", "Fetching of RemoteConfig canceled!"); return; } if (task.IsFaulted) { Analytics.LogError("Firebase Fetch RemoteConfig", "Error: " + task.Exception.Message); return; } FlushCache(); }); #endif }
public void Init() { _firebaseRemoteConfig = FirebaseRemoteConfig.Instance; #if DEBUG var configSettings = new FirebaseRemoteConfigSettings.Builder().SetDeveloperModeEnabled(true).Build(); _firebaseRemoteConfig.SetConfigSettings(configSettings); long cacheExpiration = 0; #else var configSettings = new FirebaseRemoteConfigSettings.Builder().SetDeveloperModeEnabled(false).Build(); _firebaseRemoteConfig.SetConfigSettings(configSettings); long cacheExpiration = 3600; // 1 hour in seconds. #endif _firebaseRemoteConfig.SetDefaults(Resource.Xml.firebase_default_settings); Task.Factory.StartNew(async() => { await _firebaseRemoteConfig.FetchAsync(cacheExpiration); _firebaseRemoteConfig.ActivateFetched(); }); }
private static void FetchDataAsync() { Task task2 = FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero); task2.ContinueWith(delegate { ConfigInfo info = FirebaseRemoteConfig.Info; switch (info.LastFetchStatus) { case LastFetchStatus.Success: FirebaseRemoteConfig.ActivateFetched(); UnityEngine.Debug.Log("Fetch is completed."); break; case LastFetchStatus.Failure: switch (info.LastFetchFailureReason) { } break; } }); }
/** * Fetch discount from server. */ private async System.Threading.Tasks.Task FetchDiscount() { mPriceTextView.SetText(LOADING_PHRASE_CONFIG_KEY, null); long cacheExpiration = 3600; // 1 hour in seconds. try { await mFirebaseRemoteConfig.FetchAsync(cacheExpiration); Toast.MakeText(this, "Fetch Succeeded", ToastLength.Long).Show(); // Once the config is successfully fetched it must be activated before newly fetched // values are returned. mFirebaseRemoteConfig.Activate().Wait(); } catch { Toast.MakeText(this, "Fetch Failed", ToastLength.Long).Show(); } DisplayPrice(); }
public async Task <bool> Fetch() { await _firebaseRemote.FetchAsync(CacheTimeout); return(_firebaseRemote.ActivateFetched()); }