Zur Konsole

Firebase Remote Config iOS Sample App Walkthrough

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.

Requirements

Set up your project using the instructions provided in Add Firebase to your iOS Project.

Install the client library

  1. Add the following dependency to your Podfile:

    pod 'Firebase/RemoteConfig'
    

  2. Save the file and run the following:

    pod install
    

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.

In the Firebase console, click Create New Project, and then follow the instructions to Set up a Firebase Remote Config Project with the following parameters:

Parameter key Default value Notes:
welcome_message Welcome to this sample app Change to use a different welcome message.
welcome_message_caps false 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

  1. Download the quickstart sample code and unzip it.

  2. Open a terminal window and navigate to the location of the sample project. Run pod install, then open the .xcworkspace file.

  3. Build and run the sample.

How it works

First, the sample gets a Remote Config object instance and sets the minimum fetch interval to allow for more frequent refreshes:

Swift

Objective-C

Then, the sample sets in-app default values from a plist file:

Swift

Objective-C

Now, the sample fetches values from the Remote Config service (not cached values) and callsactivateWithCompletionHandler: to make them available to the app:

Swift

Objective-C

Now that the welcome message has been updated, you can display the updated welcome message in the app.

Swift

Objective-C

You can access your Remote Config parameters using one of the stringValue, numberValue, dataValue, or boolValue properties, or using the configValueForKey: methods.

Throttling

If an app fetches too many times in a short time period, fetch calls may be throttled. In such cases, the backend returns FIRRemoteConfigFetchStatusThrottled. You are recommended to catch this error and retry in exponential backoff mode, waiting longer intervals between subsequent fetch requests.

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 a low minimum fetch interval (MinimumFetchInterval) in your app.

The default minimum fetch interval for Remote Config is 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:

  1. The parameter in fetch(long)
  2. The parameter in FIRRemoteConfigSettings.MinimumFetchInterval
  3. The default value of 12 hours