Get email from userInfo from react-native-community/google-signin after sign in and store it in a string?

Hello I have implemented the following code into my app to handle firebase authentication with google signin:

GoogleSignIn = async () => { try { await GoogleSignin.hasPlayServices();  userInfo = await GoogleSignin.signIn(); this.setState({ userInfo }); } catch (error) { if (error.code === statusCodes.SIGN_IN_CANCELLED) {   // user cancelled the login flow } else if (error.code === statusCodes.IN_PROGRESS) {   // operation (e.g. sign in) is in progress already } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {   // play services not available or outdated } else {   // some other error happened     }    }   };    getCurrentUser = async () => {   const currentUser = await GoogleSignin.getCurrentUser();   this.setState({ currentUser }); }; 

Is there any way I can store the users email from userInfo into a string for later use? Thank you!

edit: I have tried it this way but not sure if it is correct

getEmail = async () => { const currentEmail = await GoogleSignin.userInfo.email; return currentEmail; }; 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.