Reputation: 55
I am unable to resolve the GoogleSignin issue when I ran the code below getting an error
(NOBRIDGE) ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGoogleSignin' could not be found. Verify that a module by this name is registered in the native binary. [Component Stack].
I am new to react native development as well as Firebase and trying to figure this out for almost a week.
import { GoogleSignin } from "@react-native-google-signin/google-signin";
import { firebaseConfig } from "../Firebase/firebase_config";
import auth from "@react-native-firebase/auth";
import React, { useEffect } from "react";
// Initialize Google Sign-In
GoogleSignin.configure({
webClientId: firebaseConfig.webClientId, // Firebase web client ID
});
export default function Index() {
// Google Sign-In handler
const handleGoogleSignIn = async () => {
try {
// Perform the Google sign-in
const userInfo = await GoogleSignin.getTokens();
// Retrieve the ID token from the user object
const idToken = userInfo.idToken; // Access idToken from userInfo
// Create a Google credential using the ID token
const googleCredential = auth.GoogleAuthProvider.credential(idToken);
// Sign in with Firebase using the credential
await auth().signInWithCredential(googleCredential);
Alert.alert("Success", "Signed in with Google!");
} catch (error) {
console.error("Google sign-in error", error);
Alert.alert("Error", "Failed to sign in with Google.");
}
};
return (
<View style={styles.container}>
<Button title="Sign in with Google" onPress={handleGoogleSignIn} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#f5f5f5",
},
});```
Upvotes: 0
Views: 45