SignInGuard
public class SignInGuard
A reusable helper class that provides sign-in checking functionality for Sudo Platform libraries.
This class encapsulates the logic for checking if a user is signed in and invoking a delegate to handle sign-in when needed. It is designed to be used by any SudoPlatform Client to provide consistent sign-in callback behavior across the platform.
-
Initializes a new SignInGuard instance.
Declaration
Swift
public init(userClient: SudoUserClient, delegate: SudoPlatformSignInDelegate? = nil)Parameters
userClientThe SudoUserClient instance to use for checking sign-in status.
delegateOptional delegate to be invoked when sign-in is required. Can be set later using
setDelegate(_:). -
setDelegate(_:Asynchronous) Sets the delegate to be invoked when sign-in is required.
Declaration
Swift
public func setDelegate(_ delegate: SudoPlatformSignInDelegate?) asyncParameters
delegateA delegate conforming to
SudoPlatformSignInDelegate, or nil to disable sign-in checking. -
ensureSignedIn()AsynchronousChecks if the user is signed in and invokes the delegate if needed.
This method performs the following:
- If no delegate is set, returns immediately
- Checks if the user is signed in using
userClient.isSignedIn() - If not signed in, invokes the delegate’s
signIn()method
Throws
Any error thrown by the delegate’ssignIn()method, or errors from checking sign-in status.Declaration
Swift
public func ensureSignedIn() async throws
SignInGuard Class Reference