React Native Firebase谷歌登录遇DEVELOPER_ERROR及未处理Promise拒绝问题
React Native集成Google登录出现DEVELOPER_ERROR问题求助
我已经尝试解决这个问题2天,搜索各类资料并跟随YouTube教程,但仍未找到解决方案。我使用@react-native-google-signin/google-signin包实现Google登录,代码如下:
import { StatusBar } from 'expo-status-bar'; import React from 'react'; import { StyleSheet, Text, View, Button } from 'react-native'; import { GoogleSignin } from '@react-native-google-signin/google-signin'; GoogleSignin.configure({ webClientId: 'xxx.apps.googleusercontent.com', }); export default function App() { return ( <View style={styles.container}> <Text>Loginscreen</Text> <Button title='Login' onPress={googleLogin}/> <StatusBar style="auto" /> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, }); function googleLogin() { console.log("trying to login") onGoogleButtonPress().then(() => console.log('Signed in with Google!')) } async function onGoogleButtonPress() { // Get the users ID token const { idToken } = await GoogleSignin.signIn(); // Create a Google credential with the token const googleCredential = auth.GoogleAuthProvider.credential(idToken); // Sign-in the user with the credential return auth().signInWithCredential(googleCredential); }
运行时模拟器弹出“Login failed”提示,错误类型为DEVELOPER_ERROR,控制台错误日志如下:
WARN Possible Unhandled Promise Rejection (id: 1): Error: DEVELOPER_ERROR promiseMethodWrapper@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:23526:45 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:119816:45 generatorResume@[native code] asyncGeneratorStep@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:25076:26 _next@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:25098:29 tryCallOne@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:30574:16 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:30675:27 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:31754:26 _callTimer@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:31654:17 _callReactNativeMicrotasksPass@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:31689:17 callReactNativeMicrotasks@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:31896:44 __callReactNativeMicrotasks@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:24006:46 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:23785:45 __guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:23989:15 flushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.test&modulesOnly=false&runModule=true:23784:21 flushedQueue@[native code] callFunctionReturnFlushedQueue@[native code]
诚邀各位提供解决思路,感谢帮助。
内容的提问来源于stack exchange,提问作者Patrik Kocmut
相关产品推荐
相关产品推荐

