This guide walks you through the steps involved in integrating Remote Config into your iOS app. To learn more about the Remote Config API for iOS, see FIRRemoteConfig.
Set up your project using the instructions provided in Add Firebase to your iOS Project.
Install the client library
Add the following dependency to your
Save the file and run the following:
This creates an
.xcworkspace file for your application. Use this file for all
future development on your application.
Create a Remote Config project for the quickstart sample
The quickstart sample provides an example of using Remote Config to define the welcome message of the sample app. Before running the quickstart sample, you should set up a Remote Config project.
|Parameter key||Default value||Notes:|
||Change to use a different welcome message.|
||Set to true to have the welcome message display in all caps.|
After configuring your project, run the quickstart sample to see the welcome message you defined in the Firebase console. You can change the values of these parameters in the project and then tap Fetch Remote Config in the quickstart sample to see how Remote Config lets you update an app.
Build and run the quickstart sample
Download the quickstart sample code and unzip it.
Open a terminal window and navigate to the location of the sample project. Run
pod install, then open the
Build and run the sample.
How it works
First, the sample gets a Remote Config object instance and enables developer mode to allow for frequent refreshes of the cache:
Then, the sample sets in-app default values from a
Now, the sample creates a
request to fetch values from the Remote Config service and calls
activateFetched to make those values available to the app:
Now that the welcome message has been updated, you can display the updated welcome message in the app:
You can access your Remote Config parameters using one of the
boolValue properties, or using
Caching and throttling
Remote Config caches values locally after the first successful request.
By default the cache expires after 12 hours, but you can change the cache
expiration for a specific request by passing the desired cache expiration, in
fetchWithExpirationDuration:completionHandler:. If the values in
the cache are older than the desired cache expiration, Remote Config will
request fresh config values from the service. If your app requests fresh values
fetchWithExpirationDuration:completionHandler: several times, requests
are throttled and your app is provided with a cached value.
During app development, you might want to refresh the cache very frequently
(many times per hour) to let you rapidly iterate as you develop and test your
app. To accommodate rapid iteration on a project with up to 10 developers, you
can temporarily add a
FIRRemoteConfigSettings property with
isDeveloperModeEnabled set to
true to your app, changing the caching
settings of the