SBBAuthManagerDelegateProtocol Protocol Reference

Conforms to NSObject
Declared in SBBAuthManager.h

Overview

This protocol defines the interfaces for the Auth Manager delegate.

– sessionTokenForAuthManager: required method

This delegate method should return the session token for the current signed-in user session, or nil if not currently signed in to any account.

- (nullable NSString *)sessionTokenForAuthManager:(nonnull id<SBBAuthManagerProtocol>)authManager

Parameters

authManager

The auth manager instance making the delegate request.

Return Value

The session token, or nil.

Discussion

Note: This method is required.

Declared In

SBBAuthManager.h

– authManager:didGetSessionToken:forEmail:andPassword: required method

The auth manager will call this delegate method when it obtains a new session token, so that the delegate can store the new sessionToken as well as the email and password used to obtain it, to be returned later in the sessionTokenForAuthManager:, emailForAuthManager:, and passwordForAuthManager: calls, respectively.

- (void)authManager:(nullable id<SBBAuthManagerProtocol>)authManager didGetSessionToken:(nullable NSString *)sessionToken forEmail:(nullable NSString *)email andPassword:(nullable NSString *)password

Parameters

authManager

The auth manager instance making the delegate request.

sessionToken

The session token just obtained by the auth manager.

email

The email used when signing in to obtain this session token.

password

The password used when signing in to obtain this session token.

Discussion

This method provides a convenient interface for keeping track of the auth credentials used in the most recent successful signIn, for re-use when automatically refreshing an expired session token.

Note: This method is now required, and once it has been called, the emailForAuthManager: and passwordForAuthManager: delegate methods must return valid credentials.

Declared In

SBBAuthManager.h

– emailForAuthManager: required method

This delegate method should return the email for the user account last signed up for or signed in to, or nil if the user has never signed up or signed in on this device.

- (nullable NSString *)emailForAuthManager:(nullable id<SBBAuthManagerProtocol>)authManager

Parameters

authManager

The auth manager instance making the delegate request.

Return Value

The email for the user account, or nil.

Discussion

Note: This method is now required, so that the SDK can handle refreshing the session token automatically when 401 status codes are received from the Bridge API.

Declared In

SBBAuthManager.h

– passwordForAuthManager: required method

This delegate method should return the password for the user account last signed up for or signed in to, or nil if the user has never signed up or signed in on this device.

- (nullable NSString *)passwordForAuthManager:(nullable id<SBBAuthManagerProtocol>)authManager

Parameters

authManager

The auth manager instance making the delegate request.

Return Value

The password, or nil.

Discussion

Note: This method is now required. The password is used when encrypting sensitive user data in CoreData, and also for refreshing the session token automatically when 401 status codes are received from the Bridge API.

Declared In

SBBAuthManager.h

– authManager:didReceiveUserSessionInfo:

Implement this delegate method if you want the Auth Manager to notify you when it has updated the UserSessionInfo (and StudyParticipant) as a result of signing in, whether due to user action or to auto-refreshing the session token, or signing out. If you use any of the information contained in either of those objects, you should implement this method and update your app’s state accordingly each time it’s called, so you know you always have the most current versions of those objects and you always know your app’s state reflects the current state of the participant’s account on the server.

- (void)authManager:(nullable id<SBBAuthManagerProtocol>)authManager didReceiveUserSessionInfo:(nullable id)sessionInfo

Parameters

authManager

The auth manager instance making the delegate request.

sessionInfo

The new user session info, or nil if signed out. By default, the SBBUserSessionInfo object (which includes a pointer to the SBBStudyParticipant object), unless the UserSessionInfo type has been mapped in SBBObjectManager setupMappingForType:toClass:fieldToPropertyMappings:.

Declared In

SBBAuthManager.h

– usernameForAuthManager:

For backward compatibility only. Implement emailForAuthManager: instead, which will always be called by the SDK in preference to this.

- (nullable NSString *)usernameForAuthManager:(nullable id<SBBAuthManagerProtocol>)authManager

Parameters

authManager

The auth manager instance making the delegate request.

Return Value

The username, or nil.

Declared In

SBBAuthManager.h

– authManager:didGetSessionToken:

For backward compatibility only. This method will no longer be called. (Deprecated: Implement authManager:didGetSessionToken:forEmail:andPassword instead.)

- (void)authManager:(nullable id<SBBAuthManagerProtocol>)authManager didGetSessionToken:(nullable NSString *)sessionToken

Parameters

authManager

The auth manager instance making the delegate request.

sessionToken

The session token just obtained by the auth manager.

Declared In

SBBAuthManager.h