Expo集成Google登录后Firebase控制台无用户显示问题求助
Expo开发App:Google登录成功但Firebase控制台无用户记录问题
我正在用Expo开发一款App,需要实现邮箱/密码或Google登录认证功能。目前邮箱/密码认证已经实现且功能正常,相关代码如下:
Firebase初始化代码
// this is the function for initiating firebase function init_firebase(){ const firebaseConfig = { apiKey: ' AIzaSyCs-qNMrjikN5VqKdY737K22QSsT9MmtGI ', authDomain: 'tiod-app.firebaseapp.com', databaseURL: 'https://tiod-app-default-rtdb.europe-west1.firebasedatabase.app/', projectId: 'tiod-app', appId: '1:659850692368:android:bf812065131d214dfb0795', }; const app = initializeApp(firebaseConfig); const auth = initializeAuth(app, { persistence: getReactNativePersistence(ReactNativeAsyncStorage) }); return {app, auth}; } export const firebase = init_firebase();
邮箱注册与登录代码
// the function for signing up async function Signup_email(navigation: NavigationProp<ParamListBase>, email: string, password: string){ const login = await createUserWithEmailAndPassword(firebase.auth, email, password).catch((e) => { console.log(e); }); if (login){return;} navigation.navigate('Main', {email}); } // the function for logging in async function Login_email(navigation: NavigationProp<ParamListBase>, email: string, password: string, ){ const app = firebase; if (!app){return;} const login = await signInWithEmailAndPassword(app.auth, email, password).catch((e) => {console.log(e)}); if (!login){return;} navigation.navigate('Loading', login.user.toJSON()); }
在实现Google认证时,我发现signInWithRedirect函数因涉及DOM操作未定义,于是改用@react-native-google-signin/google-signin来实现,完成了Google登录功能,代码如下:
Google登录代码
async function Login_google(navigation: NavigationProp<ParamListBase>){ const result = await GoogleSignin.signIn().catch((e) => {console.log(e)}); if (!result){return;} navigation.navigate('Loading', result.user); }
Google登录配置
GoogleSignin.configure({webClientId: "659850692368-bf2itlqkbbroq5cd3e8lq969qtk8ks5i.apps.googleusercontent.com", googleServicePlistPath: "../GoogleService-Info.plist", })
现在Google登录功能可以正常使用,但Firebase控制台的用户面板仍然是空的。
内容的提问来源于stack exchange,提问作者throwaway account
相关产品推荐
相关产品推荐

