Sync

public class Sync

ObjectBox Sync makes data available on other devices (check the link for details). This class is the point of entry for Sync, e.g. create a sync client using Sync.makeClient(store, urlString).

  • Checks if this library comes with a sync client. If you do not have a sync enabled version yet, please visit https://objectbox.io/sync for more details.

    Declaration

    Swift

    public static func isAvailable() -> Bool

    Return Value

    true if calling makeClient() is possible (without throwing)

  • Creates a sync client associated with the given store and sync server with the given URL. This does not initiate any connection attempts yet: call start() to do so. Before start(), you can still configure some aspects of the sync client, e.g. its “request update” mode.

    Note: while you may not interact with SyncClient directly after start(), you need to hold on to the object: by keeping a reference you ensure the SyncClient is not destroyed and thus synchronization can keep running in the background. If you must, you can use Swift’s withExtendedLifetime() for that.

    Pass either a url or a urlString (auto-converted to URL).

    Throws

    ObjectBoxError.sync if sync is unavailable in this version of the library or no valid URL was provided.

    Declaration

    Swift

    public static func makeClient(
            store: Store,
            url: URL? = nil,
            urlString: String? = nil,
            credentials: SyncCredentials? = nil
    ) throws -> SyncClient