Remote Config
Firebase Remote Config for iOS via the FirebaseIOS.remote_config autoload.
Official Firebase docs: Firebase Remote Config · Get started (iOS)
Signals
-
fetch_completed(result: Dictionary)Emitted afterfetch()orfetch_and_activate()completes. Result keys:{status: bool, error?: String}. -
activate_completed(result: Dictionary)Emitted afteractivate()orfetch_and_activate()completes. Result keys:{status: bool, error?: String}. -
config_updated(updated_keys: Array)Emitted when a real-time config update is received (requireslisten_for_updates()). The array contains the key names that changed. Values are automatically activated before the signal is emitted.
Methods
set_defaults(defaults: Dictionary)
Sets default values that are used before any fetch completes. Call this early (e.g., in _ready()).
FirebaseIOS.remote_config.set_defaults({
"welcome_message": "Hello!",
"feature_enabled": false,
"max_items": 10
})
set_minimum_fetch_interval(seconds: int)
Configures the minimum time between fetches. Default is 43200 (12 hours). Set to 0 during development.
FirebaseIOS.remote_config.set_minimum_fetch_interval(0) # Dev mode
fetch()
Fetches config values from the Firebase server. Values are not active until activate() is called.
Emits: fetch_completed.
FirebaseIOS.remote_config.fetch()
activate()
Activates the most recently fetched config values, making them available via the getters.
Emits: activate_completed.
FirebaseIOS.remote_config.activate()
fetch_and_activate()
Convenience method that fetches and immediately activates in a single call.
Emits: fetch_completed and activate_completed.
FirebaseIOS.remote_config.fetch_and_activate()
get_string(key: String) -> String
Returns the string value for the given key. Returns "" if the key doesn’t exist.
var message = FirebaseIOS.remote_config.get_string("welcome_message")
get_bool(key: String) -> bool
Returns the boolean value for the given key. Returns false if the key doesn’t exist.
var enabled = FirebaseIOS.remote_config.get_bool("feature_enabled")
get_int(key: String) -> int
Returns the integer value for the given key. Returns 0 if the key doesn’t exist.
var max_items = FirebaseIOS.remote_config.get_int("max_items")
get_float(key: String) -> float
Returns the float value for the given key. Returns 0.0 if the key doesn’t exist.
var rate = FirebaseIOS.remote_config.get_float("spawn_rate")
get_all() -> Dictionary
Returns all remote config values as a Dictionary of {key: string_value}.
var all_config = FirebaseIOS.remote_config.get_all()
for key in all_config:
print("%s = %s" % [key, all_config[key]])
listen_for_updates()
Starts a real-time listener for config changes. When values change on the server, the new values are automatically activated and config_updated is emitted with the list of changed keys.
FirebaseIOS.remote_config.listen_for_updates()
stop_listening_for_updates()
Stops the real-time config update listener.
FirebaseIOS.remote_config.stop_listening_for_updates()
get_json(key: String) -> String
Returns the JSON string value for the given key. Returns "" if not available.
var json_str = FirebaseIOS.remote_config.get_json("level_config")
var data = JSON.parse_string(json_str)
get_value_source(key: String) -> int
Returns where the value came from: 0 = static, 1 = default, 2 = remote.
var source = FirebaseIOS.remote_config.get_value_source("welcome_message")
match source:
0: print("Value is static (no value set)")
1: print("Value is from defaults")
2: print("Value is from remote")
get_last_fetch_status() -> int
Returns the last fetch status: 0 = no_fetch_yet, 1 = success, 2 = failure, 3 = throttled.
var status = FirebaseIOS.remote_config.get_last_fetch_status()
if status == 1:
print("Last fetch was successful")
get_last_fetch_time() -> String
Returns the time of the last successful fetch as an ISO 8601 string. Returns "" if no fetch has completed.
var fetch_time = FirebaseIOS.remote_config.get_last_fetch_time()
print("Last fetch: %s" % fetch_time)
set_fetch_timeout(seconds: int)
Sets the fetch timeout in seconds. If a fetch does not complete within this time, it will fail.
FirebaseIOS.remote_config.set_fetch_timeout(10)
Example Usage
func _ready() -> void:
# Set fallback defaults
FirebaseIOS.remote_config.set_defaults({
"welcome_message": "Welcome!",
"daily_reward": 100,
"maintenance_mode": false
})
# Connect signals
FirebaseIOS.remote_config.fetch_completed.connect(_on_fetch_completed)
FirebaseIOS.remote_config.config_updated.connect(_on_config_updated)
# Fetch latest values
FirebaseIOS.remote_config.fetch_and_activate()
func _on_fetch_completed(result: Dictionary) -> void:
if result.get("status"):
var message = FirebaseIOS.remote_config.get_string("welcome_message")
var reward = FirebaseIOS.remote_config.get_int("daily_reward")
print("Welcome: %s, Daily reward: %d" % [message, reward])
else:
print("Fetch failed: %s" % result.get("error", ""))
func _on_config_updated(updated_keys: Array) -> void:
print("Config updated! Changed keys: %s" % str(updated_keys))
if "maintenance_mode" in updated_keys:
var maintenance = FirebaseIOS.remote_config.get_bool("maintenance_mode")
if maintenance:
show_maintenance_screen()