DITAuthenticator
@interface DITAuthenticator : NSObject
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
Objective-C
@property (nonatomic, readonly) DITAuthenticationStatus *_Nonnull status; -
Log in to Ditto with a third-party token.
Declaration
Objective-C
- (void)loginWithToken:(nonnull NSString *)token provider:(nullable NSString *)provider completion:(nonnull void (^)(NSError *_Nullable))completion;Parameters
tokenthe authentication token required to log in.
providerthe name of the authentication provider.
completiona block that will get called when the login attempt has completed.
-
Log in to Ditto with a username and password.
Declaration
Objective-C
- (void)loginWithUsername:(nonnull NSString *)username password:(nonnull NSString *)password provider:(nullable NSString *)provider completion:(nonnull void (^)(NSError *_Nullable))completion;Parameters
usernamethe username component of the credentials used for log in.
passwordthe password component of the credentials used for log in.
providerthe name of the authentication provider.
completiona block that will get called when the login attempt has completed.
-
Log out of Ditto.
This will stop sync, shut down all replication sessions, and remove any cached authentication credentials. Note that this does not remove any data from the store. If you wish to delete data from the store then use
logout(cleanupBlock:)instead.Declaration
Objective-C
- (void)logout; -
Log out of Ditto.
This will stop sync, shut down all replication sessions, and remove any cached authentication credentials. Note that this does not remove any data from the store. If you wish to delete data from the store then use the optional
cleanupBlockargument to perform any required cleanup.Declaration
Objective-C
- (void)logout:(nullable void (^)(DITDitto *_Nonnull))cleanupBlock;Parameters
cleanupBlockan optional action 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. -
Registers a block that will be called whenever authentication
statuschanges. Returns aDITObserverthat needs to be retained as long as you want to receive the updates.Declaration
Objective-C
- (nonnull id<DITObserver>)observeStatus: (nonnull void (^)(DITAuthenticationStatus *_Nonnull))handler; -
Deprecated
Query whether Ditto has a valid authentication token.
This will only be
YESwhen using anOnlineWithAuthenticationor anOnlineidentity, after a successful login. If the authentication token is allowed to expire then it will returnNOinstead.@deprecated use
statusinstead.Declaration
Objective-C
- (BOOL)isAuthenticated; -
Deprecated
Return the currently logged-in user ID.
This will return
nilif there is no valid authentication orOnlineWithAuthentication/Onlinemode is not being used.@deprecated use
statusinstead.Declaration
Objective-C
- (nullable NSString *)userID;
DITAuthenticator Class Reference