我只是想在Ionic App中创建一个简单的社交登录(例如:google,Facebook,...),并使用Firebase V3作为后端。不幸的是,我在互联网上找到的所有示例和教程似乎都被打破了,并且无法使用新的API v3。
进行操作但显然我无法访问以前可用的全局变量Firebase,因此我无法访问app.js的这个片段
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'firebase'])
.constant('FirebaseUrl', 'https://ionicle.firebaseio.com/')
.service('rootRef', ['FirebaseUrl', Firebase])
我收到以下错误
ReferenceError: Can't find variable: Firebase, http://localhost:8103/js/app.js, Line: 12
答案 0 :(得分:1)
facebookAuth: function () {
ngFB.login({ scope: 'email' }).then(
function (response) {
if (response.status === 'connected') {
console.log('Facebook login succeeded', response);
var credential = firebase.auth.FacebookAuthProvider.credential(
response.authResponse.accessToken);
firebase.auth().signInWithCredential(credential).catch(function (error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
} else {
alert('Facebook login failed');
}
});
},
更多详细信息:http://www.clearlyinnovative.com/firebase-3-0-ionic-facebook-login