【发布时间】:2018-10-16 16:05:03
【问题描述】:
我正在尝试通过 facebook 登录访问我的 react 本机应用程序。我在 android 上使用 fbsdk 和 firebase。这是我的功能:
loginConFacebookHandler = () => {
LoginManager.logInWithReadPermissions(['public_profile'])
.then(result => {
if (result.isCancelled) {
console.log('Cancelado')
return Promise.reject(new Error('The user cancelled the request'));
}
console.log(`Login success with permissions: ${result.grantedPermissions.toString()}`);
return AccessToken.getCurrentAccessToken();
})
.then(data => {
const credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);
return firebase.auth().signInWithCredential(credential);
})
.then(currentUser => {
console.log(`Facebook Login with user : ${JSON.stringify(currentUser.toJSON())}`);
() => {startMainTabs()}
})
.catch(error => {
console.log(`Login con facebook falló con error: ${error}`);
})
}
startMainTabs() 重定向到另一个屏幕。当我使用用户名和密码登录时,它可以完美运行:
loginUsuarioYContraseñaHandler = (email, password) => {
firebase.auth().signInWithEmailAndPassword(email, password)
.then(() => {startMainTabs()})
.catch(error => {alert(error)})
};
【问题讨论】:
标签: firebase react-native fbsdk