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)); } }); }
public static void Initialize() { #if remote_config ProjectManager config = ProjectManager.staticRef; Dictionary <string, object> defaultConfig = new Dictionary <string, object>(); defaultConfig.Add("useAdMob", config.useAdMob); defaultConfig.Add("useIAS", config.useIAS); defaultConfig.Add("useFirebaseAnalytics", config.useFirebaseAnalytics); //defaultConfig.Add ("useFirebaseRemoteConfig", config.useFirebaseRemoteConfig); defaultConfig.Add("useFirebaseAuth", config.useFirebaseAuth); defaultConfig.Add("useFirebaseDatabase", config.useFirebaseDatabase); defaultConfig.Add("useFirebaseInvites", config.useFirebaseInvites); defaultConfig.Add("useFirebaseMessaging", config.useFirebaseMessaging); defaultConfig.Add("useFirebaseStorage", config.useFirebaseStorage); defaultConfig.Add("isDebugModeActive", config.isDebugModeActive); // Add custom developer defined values from the inspector into the defaultConfig dictionary foreach (CustomRemoteConfig newDefaultConfig in staticRef.customDefaultConfig) { defaultConfig.Add(newDefaultConfig.name, newDefaultConfig.defaultValue); } // Assign all the default values from above FirebaseRemoteConfig.SetDefaults(defaultConfig); staticRef.FetchRemoteConfig(); #endif }
private void InitRemoteConfig() { firebaseRemoteConfig = FirebaseRemoteConfig.Instance; FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder() .SetDeveloperModeEnabled(true) .Build(); firebaseRemoteConfig.SetConfigSettings(configSettings); firebaseRemoteConfig.SetDefaults(Resource.Xml.remote_config_defaults); }
private static void InitializeRemoteConfig() { var defaults = new Dictionary <string, object> { { FrameworkValues.FIREBASE_REMOTE_CONFIG_SHOW_OWN_INTERSTITIAL_KEY_B, false }, { FrameworkValues.FIREBASE_REMOTE_CONFIG_OWN_INTERSTITIAL_IMAGE_URL_KEY_S, "DEFAULT" }, { FrameworkValues.FIREBASE_REMOTE_CONFIG_OWN_INTERSTITIAL_STORE_URL_KEY_S, "DEFAULT" }, { FrameworkValues.FIREBASE_REMOTE_CONFIG_OWN_INTERSTITIAL_TITLE_KEY_S, "DEFAULT" }, { FrameworkValues.FIREBASE_REMOTE_CONFIG_OWN_INTERSTITIAL_DESCRIPTION_KEY_S, "DEFAULT" } }; FirebaseRemoteConfig.SetDefaults(defaults); }
private static void SetDefaults() { Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("menu_background", "1"); dictionary.Add("daily_double", "1"); dictionary.Add("redeem_status", "0"); dictionary.Add("interstitial_firstlevel", "10"); dictionary.Add("rewarded_status", "1"); dictionary.Add("interstitial_interval", "120"); dictionary.Add("level_test", "2"); dictionary.Add("play_text_color", "2"); dictionary.Add("menu_theme", "0"); Dictionary <string, object> defaults = dictionary; FirebaseRemoteConfig.SetDefaults(defaults); }
public void Initialize(Action onSuccess = null, Action <IResultBase> onFault = null) { #if NRED_FIREBASE_REMOTECFG_UTIL if (isLoaded) { onFault.SafeCall(new Result { ok = false, errorCode = FirebaseUtil.ErrorCode.ALREADY_LOADED }); return; } try { ConfigSettings c = FirebaseRemoteConfig.Settings; #if DEBUG c.IsDeveloperMode = isDeveloperMode; #else c.IsDeveloperMode = false; #endif if (defaults.IsAvailable()) { Dictionary <string, object> registDic = new Dictionary <string, object>(defaults.Count); var enm = defaults.GetEnumerator(); while (enm.MoveNext()) { if (enm.Current.key != null) { registDic[enm.Current.key] = (object)enm.Current.value; } } FirebaseRemoteConfig.SetDefaults(registDic); } isLoaded = true; onSuccess.SafeCall(); } catch (System.Exception e) { onFault.SafeCall(new Result { ok = false, errorCode = FirebaseUtil.ErrorCode.INIT_EXCEPTION }); } #endif }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); mPriceTextView = (TextView)FindViewById(Resource.Id.priceView); Button fetchButton = (Button)FindViewById(Resource.Id.fetchButton); fetchButton.Click += async delegate { await FetchDiscount(); }; // Get Remote Config instance. // [START get_remote_config_instance] mFirebaseRemoteConfig = FirebaseRemoteConfig.Instance; // [END get_remote_config_instance] // Create Remote Config Setting to enable developer mode. // Fetching configs from the server is normally limited to 5 requests per hour. // Enabling developer mode allows many more requests to be made per hour, so developers // can test different config values during development. // [START enable_dev_mode] FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder().SetDeveloperModeEnabled(BuildConfig.DEBUG).Build(); mFirebaseRemoteConfig.SetConfigSettings(configSettings); // [END enable_dev_mode] // Set default Remote Config values. In general you should have in app defaults for all // values that you may configure using Remote Config later on. The idea is that you // use the in app defaults and when you need to adjust those defaults, you set an updated // value in the App Manager console. Then the next time you application fetches from the // server, the updated value will be used. You can set defaults via an xml file like done // here or you can set defaults inline by using one of the other setDefaults methods.S // [START set_default_values] mFirebaseRemoteConfig.SetDefaults(Resource.Xml.remote_config_defaults); // [END set_default_values] // Fetch discount config. await FetchDiscount(); }
/// <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 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 void InitializeRemoteConfig() { FirebaseRemoteConfig.SetDefaults(ownInterstitial.GetInterstitialDefaultKeys()); }