我基本上是按照文档实施我的应用程序的,但是,这给了我这个错误。我安装了他们的演示,并且也出现了相同的错误
我搜索了互联网,到目前为止没有发现与此问题相关的
import React, { Component } from 'react';
import { View, Text, Platform, ScrollView, Linking } from 'react-native';
import { Button, Card, Icon } from 'react-native-elements';
import { connect } from 'react-redux';
import {Actions} from 'react-native-router-flux';
import * as actions from '../actions';
import { GoogleSignIn } from 'expo-google-sign-in';
import { AuthSession } from 'expo';
import * as Constants from 'expo-constants';
import { AppAuth } from 'expo-app-auth';
import GoogleSignInButton from './GoogleSignInButton';
const { OAuthRedirect, URLSchemes } = AppAuth;
class AuthScreen extends Component {
state = { user: null };
componentDidMount() {
this.initAsync();
}
initAsync = async () => {
await GoogleSignIn.initAsync({
clientId: '1052072418841-6huufh0eq3mbo22ah7v8aml8esau9fvb.apps.googleusercontent.com',
});
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();
}
};
get buttonTitle() {
return this.state.user ? 'Sign-Out of Google' : 'Sign-In with Google';
}
render()
{
return (
// <View>
// <Text>
// Appauth: {JSON.stringify(AppAuth.URLSchemes, null, 2)}
// </Text>
// </View>
<Card>
<Button
type='solid'
title='Register'
large
backgroundColor='#00FFFF'
onPress={() => Actions.register()}
/>
<Button
type='solid'
title='Loging With Facebook'
large
backgroundColor='#00FFFF'
onPress={() => this.props.facebookLogin()}
/>
<GoogleSignInButton onPress={this.onPress}>
{this.buttonTitle}
</GoogleSignInButton>
</Card>
);
}
}
export default connect(null, actions)(AuthScreen);
我唯一需要的是单击Google登录后显示Google登录屏幕
答案 0 :(得分:0)
Expo v32中的Google登录仅在独立模式下工作,这意味着您应该首先构建和发布该应用。不是很方便,但至少不是死路一条。
此处有更多详细信息:https://blog.expo.io/react-native-google-sign-in-with-expo-d1707579a7ce
也请查看评论部分。