离子 - 未捕(承诺)

时间:2018-02-18 18:27:25

标签: ionic3 ionic-native

获取此问题取消Facebook / Google登录对话框。登录功能完美无缺。

我的代码:

return this.facebook.login(['email', 'public_profile'])
.then(res => {
})
.catch((error) => {
  // can't catch the error
  console.log('error: ', error); // not displayed!
});

这只发生在手机(Cordova)上。在网站上使用Firebase正常工作(“用户取消...”)。 工作代码(桌面):

return this.AngularFireAuth.auth
        .signInWithPopup(new firebase.auth.FacebookAuthProvider())
        .then(function (res) {
        })
        .catch(function (error) {
           // if I cancel the dialog I get the error in this case
        });

1 个答案:

答案 0 :(得分:0)

工作代码:

return this.facebook.login(['email', 'public_profile'])
            .then(res => {
              const facebookCredential = firebase.auth.FacebookAuthProvider.credential(res.authResponse.accessToken);
              return firebase.auth().signInWithCredential(facebookCredential)
                .then(success => {
                }).catch((error) => {
                });
            }).catch((error) => {
            });