最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Cannot find native module 'Expo application' - Stack Overflow

programmeradmin0浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论