You can useFirebase Remote Configto define parameters in your app and
update their values in the cloud, allowing you to modify the appearance and
behavior of your app without distributing an app update. This guide walks you
through the steps to get started and provides some sample code, all of which is
available to clone or download from thefirebase/quickstart-iosGitHub repository.
This object is used to store in-app default parameter values, fetch updated
parameter values from theRemote Configbackend, and control when fetched
values are made available to your app.
During development, it's recommended to set a relatively low minimum fetch
interval. SeeThrottlingfor more
information.
Step 2: Set in-app default parameter values
You can set in-app default parameter values in theRemote Configobject, so that your app behaves as intended before it connects to theRemote Configbackend, and so that default values are available if none are
set in the backend.
Define a set of parameter names, and default parameter values using anNSDictionaryobject or aplist
file.
If you have already configuredRemote Configbackend parameter values,
you can download a generatedplistfile that includes all default values
and save it to your Xcode project.
Now you can get parameter values from theRemote Configobject. If you later
set values in theRemote Configbackend, fetch them, and then activate them,
those values are available to your app. Otherwise, you get the in-app parameter
values configured usingsetDefaults:.
To get these values, call theconfigValueForKey:method, providing the parameter key as an argument.
letremoteConfig=RemoteConfig.remoteConfig()// Retrieve a parameter value using configValueForKeyletwelcomeMessageValue=remoteConfig.configValue(forKey:"welcome_message")letwelcomeMessage=welcomeMessageValue.stringValueletfeatureFlagValue=remoteConfig.configValue(forKey:"new_feature_flag")letisFeatureEnabled=featureFlagValue.boolValue
A more readable and convenient way to access these values in Swift is through
Swift's subscript notation:
letremoteConfig=RemoteConfig.remoteConfig()// Retrieve a string parameter valueletwelcomeMessage=remoteConfig["welcome_message"].stringValue// Retrieve a boolean parameter valueletisFeatureEnabled=remoteConfig["new_feature_flag"].boolValue// Retrieve a number parameter valueletmaxItemCount=remoteConfig["max_items"].numberValue.intValue
Use Codable for type-safe configuration
For more complex configurations, you can use Swift'sCodableprotocol to
decode structured data fromRemote Config. This provides type-safe
configuration management and simplifies working with complex objects.
// Define a Codable struct for your configurationstructAppFeatureConfig:Codable{letisNewFeatureEnabled:BoolletmaxUploadSize:IntletthemeColors:[String:String]}// Fetch and decode the configurationfuncconfigureAppFeatures(){letremoteConfig=RemoteConfig.remoteConfig()remoteConfig.fetchAndActivate{status,erroringuarderror==nilelse{return}do{letfeatureConfig=tryremoteConfig["app_feature_config"].decoded(asType:AppFeatureConfig.self)configureApp(with:featureConfig)}catch{// Handle decoding errorsprint("Failed to decode configuration:\(error)")}}}
This method lets you:
Define complex configuration structures.
Automatically parse JSON configurations.
Ensure type safety when accessingRemote Configvalues.
Provide clean, readable code for handling structuredRemote Configtemplates.
Use Property Wrappers for declarative configuration in SwiftUI
Property wrappers are a powerful Swift feature that lets you add custom behavior
to property declarations. In SwiftUI, property wrappers are used to manage
state, bindings, and other property behaviors. For more information, see theSwift Language
Guide.
Use the@RemoteConfigPropertyproperty wrapper when you want a declarative way
to accessRemote Configvalues in SwiftUI, with built-in support for default
values and simplified configuration management.
Step 4: Set parameter values
Using theFirebaseconsole or theRemote Configbackend
APIs, you can create new backend default
values that override the in-app values according to your desired conditional
logic or user targeting. This section walks you through theFirebaseconsole
steps to create these values.
SelectRemote Configfrom the menu to view theRemote Configdashboard.
Define parameters with the same names as the parameters that you defined in
your app. For each parameter, you can set a default value (which will
eventually override the in-app default value) and you can also set
conditional values. To learn more, seeRemote ConfigParameters and
Conditions.
If usingcustom signal
conditions,
define the attributes and their values. The following examples show how to
define a custom signal condition.
Swift
Task{letcustomSignals:[String:CustomSignalValue?]=["city":.string("Tokyo"),"preferred_event_category":.string("sports")]do{tryawaitremoteConfig.setCustomSignals(customSignals)print("Custom signals set successfully!")}catch{print("Error setting custom signals:\(error)")}}
Objective-C
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^{NSDictionary*customSignals=@{@"city":@"Tokyo",@"preferred_event_category":@"sports"};[self.remoteConfigsetCustomSignals:customSignalswithCompletion:^(NSError*_Nullableerror){if(error){NSLog(@"Error setting custom signals: %@",error);}else{NSLog(@"Custom signals set successfully!");}}];});
Because these updated parameter values affect the behavior and appearance of
your app, you should activate the fetched values at a time that ensures a smooth
experience for your user, such as the next time that the user opens your app.
SeeRemote Config loading strategiesfor more
information and examples.
Step 6: Listen for updates in real time
After you fetch parameter values, you can use real-timeRemote Configto
listen for updates from theRemote Configbackend. Real-timeRemote Configsignals to connected devices when updates are available and
automatically fetches the changes after you publish a newRemote Configversion.
Real-time updates are supported by theFirebaseSDK forAppleplatforms v10.7.0+ and higher.
In your app, calladdOnConfigUpdateListenerto start listening for updates
and automatically fetch any new or updated parameter values. The following
example listens for updates and whenactivateWithCompletionHandleris
called, uses the newly fetched values to display an updated welcome message.
Swift
remoteConfig.addOnConfigUpdateListener{configUpdate,erroringuardletconfigUpdate,error==nilelse{print("Error listening for config updates:\(error)")}print("Updated keys:\(configUpdate.updatedKeys)")self.remoteConfig.activate{changed,erroringuarderror==nilelse{returnself.displayError(error)}DispatchQueue.main.async{self.displayWelcome()}}}
Objective-C
__weak__typeof__(self)weakSelf=self;[self.remoteConfigaddOnConfigUpdateListener:^(FIRRemoteConfigUpdate*_NonnullconfigUpdate,NSError*_Nullableerror){if(error!=nil){NSLog(@"Error listening for config updates %@",error.localizedDescription);}else{NSLog(@"Updated keys: %@",configUpdate.updatedKeys);__typeof__(self)strongSelf=weakSelf;[strongSelf.remoteConfigactivateWithCompletion:^(BOOLchanged,NSError*_Nullableerror){if(error!=nil){NSLog(@"Activate error %@",error.localizedDescription);}dispatch_async(dispatch_get_main_queue(),^{[strongSelfdisplayWelcome];});}];}}];
The next time you publish a new version of yourRemote Config, devices
that are running your app and listening for changes will call the completion
handler.
Throttling
If an app fetches too many times in a short time period, fetch calls are
throttled and the SDK returnsFIRRemoteConfigFetchStatusThrottled.
Before SDK version 6.3.0, the limit was 5 fetch requests in a 60 minute window
(newer versions have more permissive limits).
During app development,you might want to fetch more often to refresh the cache
very frequently (many times per hour) to let you rapidly iterate as you develop
and test your app. Real-time Remote Config updates automatically bypass the
cache when the config is updated on the server. To accommodate rapid iteration
on a project with numerous developers, you can temporarily add aFIRRemoteConfigSettingsproperty with a low minimum fetch interval
(MinimumFetchInterval) in your app.
The default and recommended production fetch interval forRemote Configis 12 hours, which means that configs won't be fetched from the backend more
than once in a 12 hour window, regardless of how many fetch calls are actually
made. Specifically, the minimum fetch interval is determined in this following
order:
The parameter infetch(long)
The parameter inFIRRemoteConfigSettings.MinimumFetchInterval
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-12-17 UTC."],[],[]]