Ran*_*ano 0 firebase ionic-framework firebase-authentication firebase-realtime-database
我正在离子1.X中建立聊天,我想使用Firebase作为我的数据库和auth提供者.首先,我希望能够使用Firebase创建和登录用户.我在帐户中启用了简单的电子邮件和密码验证.然而,大多数的教程这样一个与火力地堡2.作品如果我跟着它,我有一个错误:
在我的index.html中,我加载了firebase,如:
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/1.2.0/angularfire.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
并创建用户:
$scope.signupEmail = function(){
$scope.message = null;
$scope.error = null;
console.log('In signup email with username ' + $scope.data.username + ' email ' + $scope.data.email + ' and password ' + $scope.data.password);
var chatRef = new Firebase('https://some-url.firebaseio.com');
var auth = $firebaseAuth(chatRef);
auth.$createUser({
email: $scope.data.email,
password: $scope.data.password
}).then(function(userData) {
console.log("User created with uid: " + userData.uid);
$scope.message = "User created with uid: " + userData.uid;
}).catch(function(error) {
console.log("Error: " + error);
$scope.error = error;
});
};
Run Code Online (Sandbox Code Playgroud)
逻辑结论和搜索谷歌是我应该使用Firebase 3 SDK来创建用户.但是,在官方的Ionic文档(而不是遗留的文档)中,如果我转到index.html并添加使用firebase的新方法,您可以找到将新SDK与Ionic集成的任何部分:
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase.js"></script>
<script>
// Initialize Firebase
// TODO: Replace with your project's customized code snippet
var config = {
apiKey: "apiKey",
authDomain: "projectId.firebaseapp.com",
databaseURL: "https://databaseName.firebaseio.com",
storageBucket: "bucket.appspot.com",
};
firebase.initializeApp(config);
</script>
Run Code Online (Sandbox Code Playgroud)
然后我无法将"firebase"注入我的模块.
有关如何集成firebase sdk 3和ionic 1.x的任何想法?