Jør*_*and 3 firebase ionic-framework firebase-authentication
我正在将一个离子应用程序从firebase v2合并到firebase v3.
当我使用新的(v3)firebase电子邮件/密码登录API时,我没有经过身份验证,每次重新启动应用程序时都必须登录.
首次登录应用程序时,用户应保持身份验证状态.或者至少这是firebase v2 API中的默认值.
如何坚持登录?
谢谢,Jørgen
你应该用onAuthStateChanged().只要认证状态发生变化,就会调用此函数.
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
... do other stuff
} else {
// No user is signed in.
... do other stuff
}
});
Run Code Online (Sandbox Code Playgroud)
如果您在打开应用程序时已经登录,或者您打电话signInWithEmailAndPassword,则会调用此功能并user包含该功能firebase.auth().currentUser.
| 归档时间: |
|
| 查看次数: |
408 次 |
| 最近记录: |