I'm having a problem integrating
import * as Google from ‘expo-auth-session/providers/google’
in my native React project. I'm using Expo Go.
I get this error:
(NOBRIDGE) ERROR Error: Cannot find native module 'ExpoApplication' [Component Stack]
I can't find the answer on Google. It seems no one has ever had this error.
I've tried reinstalling the packages, restarting the application but nothing works. Whenever I want to add this library I get this error.
Here is the code I use :
import React, { useState, useEffect } from "react";
import { View, Text, Button } from "react-native";
import * as WebBrowser from "expo-web-browser";
import * as Google from "expo-auth-session/providers/google";
import AsyncStorage from "@react-native-async-storage/async-storage";
import {IOS_CLIENT_ID, WEB_CLIENT_ID } from "@env";
WebBrowser.maybeCompleteAuthSession();
export default function GoogleSignInScreen() {
const [userInfo, setUserInfo] = useState(null);
// Configuration Google OAuth
const [request, response, promptAsync] = Google.useAuthRequest({
clientId: WEB_CLIENT_ID,
iosClientId: IOS_CLIENT_ID,
});
useEffect(() => {
if (response?.type === "success") {
getUserInfo(response.authentication.accessToken);
}
}, [response]);
const getUserInfo = async (token) => {
try {
const res = await fetch(";, {
headers: { Authorization: `Bearer ${token}` },
});
const user = await res.json();
setUserInfo(user);
await AsyncStorage.setItem("user", JSON.stringify(user));
} catch (error) {
console.error(error);
}
};
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text style={{ fontSize: 20, marginBottom: 20 }}>
Se connecter avec Google
</Text>
{userInfo ? (
<Text>Bienvenue, {userInfo.name}!</Text>
) : (
<Button title="Sign in with Google" onPress={() => promptAsync()} />
)}
</View>
);
}
Thank you