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

    userClient

    The SudoUserClient instance to use for checking sign-in status.

    delegate

    Optional 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?) async

    Parameters

    delegate

    A delegate conforming to SudoPlatformSignInDelegate, or nil to disable sign-in checking.

  • ensureSignedIn() Asynchronous

    Checks if the user is signed in and invokes the delegate if needed.

    This method performs the following:

    1. If no delegate is set, returns immediately
    2. Checks if the user is signed in using userClient.isSignedIn()
    3. If not signed in, invokes the delegate’s signIn() method

    Throws

    Any error thrown by the delegate’s signIn() method, or errors from checking sign-in status.

    Declaration

    Swift

    public func ensureSignedIn() async throws