Hi, I have recently setup firebase for my application for google authentication. What I need help with is once the user has been authenticated via Google authentication. I want to navigate them to a different screen in my application known as the ‘Lobby’ Screen.
So Essentially if my googleSignin() returns success, I want the user to be navigated to the Lobby Screen, I’ve tried my best at doing this, but I can’t seem to figure it out.
Any help would be greatly appreciated!
Useful Docs: https://docs.expo.io/versions/latest/sdk/google/
Code:
import React from “react”;
import { Text, StyleSheet, View, Button, TouchableOpacity, Image } from “react-native”;
import firebase from ‘firebase’
import ‘@firebase/firestore’;
import * as Google from ‘expo-google-app-auth’;
firebase.initializeApp(firebaseConfig);
let provider = new firebase.auth.GoogleAuthProvider();
const googleSignin = async (props) => {
const { type, accessToken, user, idToken } = await Google.logInAsync(config);
if (type === ‘success’) {
console.log(‘sucess’);
props.navigation.navigate(‘Lobby’);
}
}
const navigateLobby = ({ navigation }) => {
navigation.navigate(‘Lobby’);
}
const HomeScreen = ({ navigation }) => {
return (
<Button
title="Go to Lobby Demo"
onPress={() => navigation.navigate('Lobby')}
/>
<TouchableOpacity onPress={() => googleSignin() ? navigation.navigate('Lobby') : null} >
<Image style={styles.imagestyle} source={require('../../assets/GoogleButton.png')} />
</TouchableOpacity>
</View>
);
};
const styles = StyleSheet.create({
text: {
fontSize: 30
}
});
export default HomeScreen;