Sha*_*ari 5 javascript firebase reactjs react-native google-signin
我已经使用此链接在 Firebase 上启用了 Google SignIn https://rnfirebase.io/auth/social-auth我的应用程序编译正常,但是当我按下登录按钮并选择 Google 帐户进行登录时,我得到了可能的未处理承诺拒绝(id:0):错误:DEVELOPER_ERROR https://rnfirebase.io/auth/social-auth 我有 Windows 10 和
react-native-cli: 2.0.1
react-native: 0.63.4
Node : v12.16.0
Run Code Online (Sandbox Code Playgroud)
这是App.js
import React , {useState , useEffect} from 'react';
import { Text TextInput, View } from 'react-native';
import {ButtonTemplate} from '../assets/ButtonTemplate'
import auth from '@react-native-firebase/auth';
import { GoogleSignin } from '@react-native-community/google-signin';
const App = () => {
useEffect(()=> {
GoogleSignin.configure({
webClientId: 'xxxxxxxxxxxxxx.apps.googleusercontent.com',
});
})
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);
}
const googleLogin=()=>{
console.log('Google SignIn');
onGoogleButtonPress().then(() => console.log('Signed in with Google!'))
}
return (
<ButtonTemplate
text={"Continue With Google"}
backgroundColor={'#5384ed'}
fontSize={16}
marginTop= {'3%'}
iconText={'G'}
justifyContent={'flex-start'}
onPress={googleLogin}
/>
)
};
export default App;
Run Code Online (Sandbox Code Playgroud)
这是错误
Possible Unhandled Promise Rejection (id: 0):
Error: DEVELOPER_ERROR
promiseMethodWrapper@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2258:45
signIn$@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:189098:72
tryCatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25048:23
invoke@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25221:32
tryCatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25048:23
invoke@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25121:30
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25131:21
tryCallOne@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27134:16
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27235:27
_callTimer@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:30674:17
_callImmediatesPass@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:30713:17
callImmediates@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:30930:33
__callImmediates@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2760:35
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2546:34
__guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2743:15
flushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2545:21
flushedQueue@[native code]
callFunctionReturnFlushedQueue@[native code]
Run Code Online (Sandbox Code Playgroud)
我有两个问题,第一个问题是上面的,第二个An OAuth2 client already exists for this package name and SHA-1 in another project.问题是在 Firebase 中添加 SHA1 到项目中时的第二个问题。我解决了这个问题
keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 10000keytool -keystore debug.keystore -list -v然后在给出位于的密码后通过此命令获取 SHA1 和 SHA256android/App/build.gradle then signingConfigs there is store passwordandroid/App文件夹中cd android && ./gradlew clean npx react-native run-android我使用了这个链接How to Implement Google Login in React Native with Firebase 也是一个 Youtube 视频Youtube 视频相关的上一个链接
| 归档时间: |
|
| 查看次数: |
4939 次 |
| 最近记录: |