Noe*_*ova 5 google-authentication firebase google-play-services expo create-react-native-app
作为问题,对于使用gobase in firebase登录需要设置google-service但是如果使用create-react-native-app创建新的react-native项目则不会有"android"或"ios"文件夹(接受使用"弹出" ")所以,有人对我有建议吗?但是我也不知道如何在我的项目中设置google-service(甚至我"弹出"项目).
Joe*_*ddy 10
@brentvatne的回答有点过时了.以下是我在Expo v27上的工作方式
重要的一点:您可以使用这些说明获取客户ID .
只需从谷歌页面上的项目下拉列表中选择您的firebase应用程序即可.
const _loginWithGoogle = async function() {
try {
const result = await Expo.Google.logInAsync({
androidClientId:"YOUR_ANDROID_CLIENT_ID",
iosClientId:"YOUR_iOS_CLIENT_ID",
scopes: ["profile", "email"]
});
if (result.type === "success") {
const { idToken, accessToken } = result;
const credential = firebase.auth.GoogleAuthProvider.credential(idToken, accessToken);
firebase
.auth()
.signInAndRetrieveDataWithCredential(credential)
.then(res => {
// user res, create your user, do whatever you want
})
.catch(error => {
console.log("firebase cred err:", error);
});
} else {
return { cancelled: true };
}
} catch (err) {
console.log("err:", err);
}
};
Run Code Online (Sandbox Code Playgroud)
无需对 android 或 ios 文件夹进行任何更改即可支持 Google 在使用 Expo 构建的应用程序上使用 firebase 登录。
归档时间: |
|
查看次数: |
5202 次 |
最近记录: |