作为一个问题,在firebase中登录google需要设置google-service,但如果你用create- react-native -app创建一个新的react-native项目,将没有"android“或"ios”文件夹(接受使用的"eject"),所以,有人给我一个建议吗?然而,我也不知道如何在我的项目中设置google-service (甚至我也“弹出”了这个项目)。
发布于 2017-06-19 02:43:21
无需对android或ios文件夹进行任何更改,即可在使用世博会构建的应用程序上使用firebase支持Google登录。
发布于 2018-05-18 03:20:28
@brentvatne的答案有点过时。以下是我是如何在v27世博会上使用它的
重要提示:您可以使用these instructions获取客户端ids。
只需从google页面的项目下拉列表中选择您的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);
}
};https://stackoverflow.com/questions/44616596
复制相似问题