SMS code AutoRetrieval #6209
-
Hello and thanks for this awesome library 🔥🔥🔥 Can SMS codes be autoretrieved ? If so how to check if it was autoretrieved before the user inputs the code ? Sorry, I didn't find anything about this in the docs. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
if you listen to onAuthStateChanged, which passes a user parameter, and that user !== undefined, that means they have logged in via SMS auto-retrieval https://rnfirebase.io/auth/usage#listening-to-authentication-state So in a "normal" app where you have protected and unprotected screens, as soon as onAuthStateChanged is called with a valid user and you set that in to your state (or Context or whatever) then you'll immediately flip to your logged-in screens and be all set A bit like so |
Beta Was this translation helpful? Give feedback.
if you listen to onAuthStateChanged, which passes a user parameter, and that user !== undefined, that means they have logged in via SMS auto-retrieval
https://rnfirebase.io/auth/usage#listening-to-authentication-state
So in a "normal" app where you have protected and unprotected screens, as soon as onAuthStateChanged is called with a valid user and you set that in to your state (or Context or whatever) then you'll immediately flip to your logged-in screens and be all set
A bit like so
https://github.com/invertase/react-native-firebase-authentication-example/blob/68bd37f8c219f892655b40c73e9818370f368b82/template/src/app/App.tsx#L36-L70