RemoteSettingsClient

open class RemoteSettingsClient:
    RemoteSettingsClientProtocol

Client for a single Remote Settings collection

Use [RemoteSettingsService::make_client] to create these.

  • Declaration

    Swift

    required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer)
  • Collection this client is for

    Declaration

    Swift

    open func collectionName() -> String
  • Get attachment data for a remote settings record

    Attachments are large binary blobs used for data that doesn’t fit in a normal record. They are handled differently than other record data:

    • Attachments are not downloaded in [RemoteSettingsService::sync]
    • This method will make network requests if the attachment is not cached
    • This method will throw if there is a network or other error when fetching the attachment data.

    Declaration

    Swift

    open func getAttachment(attachmentId: String) throws -> Data
  • Get the current set of records.

    This method normally fetches records from the last sync. This means that it returns fast and does not make any network requests.

    If records have not yet been synced it will return None. Use sync_if_empty = true to change this behavior and perform a network request in this case. That this is probably a bad idea if you want to fetch the setting in application startup or when building the UI.

    None will also be returned on disk IO errors or other unexpected errors. The reason for this is that there is not much an application can do in this situation other than fall back to the same default handling as if records have not been synced.

    TODO(Bug 1919141):

    Application-services schedules regular dumps of the server data for specific collections. For these collections, get_records will never return None. If you would like to add your collection to this list, please reach out to the DISCO team.

    Declaration

    Swift

    open func getRecords(syncIfEmpty: Bool = false) -> [RemoteSettingsRecord]?
  • Get the current set of records as a map of record_id -> record.

    See [Self::get_records] for an explanation of when this makes network requests, error handling, and how the sync_if_empty param works.

    Declaration

    Swift

    open func getRecordsMap(syncIfEmpty: Bool = false) -> [String : RemoteSettingsRecord]?