FIRRemoteConfig

@interface FIRRemoteConfig : NSObject <NSFastEnumeration>

Firebase Remote Config class. The shared instance method +remoteConfig can be created and used to fetch, activate and read config results and set default config results.

  • Last successful fetch completion time.

    Declaration

    Swift

    var lastFetchTime: Date? { get }

    Objective-C

    @property (readonly, strong, nonatomic, nullable) NSDate *lastFetchTime;
  • Last fetch status. The status can be any enumerated value from FIRRemoteConfigFetchStatus.

    Declaration

    Swift

    var lastFetchStatus: FIRRemoteConfigFetchStatus { get }

    Objective-C

    @property (readonly, assign, nonatomic)
        FIRRemoteConfigFetchStatus lastFetchStatus;
  • Config settings are custom settings.

    Declaration

    Swift

    var configSettings: FIRRemoteConfigSettings { get set }

    Objective-C

    @property (readwrite, strong, nonatomic, nonnull)
        FIRRemoteConfigSettings *configSettings;
  • Returns the FIRRemoteConfig instance shared throughout your app. This singleton object contains the complete set of Remote Config parameter values available to the app, including the Active Config and Default Config. This object also caches values fetched from the Remote Config Server until they are copied to the Active Config by calling activateFetched. When you fetch values from the Remote Config Server using the default Firebase namespace service, you should use this class method to create a shared instance of the FIRRemoteConfig object to ensure that your app will function properly with the Remote Config Server and the Firebase service.

    Declaration

    Swift

    class func remoteConfig() -> FIRRemoteConfig

    Objective-C

    + (nonnull FIRRemoteConfig *)remoteConfig;
  • Unavailable. Use +remoteConfig instead.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Fetches Remote Config data with a callback. Call activateFetched to make fetched data available to your app. - parameter: completionHandler Fetch operation callback.

    Declaration

    Swift

    func fetch(completionHandler: FIRRemoteConfigFetchCompletion? = nil)

    Objective-C

    - (void)fetchWithCompletionHandler:
        (nullable FIRRemoteConfigFetchCompletion)completionHandler;

    Parameters

    completionHandler

    Fetch operation callback.

  • Fetches Remote Config data and sets a duration that specifies how long config data lasts. Call activateFetched to make fetched data available to your app. - parameter: expirationDuration Duration that defines how long fetched config data is available, in seconds. When the config data expires, a new fetch is required. - parameter: completionHandler Fetch operation callback.

    Declaration

    Swift

    func fetch(withExpirationDuration expirationDuration: TimeInterval, completionHandler: FIRRemoteConfigFetchCompletion? = nil)

    Objective-C

    - (void)fetchWithExpirationDuration:(NSTimeInterval)expirationDuration
                      completionHandler:(nullable FIRRemoteConfigFetchCompletion)
                                            completionHandler;

    Parameters

    expirationDuration

    Duration that defines how long fetched config data is available, in seconds. When the config data expires, a new fetch is required.

    completionHandler

    Fetch operation callback.

  • Applies Fetched Config data to the Active Config, causing updates to the behavior and appearance of the app to take effect (depending on how config data is used in the app). Returns true if there was a Fetched Config, and it was activated. Returns false if no Fetched Config was found, or the Fetched Config was already activated.

    Declaration

    Swift

    func activateFetched() -> Bool

    Objective-C

    - (BOOL)activateFetched;
  • Enables access to configuration values by using object subscripting syntax. This is used to get the config value of the default namespace.

    // Example:
    FIRRemoteConfig *config = [FIRRemoteConfig remoteConfig];
    FIRRemoteConfigValue *value = config[@yourKey];
    BOOL b = value.boolValue;
    NSNumber *number = config[@yourKey].numberValue;
    

    Declaration

    Swift

    subscript(key: String) -> FIRRemoteConfigValue { get }

    Objective-C

    - (nonnull FIRRemoteConfigValue *)objectForKeyedSubscript:
        (nonnull NSString *)key;
  • Gets the config value of the default namespace. - parameter: key Config key.

    Declaration

    Swift

    func configValue(forKey key: String?) -> FIRRemoteConfigValue

    Objective-C

    - (nonnull FIRRemoteConfigValue *)configValueForKey:(nullable NSString *)key;

    Parameters

    key

    Config key.

  • Gets the config value of a given namespace. - parameter: key Config key. - parameter: aNamespace Config results under a given namespace.

    Declaration

    Swift

    func configValue(forKey key: String?, namespace aNamespace: String?) -> FIRRemoteConfigValue

    Objective-C

    - (nonnull FIRRemoteConfigValue *)configValueForKey:(nullable NSString *)key
                                              namespace:
                                                  (nullable NSString *)aNamespace;

    Parameters

    key

    Config key.

    aNamespace

    Config results under a given namespace.

  • Gets the config value of a given namespace and a given source. - parameter: key Config key. - parameter: aNamespace Config results under a given namespace. - parameter: source Config value source.

    Declaration

    Swift

    func configValue(forKey key: String?, namespace aNamespace: String?, source: FIRRemoteConfigSource) -> FIRRemoteConfigValue

    Objective-C

    - (nonnull FIRRemoteConfigValue *)
    configValueForKey:(nullable NSString *)key
            namespace:(nullable NSString *)aNamespace
               source:(FIRRemoteConfigSource)source;

    Parameters

    key

    Config key.

    aNamespace

    Config results under a given namespace.

    source

    Config value source.

  • Gets all the parameter keys from a given source and a given namespace.

    Declaration

    Swift

    func allKeys(from source: FIRRemoteConfigSource, namespace aNamespace: String?) -> [String]

    Objective-C

    - (nonnull NSArray<NSString *> *)allKeysFromSource:(FIRRemoteConfigSource)source
                                             namespace:
                                                 (nullable NSString *)aNamespace;

    Parameters

    source

    The config data source.

    aNamespace

    The config data namespace.

    Return Value

    An array of keys under the given source and namespace.

  • Returns the set of parameter keys that start with the given prefix, from the default namespace in the active config.

    Declaration

    Swift

    func keys(withPrefix prefix: String?) -> Set

    Objective-C

    - (nonnull NSSet<NSString *> *)keysWithPrefix:(nullable NSString *)prefix;

    Parameters

    prefix

    The key prefix to look for. If prefix is nil or empty, returns all the keys.

    Return Value

    The set of parameter keys that start with the specified prefix.

  • Returns the set of parameter keys that start with the given prefix, from the given namespace in the active config.

    Declaration

    Swift

    func keys(withPrefix prefix: String?, namespace aNamespace: String?) -> Set

    Objective-C

    - (nonnull NSSet<NSString *> *)keysWithPrefix:(nullable NSString *)prefix
                                        namespace:(nullable NSString *)aNamespace;

    Parameters

    prefix

    The key prefix to look for. If prefix is nil or empty, returns all the keys in the given namespace.

    aNamespace

    The namespace in which to look up the keys. If the namespace is invalid, returns an empty set.

    Return Value

    The set of parameter keys that start with the specified prefix.

  • Sets config defaults for parameter keys and values in the default namespace config.

    Declaration

    Swift

    func setDefaults(_ defaults: [String : NSObject]?)

    Objective-C

    - (void)setDefaults:(nullable NSDictionary<NSString *, NSObject *> *)defaults;

    Parameters

    defaultConfig

    A dictionary mapping a NSString * key to a NSObject * value.

  • Sets config defaults for parameter keys and values in the default namespace config.

    Declaration

    Swift

    func setDefaults(_ defaultConfig: [String : NSObject]?, namespace aNamespace: String?)

    Objective-C

    - (void)setDefaults:
                (nullable NSDictionary<NSString *, NSObject *> *)defaultConfig
              namespace:(nullable NSString *)aNamespace;

    Parameters

    defaultConfig

    A dictionary mapping a NSString * key to a NSObject * value.

    aNamespace

    Config under a given namespace.

  • Sets default configs from plist for default namespace; - parameter: fileName The plist file name, with no file name extension. For example, if the plist file is defaultSamples.plist, call: [[FIRRemoteConfig remoteConfig] setDefaultsFromPlistFileName:@defaultSamples];

    Declaration

    Swift

    func setDefaultsFromPlistFileName(_ fileName: String?)

    Objective-C

    - (void)setDefaultsFromPlistFileName:(nullable NSString *)fileName;

    Parameters

    fileName

    The plist file name, with no file name extension. For example, if the plist file is defaultSamples.plist, call: [[FIRRemoteConfig remoteConfig] setDefaultsFromPlistFileName: defaultSamples];

  • Sets default configs from plist for a given namespace; - parameter: fileName The plist file name, with no file name extension. For example, if the plist file is defaultSamples.plist, call: [[FIRRemoteConfig remoteConfig] setDefaultsFromPlistFileName:@defaultSamples]; - parameter: aNamespace The namespace where the default config is set.

    Declaration

    Swift

    func setDefaultsFromPlistFileName(_ fileName: String?, namespace aNamespace: String?)

    Objective-C

    - (void)setDefaultsFromPlistFileName:(nullable NSString *)fileName
                               namespace:(nullable NSString *)aNamespace;

    Parameters

    fileName

    The plist file name, with no file name extension. For example, if the plist file is defaultSamples.plist, call: [[FIRRemoteConfig remoteConfig] setDefaultsFromPlistFileName: defaultSamples];

    aNamespace

    The namespace where the default config is set.

  • Returns the default value of a given key and a given namespace from the default config.

    Declaration

    Swift

    func defaultValue(forKey key: String?, namespace aNamespace: String?) -> FIRRemoteConfigValue?

    Objective-C

    - (nullable FIRRemoteConfigValue *)defaultValueForKey:(nullable NSString *)key
                                                namespace:
                                                    (nullable NSString *)aNamespace;

    Parameters

    key

    The parameter key of default config.

    aNamespace

    The namespace of default config.

    Return Value

    Returns the default value of the specified key and namespace. Returns nil if the key or namespace doesn’t exist in the default config.