使用Expo进行Google登录时出现错误,并进行本机响应。
export default class App extends React.Component {
onPressLearnMore = async () => {
try {
const { type, user, accessToken } = await Expo.Google.logInAsync({
webClientId: '694750299286-9rvrhtrb97gc5781euta08qau7s483ma.apps.googleusercontent.com',
});
if (type === 'success') {
console.log(user, accessToken);
}
} catch ({ message }) {
alert(`login: ${message}`);
}
};
render() {
return (
<View style={styles.container}>
<Button
onPress={this.onPressLearnMore}
title="Login"
color="#841584"
/>
</View>
);
}
}
点击登录按钮后,Google应该会登录。