DITDittoSyncKit
@interface DITDittoSyncKit : NSObject
The entrypoint to the DittoSyncKit SDK.
For a DITDittoSyncKit
instance to continue to connect to other devices it must be kept in scope.
-
Represents whether logging is enabled.
Declaration
Objective-C
@property (class, nonatomic) BOOL loggingEnabled;
-
The minimum log level at which logs will be logged, provided
loggingEnabled
istrue
.Declaration
Objective-C
@property (class, nonatomic) enum DITLogLevel minimumLogLevel;
-
Represents whether or not emojis should be used as the log level indicator in the logs.
Declaration
Objective-C
@property (class, nonatomic) BOOL emojiLogLevelHeadingsEnabled;
-
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
Objective-C
@property (class, nonatomic) NSString *_Nonnull deviceName;
-
Provides access to the SDK’s store functionality.
Declaration
Objective-C
@property (readonly) DITStore *_Nonnull store;
-
The site ID that the instance of
DITDittoSyncKit
is using as part of its identity.Declaration
Objective-C
@property (nonatomic, readonly) uint32_t siteID;
-
An optional delegate that will be called with SDK lifecycle information if defined.
Declaration
Objective-C
@property (nonatomic, weak) id<DITDittoSyncKitDelegate> _Nullable delegate;
-
The dispatch queue that will be used to deliver delegate events. Defaults to the main queue.
Declaration
Objective-C
@property (nonatomic) dispatch_queue_t _Nonnull delegateEventQueue;
-
Initializes a new
DITDittoSyncKit
.This will initialize an instance of
DITDittoSyncKit
with the default configuration.Declaration
Objective-C
- (nonnull instancetype)init;
-
Initializes a new
DITDittoSyncKit
.Declaration
Objective-C
- (nonnull instancetype)initWithIdentity:(nonnull DITIdentity *)identity;
Parameters
identity
Provide the identity of the entity that is interacting with DittoSyncKit.
-
Initializes a new
DITDittoSyncKit
.Declaration
Objective-C
- (nonnull instancetype)initWithIdentity:(nonnull DITIdentity *)identity persistenceDirectory:(nullable NSURL *)directory;
Parameters
identity
Provide the identity of the entity that is interacting with DittoSyncKit.
directory
The directory that will be used to persist DittoSyncKit data.
-
Starts all of the transports used by DittoSyncKit to connect to other devices.
This has no effect for any transports that have already been started.
Declaration
Objective-C
- (void)start;
-
Start a set of transports used by DittoSyncKit to connect to other devices.
This has no effect if a provided transport is already started.
Declaration
Objective-C
- (void)start:(nonnull NSArray<DITTransport *> *)transports;
Parameters
transports
The set of transports to be started.
-
Stops all of the transports used by DittoSyncKit to connect to other devices.
This has no effect for any transports that have already been stopped.
Declaration
Objective-C
- (void)stop;
-
Stop a set of transports being used by DittoSyncKit to connect to other devices.
This has no effect for any transports that have already been started.
Declaration
Objective-C
- (void)stop:(nonnull NSArray<DITTransport *> *)transports;
Parameters
transports
The set of transports to be stopped.
-
Starts an HTTP server that other devices will be able to connect to.
Declaration
Objective-C
- (void)startHTTPServer:(nonnull NSString *)address enableWebsocket:(BOOL)enableWebsocket staticPath:(nullable NSString *)staticPath tlsCertPath:(nullable NSString *)certPath tlsKeyPath:(nullable NSString *)keyPath;
Parameters
address
The address that the WebSocket 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. May be NULL.
certPath
If using TLS, an absolute path to a file containing this server’s certificate. Otherwise NULL.
keyPath
If using TLS, an absolute path to a file containing this server’s private key. Otherwise NULL.
-
Activate a
DITDittoSyncKit
instance by setting an access license. You cannot meaningfully interact with aDITDittoSyncKit
instance before you have activated it.Declaration
Objective-C
- (void)setAccessLicense:(nonnull NSString *)license;
Parameters
license
The license to activate the
DITDittoSyncKit
instance with. -
Clears the cached site ID, if one had been cached.
Declaration
Objective-C
- (void)clearSiteID;
-
Request bulk status information about the transports.
This is mostly intended for statistical or debugging purposes.
Declaration
Objective-C
- (nullable DITTransportDiagnostics *)transportDiagnostics: (NSError *_Nullable *_Nullable)error;
Parameters
error
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.
Return Value
An instance of
DITTransportDiagnostics
ornil
if there was an error. -
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. From then on it will be invoked repeatedly when Ditto devices come and go, or the active connections to them change.
Declaration
Objective-C
- (nonnull DITPeersObserver *)observePeers: (nonnull void (^)(NSArray<DITRemotePeer *> *_Nonnull))callback;
-
Returns a string identifying the version of the DittoSyncKit SDK.
Declaration
Objective-C
- (nonnull NSString *)sdkVersion;