我正在尝试在登录后获取匿名用户的UID,但它不会抛出任何异常,而是只是不输入登录代码。这就是我所做的
private void initAnonymLogin(final int number) {
initProgressDialog("Saving alarm","wait...");
mAuth.signInAnonymously()
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInAnonymously:success");
FirebaseUser user = mAuth.getCurrentUser();
DatabaseReference ref = mDatabase.child("post").child(user.getUid());
Map<String,Object> postMap = new HashMap<>();
clienteMap.put("device_token",devicetoken);
clienteMap.put("notifyAt",number);
ref.updateChildren(postMap).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
progressDialog.dismiss();
}
});
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInAnonymously:failure", task.getException());
}
// ...
}
});
}
我在Firebase控制台上启用了Firebase匿名登录,但是仍然无法正常工作。我读了日志并把它扔了
com.google.firebase.FirebaseException:发生内部错误。 [在之前的项目xxxxxxx中未使用Identity Toolkit API或 它被禁用。通过访问启用它 https://console.developers.google.com/apis/api/ident .....
我打开了链接,但是看了一点之后我不需要使用该api,因为现在我们可以使用Firebase身份验证