TypeError:无法读取react-native中未定义的属性“ configure”

时间:2018-07-12 08:13:55

标签: react-native firebase-authentication google-signin react-native-ios

我在ios中使用android的react-native进行googleSignIn时遇到了这个问题,但在ios中却没有。我也用cocoapods尝试过,但是没有用。我想链接存在问题,但是我遵循了googlesignIn ios文档来实现它,并且还尝试了取消链接和链接google signIn的操作,但是它不起作用。请有人帮我。

enter image description here

下面是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}`);
              });
        }

1 个答案:

答案 0 :(得分:0)

像这样单独使用配置

componentDidMount(){
this.GoogleSignIn
}

GoogleSignIn = async () => {
    await GoogleSignin.configure({
        iosClientId:'key',
        offlineAccess: false,
    });
};