我试图用离子只是使用这个火力点身份验证:使用Ionic2与火力权威性
signInWithFacebook(): firebase.Promise<FirebaseAuthState> {
if (this.platform.is('cordova')) {
console.log("trying to log in using cordova...");
Facebook.login(['email', 'public_profile']).then(res => {
console.log("Logged in. result here");
const facebookCredential = firebase.auth.FacebookAuthProvider.credential(res.authResponse.accessToken);
console.log(firebase.auth().signInWithCredential(facebookCredential));
return firebase.auth().signInWithCredential(facebookCredential);
});
} else {
return this.auth$.login({
provider: AuthProviders.Facebook,
method: AuthMethods.Popup
});
}
}
这段代码在网络的伟大工程,但在安卓(科尔多瓦)不起作用。
我调试为什么登录按钮不工作,我发现这样的错误:
EXCEPTION: Error in ./HomePage class HomePage - inline template:6:0 caused by: Cannot read property 'then' of undefined....
Logged in. result here
EXCEPTION: Uncaught (in promise): ReferenceError: firebase is not defined ReferenceError: firebase is not defined at file:///android_asset/www/build/main.js:42039:42 at t.invoke...
关于第二个问题(没有定义火力),我试图
`import firebase from 'firebase';`
但离子2编译返回错误。
我只是使用的代码使用离子2.
任何人有任何想法,为什么这可能发生的Angularfire2权威性?
它解决了问题,但返回了错误的数据。我需要返回这个:'firebase.auth()。signInWithCredential(facebookCredential)' – TheUnreal
if firebase.auth()。signInWithCredential(facebookCredential);''返回一个承诺信息你需要的,你会收到在''signInWithFacebook()''中返回的承诺 – raj