DittoKit

@objc
public class DittoKit : NSObject

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

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

    Declaration

    Swift

    @objc
    public var delegate: DittoKitDelegate?
  • Represents whether logging is enabled.

    Declaration

    Swift

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

    Declaration

    Swift

    @objc
    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

    @objc
    public static var emojiLogLevelHeadingsEnabled: Bool { get set }
  • Optional log delegate that can be implemented to hook into the DittoKit logging.

    Declaration

    Swift

    @objc
    public static var logDelegate: DittoLogDelegate? { get set }
  • The site ID that the instance of DittoKit is using as part of its identity.

    Declaration

    Swift

    @objc
    public let siteID: UInt32
  • Providee’s access to the SDK’s store functionality.

    Declaration

    Swift

    @objc
    public var store: DittoStore { get }
  • Keeps track of whether or not the DittoKit instance has been activated via a successful call to setAccessLicense.

    Declaration

    Swift

    @objc
    public private(set) var activated: Bool
  • The DispatchQueue that will be used to deliver delegate events. Defaults to DispatchQueue.main.

    Declaration

    Swift

    public var delegateEventQueue: DispatchQueue
  • Initializes a new DittoKit.

    Throws

    DittoKitError

    Declaration

    Swift

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

    Parameters

    identity

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

    persistenceDirectory

    The directory that will be used to persist DittoKit data.

    dbConfig

    Optional configuration to pass to the underlying storage backend.

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

    Declaration

    Swift

    @objc
    public func setAccessLicense(_ license: String)

    Parameters

    license

    The license to activate the DittoKit instance with.

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

    Declaration

    Swift

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

    Parameters

    transports

    The set of transports to be started.

  • Stop a set of transports from being used by DittoKit to connect to other devices.

    Declaration

    Swift

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

    Parameters

    transports

    The set of transports to be stopped.

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

    Throws

    DittoKitError

    Declaration

    Swift

    public func transportDiagnostics() throws -> DittoTransportDiagnostics

    Return Value

    An instance of DittoTransportDiagnostics.

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

    Throws

    DittoKitError

    Declaration

    Swift

    @objc
    public func clearSiteID() throws
  • Set a custom device code for the current device.

    When observing peers in the vicinity, each remote peer is represented by a short UTF-8 device code up to 11 bytes in length. By default this will be a truncated version of the device hostname. It does not have to be unique among peers. The device code can be overridden by calling this method prior to start().

    Declaration

    Swift

    public func setDeviceCode(code: String) throws
  • 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<RemotePeer>) -> ()) -> PeersObserver
  • Start a set of transports being used by DittoKit to connect to other devices. This will start Wi-Fi, Bluetooth LE, and Apple Wireless Direct.

    Declaration

    Swift

    @objc
    public func start()
  • Stop a set of transports from being used by DittoKit to connect to other devices. This will stop Wi-Fi, Bluetooth LE, and Apple Wireless Direct.

    Declaration

    Swift

    @objc
    public func stop()