ServerManager

@objc
public final class ServerManager : NSObject

ServerManager is the class to be used for configuring the SDK to use a particular server. It does all the heavy lifting related to server configuration.

  • Returns the server that is set to be the current server. This is the server that will be used by default for API requests. Returns nil if no server present.

    Declaration

    Swift

    @objc
    public static func defaultServer() -> Server?
  • Reload the information of all the configured servers.

    Declaration

    Swift

    public static func reloadServer()
  • Returns the list of all servers configured in the SDK.

    Declaration

    Swift

    public static func servers() -> Results<Server>?
  • Returns an existing server if it exists, otherwise returns nil.

    Declaration

    Swift

    public static func server(forHost host: String, port: String) -> Server?
  • Returns a list of server generated using

    • History of previously configured servers on this device.
    • User’s iCloud account.
    Declaration

    Swift

    public static func serverHistory() -> [Server]
  • Add a server to SDK if not already present. The server is only added. The SDK will not switch to this server automatically. Call switchToServer(_, completion) for switching. Server is considered valid only if serverName and serverURL are not nil.

    Declaration

    Swift

    public static func addServer(_ server: Server?)
  • Remove a configured server and delete all data for that server. If removed server is the current one then the first server from the list of remaining servers is the new current. Default is nil if no servers are available.

    Declaration

    Swift

    public static func removeServer(_ server: Server?)
  • Remove all the servers and data from SDK

    Declaration

    Swift

    public static func reset()
  • Switch the SDK to use a server as the current server. Server will be added to SDK if not already present. Added server will go through setup workflow if not already done.

    Server Setup Workflow is the following:

    • Call Server Version API (meta/version) to get server information.
    • Submit Certificate Signing Request (/signcsr) to server for the current device.

    If both requests succeed, then server setup if considered successful.

    Declaration

    Swift

    public static func switchToServer(_ server: Server?,
                                      promptForConfirmation prompt: Bool = false,
                                      completion: @escaping (ServerSwitchResult) -> Void)
    Parameters
    server

    The server to switch to.

    completion

    The block to be called on server switch completion.