上QQ阅读APP看书,第一时间看更新
Anonymous Authentication
The name clearly states that the application allows users to access the application's features by providing a temporary anonymous identity. We need to enable anonymous login in the Firebase console. Next, the anonymousSignIn method calls the signInAnonymously() method of the FirebaseAuth instance:
public void anonymousSignIn() {
FirebaseAuth.signInAnonymously()
.addOnCompleteListener(this,
new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
Toast.makeText(AnonAuthActivity.this,
"Authentication failed. "
+ task.getException(),
Toast.LENGTH_SHORT).show();
} else {
softButton.setText("Create an Account");
buttonMode = CREATE_MODE;
}
}
});
}