ClientRegistrationProvider

public protocol ClientRegistrationProvider : AnyObject

Interface for providers that support client registration.

  • Checks locally whether a previous registerClient call successfuly created a client registration for the remote OData service.

    Declaration

    Swift

    func isClientRegistered() throws -> Bool

    Return Value

    true if a registration was already established.

  • If isClientRegistered would return false, create a new client registration and record its key (ClientID property of type GUID) in local file ~/ClientRegistration/<ServiceName>.json. Otherwise just load the previously locally-saved registration ID into the ServiceOptions.clientInstanceID. The server’s metadata is expected to include a ClientRegistrationSet entity set with entity type ClientRegistration, a key property named ClientID of type long (Edm.Int64), and a property named ‘ClientGUIDof typeguid(Edm.Guid). If a new registration is successfully created,ServiceOptions.clientInstanceIDis set, and will subsequently be used to populate theClient-Instance-ID` HTTP header for all OData calls. The purpose of creating such a client registration is to enable the server to associate various resources with the current instance of the current client application. A “current instance” can survive multiple restarts of the client application so long as the same Client-Instance-ID header value is provided for each OData call to the remote service. This is particularly useful for offline applications which rely on server-side OData change tracking implementations that store per-client server-side state to facilitate change tracking.

    Declaration

    Swift

    func registerClient(_ client: EntityValue?) throws

    Parameters

    client

    Instance of ClientRegistration entity type. If omitted, a default instance will be created.

  • Forget any client registration previously established by registerClient. Also attempts to make a call to the server to delete the associated entity, if the deleteFromServer parameter is true.

    Declaration

    Swift

    func unregisterClient(deleteFromServer: Bool) throws

    Parameters

    deleteFromServer

    Specify a value of true to request the server to also delete the corresponding entity.