RemoteConfig

class RemoteConfig : 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 }
  • Last fetch status. The status can be any enumerated value from FIRRemoteConfigFetchStatus.

    Declaration

    Swift

    var lastFetchStatus: RemoteConfigFetchStatus { get }
  • Config settings are custom settings.

    Declaration

    Swift

    var configSettings: RemoteConfigSettings { get set }
  • 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() -> RemoteConfig
  • Unavailable. Use +remoteConfig instead.

  • Fetches Remote Config data with a callback. Call activateFetched to make fetched data available to your app.

    Note: This method uses a Firebase Instance ID token to identify the app instance, and once it’s called, it periodically sends data to the Firebase backend. (see [FIRInstanceID getIDWithHandler:]). To stop the periodic sync, developers need to call [FIRInstanceID deleteIDWithHandler:] and avoid calling this method again.

    Declaration

    Swift

    func fetch(completionHandler: RemoteConfigFetchCompletion? = nil)

    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.

    Note: This method uses a Firebase Instance ID token to identify the app instance, and once it’s called, it periodically sends data to the Firebase backend. (see [FIRInstanceID getIDWithHandler:]). To stop the periodic sync, developers need to call [FIRInstanceID deleteIDWithHandler:] and avoid calling this method again.

    Declaration

    Swift

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

    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
  • 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) -> RemoteConfigValue { get }
  • Gets the config value of the default namespace.

    Declaration

    Swift

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

    Parameters

    key

    Config key.

  • Gets the config value of a given namespace.

    Declaration

    Swift

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

    Parameters

    key

    Config key.

    aNamespace

    Config results under a given namespace.

  • Gets the config value of a given namespace and a given source.

    Declaration

    Swift

    func configValue(forKey key: String?, namespace aNamespace: String?, source: RemoteConfigSource) -> RemoteConfigValue

    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: RemoteConfigSource, namespace aNamespace: String?) -> [String]

    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<String>

    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<String>

    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]?)

    Parameters

    defaults

    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(_ defaults: [String : NSObject]?, namespace aNamespace: String?)

    Parameters

    defaults

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

    aNamespace

    Config under a given namespace.

  • Sets default configs from plist for default namespace;

    Declaration

    Swift

    func setDefaults(fromPlist fileName: String?)

    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;

    Declaration

    Swift

    func setDefaults(fromPlist fileName: String?, namespace aNamespace: String?)

    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?) -> RemoteConfigValue?

    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.