Swift: Listen to auth events
- Types of auth events:
INITIAL_SESSION
, SIGNED_IN
, SIGNED_OUT
, TOKEN_REFRESHED
, USER_UPDATED
, PASSWORD_RECOVERY
, MFA_CHALLENGE_VERIFIED
- The
INITIAL_SESSION
can be used to allow you to invoke the callback function when authStateChanges
is first called.
Examples
Listen to auth changes
for await (event, session) in await supabase.auth.authStateChanges \{
print(event, session)
\}
Listen to a specific event
for await (_, session) in await supabase.auth.authStateChanges.filter(\{ $0.event == .signedIn \}) \{
// handle signIn event.
\}