Expo,React Native Firebase:GoogleSignIn.initAsync():未定义不是对象

Expo,React Native Firebase:GoogleSignIn.initAsync():未定义不是对象,firebase,react-native,firebase-authentication,expo,react-native-firebase,Firebase,React Native,Firebase Authentication,Expo,React Native Firebase,我做了所有这些,正如在报告中所说的 1转到你的app.json,确保你定义了你想要使用的ios.bundleIdentifier和android.package 2打开Firebase控制台并设置新项目,或使用现有项目 3使用先前定义的捆绑ID和Android软件包创建本机iOS和Android应用程序 4下载GoogleService-info.plist(iOS)和google-services.json(Android)。将它们移动到您的世博会项目中 5在app.json中,将expo.i

我做了所有这些,正如在报告中所说的

1转到你的app.json,确保你定义了你想要使用的ios.bundleIdentifier和android.package

2打开Firebase控制台并设置新项目,或使用现有项目

3使用先前定义的捆绑ID和Android软件包创建本机iOS和Android应用程序

4下载GoogleService-info.plist(iOS)和google-services.json(Android)。将它们移动到您的世博会项目中

5在app.json中,将expo.ios.config.googleSignIn.reservedClientId设置为GoogleService-info.plist中的REVERSE_CLIENT_ID值

6同样在app.json中,将expo.android.googleServicesFile设置为您的google-services.json的相对路径。确保该文件位于您的世博会项目中的某个位置

我的登录屏幕:

import { GoogleSignIn } from 'expo-google-sign-in';

export default class SignIn extends React.Component {
  state = { user: null };


  componentDidMount() {
    this.initAsync();
  }

  initAsync = async () => {
    try {
      await GoogleSignIn.initAsync({ clientId: '{client id from the file here}' });
} catch ({ message }) {
  alert('GoogleSignIn.initAsync(): ' + message);
  console.log(message);
}

    this._syncUserWithStateAsync();
  };

  _syncUserWithStateAsync = async () => {
    const user = await GoogleSignIn.signInSilentlyAsync();
    this.setState({ user });
  };

signOutAsync = async () => {
    await GoogleSignIn.signOutAsync();
    this.setState({ user: null });
  };

  signInAsync = async () => {
    try {
      await GoogleSignIn.askForPlayServicesAsync();
      const { type, user } = await GoogleSignIn.signInAsync();
      if (type === 'success') {
        this._syncUserWithStateAsync();
      }
    } catch ({ message }) {
      alert('login: Error: ' + message);
    }
  };

  onPress = () => {
    if (this.state.user) {
       this.signOutAsync();
    } else {
      this.signInAsync();
    }
  };

  render() {
    return (
      <View style={styles.container}>            
        <View style={styles.buttonContainer}>
          <TouchableOpacity onPress={this.onPress}>
            <View style={styles.googleSignInButton}>
               <AntDesign name='google' size={32} style={styles.googleIcon} />
              <Text style={styles.buttonText}>Sign In using Google</Text>
             </View>
          </TouchableOpacity>
        </View>
      </View>
    );
  }
};
由于某种原因我不知道,GoogleSignIn对象返回时未定义


帮助。

我也有同样的问题。我找到了这个对我有用的解决方案。改变

从“世博谷歌登录”导入谷歌登录;
致:

import*作为“谷歌世博登录”中的谷歌登录;

正如您所说,我遇到了以下错误:expo客户端不支持expo google登录,因为在构建时需要自定义URL方案。请参考世博会以外使用的文档www.npmjs.com/package/Expo谷歌签名inI(我仍在处理该部分:-)如果您能够解决问题,请在此处发布。
undefined is not an object (evaluating '_expoGoogleSignIn.GoogleSignIn.initAsync')