【发布时间】:2018-12-20 09:08:22
【问题描述】:
我在 Ios 中使用 react-native 在 android 中执行 googleSignIn 时遇到了这个问题,它完全可以正常工作,但在 ios 中却不是。我也用 cocoapods 尝试过,但它不起作用。我想这是链接的问题,但我按照 googlesignIn ios 文档来实现它,并尝试使用 unlink 和链接 google signIn 但它不起作用。请有人帮帮我。
以下是 googleSignIn 的代码。
componentDidMount() {
this.unsubscriber = firebase.auth().onAuthStateChanged((changedUser) => {
// console.log(`changed User : ${JSON.stringify(changedUser.toJSON())}`);
this.setState({ user: changedUser });
});
GoogleSignin.configure({
iosClientId: '180169766571-2cfig8ri85cplmmdpnk2mcv0vb042055.apps.googleusercontent.com', // only for iOS
})
.then(() => {
// you can now call currentUserAsync()
});
}
onLoginGoogle = () => {
GoogleSignin
.signIn()
.then((data)=> {
// create a new firebase credential with the token
const credential = firebase.auth.GoogleAuthProvider.credential(data.idToken, data.accessToken);
// login with credential
return firebase.auth().signInWithCredential(credential);
})
.then((currentUser)=>{
console.log(`Google Login with user : ${JSON.stringify(currentUser.toJSON())}`);
})
.catch((error) => {
console.log(`Login fail with error ${error}`);
});
}
【问题讨论】:
标签: react-native firebase-authentication google-signin react-native-ios