DittoAuthenticator
public class DittoAuthenticator
Provides access to authentication information and methods for logging on to
Ditto Cloud. Relevant when using an onlineWithAuthentication or an
online identity.
-
Returns the current authentication status.
Declaration
Swift
public var status: DittoAuthenticationStatus { get } -
Log in to Ditto with a third-party token.
The completion closure will be called once, whether the login attempt succeeds or fails. If it has failed then the optional
DittoSwiftErrorwill be non-nil, otherwise it will benil. Regardless of whether or not the login attempt succeeds the optionalStringargument will be non-nilif the auth webhook endpoint returned any JSON value under theclientInfokey. That JSON string is what will be passed via theString?argument, if it’s provided.@param token the authentication token required to log in. @param provider the name of the authentication provider. @param completion a closure that will get called when the login attempt has completed.
Declaration
Swift
public func login( token: String, provider: String, completion: @escaping (String?, DittoSwiftError?) -> Void ) -
Log in to Ditto with a third-party token.
@param token the authentication token required to log in. @param provider the name of the authentication provider. @param completion a closure that will get called when the login attempt has completed.
Declaration
Swift
@available(*, deprecated, message: "Use `login` that provides access to the clientInfo JSON string in the completion closure instead.") public func loginWithToken( _ token: String, provider: String, completion: @escaping (DittoSwiftError?) -> Void ) -
Log in to Ditto with a username and password.
@param username the username component of the credentials used for log in. @param password the password component of the credentials used for log in. @param provider the name of the authentication provider. @param completion a closure that will get called when the login attempt has completed.
Declaration
Swift
public func loginWithCredentials( username: String, password: String, provider: String, completion: @escaping (DittoSwiftError?) -> Void ) -
Log out of Ditto.
This will stop sync, shut down all replication sessions, and remove any cached authentication credentials. Use the optional
cleanupclosure to perform any required cleanup.Note that this does not remove any data from the store. The ditto instance returned in the cleanup closure will no longer be authorized for write transactions, e.g.
remove(), however, data may be evicted.@param cleanup an optional closure that will be called with the relevant
Dittoinstance as the sole argument that allows you to perform any required cleanup of the store as part of the logout process.Declaration
Swift
public func logout(cleanup: ((Ditto) -> Void)? = nil) -
Registers a block that will be called whenever authentication
statuschanges. Returns aDittoObserverthat needs to be retained as long as you want to receive the updates.Declaration
Swift
public func observeStatus(_ block: @escaping (DittoAuthenticationStatus) -> Void) -> DittoObserver -
A Combine publisher that shares authentication status.
See moreDeclaration
Swift
struct StatusPublisher : Publisher -
A Combine publisher for authentication status changes.
Declaration
Swift
func statusPublisher() -> StatusPublisherReturn Value
A
StatusPublisherwhich has an output ofDittoAuthenticationStatus.