DittoSyncKit

public class DittoSyncKit

DittoSyncKit is the entry point for accessing Ditto-related functionality.

  • An optional delegate that will be called with SDK lifecycle information if defined.

    Declaration

    Swift

    public var delegate: DittoSyncKitDelegate? { get set }
  • Represents whether logging is enabled.

    Declaration

    Swift

    public static var loggingEnabled: Bool { get set }
  • The minimum log level at which logs will be logged, provided loggingEnabled is true.

    Declaration

    Swift

    public static var minimumLogLevel: DittoLogLevel { get set }
  • Represents whether or not emojis should be used as the log level indicator in the logs.

    Declaration

    Swift

    public static var emojiLogLevelHeadingsEnabled: Bool { get set }
  • Configure a custom identifier for the current device.

    When using observePeers(), each remote peer is represented by a short UTF-8 “device name”. By default this will be a truncated version of the device’s hostname. It does not need to be unique among peers. Configure the device name before calling start(). If it is too long it will be truncated.

    Declaration

    Swift

    public static var deviceName: String { get set }
  • The site ID that the instance of DittoSyncKit is using as part of its identity.

    Declaration

    Swift

    public var siteID: UInt32 { get }
  • Provides access to the SDK’s store functionality.

    Declaration

    Swift

    public var store: DittoStore { get }
  • The DispatchQueue that will be used to deliver delegate events. Defaults to DispatchQueue.main.

    Declaration

    Swift

    public var delegateEventQueue: DispatchQueue { get set }
  • Initializes a new DittoSyncKit.

    Declaration

    Swift

    public init(
        identity: DittoIdentity = .development(),
        persistenceDirectory directory: URL? = nil
    )

    Parameters

    identity

    Provide the identity of the entity that is interacting with DittoSyncKit.

    persistenceDirectory

    The directory that will be used to persist DittoSyncKit data.

  • Activate a DittoSyncKit instance by setting an access license. You cannot interact with DittoSyncKit before you have activated it.

    Declaration

    Swift

    public func setAccessLicense(_ license: String)

    Parameters

    license

    The license to activate the DittoSyncKit instance with.

  • Start a set of transports being used by DittoSyncKit to connect to other devices. This has no effect if a provided transport is already started.

    By default the WiFi, Bluetooth, and AWDL transports will be started.

    Declaration

    Swift

    public func start(transports: Set<DittoTransport> = [.wifi, .bluetooth, .awdl])

    Parameters

    transports

    The set of transports to be started.

  • Stop all DittoSyncKit transports.

    Declaration

    Swift

    public func stop()
  • Stop a set of transports from being used by DittoSyncKit to connect to other devices.

    Declaration

    Swift

    public func stop(transports: Set<DittoTransport>)

    Parameters

    transports

    The set of transports to be stopped.

  • Starts an HTTP server that other devices will be able to connect to.

    Declaration

    Swift

    public func startHttpServer(address: String, enableWebsocket: Bool, staticPath: String? = nil, tlsCertPath: String? = nil, tlsKeyPath: String? = nil)

    Parameters

    address

    The address that the server should run at. e.g. “0.0.0.0:4040”

    enableWebsocket

    Whether to accept Ditto sync connections on this port.

    staticPath

    An absolute path to a directory of static files that should be served.

    tlsCertPath

    If using TLS, an absolute path to a file containing this server’s certificate. Otherwise nil.

    tlsKeyPath

    If using TLS, an absolute path to a file containing this server’s private key. Otherwise nil.

  • Request bulk status information about the transports. This is mostly intended for statistical or debugging purposes.

    Declaration

    Swift

    public func transportDiagnostics() throws -> DittoTransportDiagnostics

    Return Value

    An instance of DittoTransportDiagnostics.

  • Clears the cached site ID, if one had been cached.

    Declaration

    Swift

    public func clearSiteID()
  • Request information about Ditto peers in range of this device.

    This method returns an observer which should be held as long as updates are required. A newly registered observer will have a peers update delivered to it immediately. Then it will be invoked repeatedly when Ditto devices come and go, or the active connections to them change.

    Declaration

    Swift

    public func observePeers(callback: @escaping (Array<DittoRemotePeer>) -> ()) -> DittoPeersObserver
  • A string identifying the version of the DittoSyncKit SDK.

    Declaration

    Swift

    public var sdkVersion: String { get }