且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Firebase 令牌身份验证错误

更新时间:2022-01-25 01:07:07

我想你在上传文件之前没有签名.在启动器活动的 onCreate() 中,试试这个代码

I think you didn't sign before uploading files. In onCreate() of launcher activity, try this code

FirebaseAuth mAuth = FirebaseAuth.getInstance(); 

然后在 onStart(),

Then in onStart(),

FirebaseUser user = mAuth.getCurrentUser();
if (user != null) {
  // do your stuff
} else {
  signInAnonymously();
}

匿名登录()

private void signInAnonymously() {
    mAuth.signInAnonymously().addOnSuccessListener(this, new  OnSuccessListener<AuthResult>() {
            @Override
            public void onSuccess(AuthResult authResult) {
                // do your stuff
            }
        })
        .addOnFailureListener(this, new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception exception) {
                Log.e(TAG, "signInAnonymously:FAILURE", exception);
            }
        });
}

这可能会解决您的问题