模块“firebase/auth”没有导出成员“signInWithPopup”

问题描述 投票:0回答:1

我正在尝试在 React Native + Expo 项目上使用谷歌的弹出登录,但我无法导入该方法。我正在阅读 firebase 变更日志,该方法似乎并未被弃用。

import { router } from 'expo-router';
import {
    GoogleAuthProvider,
    User,
    onAuthStateChanged,
    signInWithCredential,
    signInWithPopup, // I got the error here
    signOut,
} from 'firebase/auth';

package.json

"dependencies": {
  "@expo/vector-icons": "^14.0.0",
  "@react-native-async-storage/async-storage": "1.23.1",
  "@react-navigation/native": "^6.0.2",
  "expo": "^51.0.8",
  "expo-application": "~5.9.1",
  "expo-auth-session": "~5.5.2",
  "expo-crypto": "~13.0.2",
  "expo-dev-client": "~4.0.14",
  "expo-font": "~12.0.5",
  "expo-image": "~1.12.9",
  "expo-linking": "~6.3.1",
  "expo-router": "~3.5.14",
  "expo-splash-screen": "~0.27.4",
  "expo-status-bar": "~1.12.1",
  "expo-system-ui": "~3.0.4",
  "expo-web-browser": "~13.0.3",
  "firebase": "^10.11.1",
  "react": "18.2.0",
  "react-dom": "18.2.0",
  "react-native": "0.74.1",
  "react-native-paper": "^5.12.3",
  "react-native-safe-area-context": "4.10.1",
  "react-native-screens": "3.31.1",
  "react-native-web": "~0.19.6"
},
"devDependencies": {
  "@babel/core": "^7.20.0",
  "@types/react": "~18.2.45",
  "jest": "^29.2.1",
  "jest-expo": "~51.0.2",
  "react-test-renderer": "18.2.0",
  "typescript": "~5.3.3"
},
javascript firebase react-native firebase-authentication expo
1个回答
0
投票

signInWithPopup
是浏览器预期使用的方法。 React-Native 不是浏览器......它是一个“本机应用程序”。

如果您尝试使用 Google 身份验证通过“本机应用程序”进行身份验证,那么您将需要使用

react-native-firebase
而不是 Firebase Web 客户端 SDK (
firebase
)。

我在这篇文章中写了这两个库之间的差异

© www.soinside.com 2019 - 2024. All rights reserved.