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

    token

    the authentication token required to log in.

    provider

    the name of the authentication provider.

    completion

    a 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

    username

    the username component of the credentials used for log in.

    password

    the password component of the credentials used for log in.

    provider

    the name of the authentication provider.

    completion

    a 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 cleanupBlock argument to perform any required cleanup.

    Declaration

    Objective-C

    - (void)logout:(nullable void (^)(DITDitto *_Nonnull))cleanupBlock;

    Parameters

    cleanupBlock

    an optional action that will be called with the relevant Ditto instance 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 status changes. Returns a DITObserver that 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;