我创建了用户登录并注册Android应用程序。我使用Firebase Auth For User Register。我希望当用户注册A计数器值将添加到我的数据库时为该用户。它将为所有用户创建。计数器值将为“0”。
答案 0 :(得分:0)
也许FirebaseAuth.AuthStateListener
是您需要的。见https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseAuth.AuthStateListener
FirebaseAuth fa = FirebaseAuth.getInstance();
fa.addAuthStateListener(new FirebaseAuth.AuthStateListener() {
@Override
onAuthStateChanged(FirebaseAuth auth) {
//not sure how to check for the login event. but this should work too
FirebaseUser currentUser = auth.getCurrentUser()
if(currentUser != null) {
//add your data in your database.
}
}
});
答案 1 :(得分:0)
我认为firebase云功能对此非常有用。你能看一下authentication triggers吗?
您的nodeJS代码是这样的,请查看入门部分here
exports.incrementUserount = functions.auth.user().onCreate(event => {
// increment the counter in the database here
});