国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

我是否在使用Firebase JS SDK還是React-Native-Firebase?
P粉083785014
P粉083785014 2023-09-02 18:27:28
0
1
769
<p>我使用Firebase的JS SDK創(chuàng)建了一個大型的Web應(yīng)用程序,現(xiàn)在我正在使用React-Native和Expo過渡到移動應(yīng)用程序。由于我使用Expo,我創(chuàng)建了一個開發(fā)客戶端,以便不使用Expo Go,因為RNFirebase使用本地代碼。 <strong>我的目標(biāo):實現(xiàn)與React-Native-Firebase身份驗證相關(guān)聯(lián)的基本Google登錄</strong></p> <p>我已經(jīng)使用npm安裝了"react-native-firebase/app"和"react-native-firebase/auth"</p> <p>然而,當(dāng)我嘗試使用Google的登錄驗證(https://rnfirebase.io/auth/social-auth)時,我一直收到一個錯誤,說'[DEFAULT]' firebase app未初始化。</p> <p>所以,我按照另一個指南(我不知道是否正確),告訴我創(chuàng)建一個類似于我的Web應(yīng)用程序的firebase.js文件,其中包含以下內(nèi)容:</p> <pre class="brush:php;toolbar:false;">import firebase from '@react-native-firebase/app'; import auth from '@react-native-firebase/auth'; // 對于Firebase JS SDK v7.20.0及更高版本,measurementId是可選的 const firebaseConfig = {apiKey: "AIzaSyCoNUZI0-Mir9hGtXUJJmIrML88JxSOJAk",authDomain: "campus-market-25068.firebaseapp.com",databaseURL: "https://campus-market-25068-default-rtdb.firebaseio.com",projectId: "campus-market-25068",storageBucket: "campus-market-25068.appspot.com",messagingSenderId: "315015080294",appId: "1:315015080294:web:53dbed097963d67b92c0a7",measurementId: "G-5TVXC2MQ7S"};if (!firebase.apps.length) {firebase.initializeApp(firebaseConfig);}export { firebase, auth }</pre> <p>現(xiàn)在,身份驗證可以工作,但我不知道我是否仍在使用RNFirebase還是使用Firebase的JS SDK。有人可以回答嗎?這是我的身份驗證代碼:</p> <pre class="brush:php;toolbar:false;">import 'expo-dev-client' import { useState, useEffect } from 'react'; import { StatusBar } from 'expo-status-bar'; import { StyleSheet, Text, View, Button } from 'react-native'; // import './src/firebase';/ / import * as firebase from '@react-native-firebase/app'; import { auth } from './firebase'; import { GoogleSignin } from '@react-native-google-signin/google-signin'; export default function App() { GoogleSignin.configure({ webClientId: '315015080294-gejpuoaedqhbcve32dat55gg4cn5va3j.apps.googleusercontent.com', }); async function onGoogleButtonPress() { // 檢查設(shè)備是否支持Google Play await GoogleSignin.hasPlayServices({ showPlayServicesUpdateDialog: true }); // 獲取用戶的ID令牌 console.log(GoogleSignin); const { idToken } = await GoogleSignin.signIn(); const googleCredential = auth.GoogleAuthProvider.credential(idToken); // 使用憑據(jù)登錄用戶 return auth().signInWithCredential(googleCredential);// console.log("YOOOOOOO5")// console.log(res)} return ( <View style={styles.container}><Text>打開App.js開始開發(fā)您的應(yīng)用程序!</Text><StatusBar style="auto" /><Button title="Google登錄" onPress={() => onGoogleButtonPress().then(() => console.log('使用Google登錄!'))}/></View>);}) ) const styles = StyleSheet.create({container: {flex: 1,backgroundColor: '#fff',alignItems: 'center',justifyContent: 'center',},});</pre> <p>我不確定從哪里開始</p>
P粉083785014
P粉083785014

全部回復(fù)(1)
P粉682987577

在這行代碼中,使用了 auth().signInWithCredential ,你仍然在使用 react-native-firebase 庫:

return auth().signInWithCredential(googleCredential);

在 Firebase JavaScript SDK 中,這可能是 firebase.auth().signInWithCredential 或者 signInWithCredential(auth, ...。

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板