File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,8 +62,24 @@ function PhoneSignIn() {
6262 // If null, no SMS has been sent
6363 const [confirm , setConfirm ] = useState (null );
6464
65+ // verification code (OTP - One-Time-Passcode)
6566 const [code , setCode ] = useState (' ' );
6667
68+ // Handle login
69+ function onAuthStateChanged (user ) {
70+ if (user) {
71+ // Some Android devices can automatically process the verification code (OTP) message, and the user would NOT need to enter the code.
72+ // Actually, if he/she tries to enter it, he/she will get an error message because the code was already used in the background.
73+ // In this function, make sure you hide the component(s) for entering the code and/or navigate away from this screen.
74+ // It is also recommended to display a message to the user informing him/her that he/she has successfully logged in.
75+ }
76+ }
77+
78+ useEffect (() => {
79+ const subscriber = auth ().onAuthStateChanged (onAuthStateChanged);
80+ return subscriber; // unsubscribe on unmount
81+ }, []);
82+
6783 // Handle the button press
6884 async function signInWithPhoneNumber (phoneNumber ) {
6985 const confirmation = await auth ().signInWithPhoneNumber (phoneNumber);
You can’t perform that action at this time.
0 commit comments