我在我的 Android 应用程序中使用 Google 和 Facebook 登录。我找到了 this thread还谈到一段时间后失去与 Firebase 数据库的连接,这种情况经常发生。我运行了下面的代码,以及“完成的刷新 token ”。永远不会打印出来。
Log.d(TAG, "Start token refresh.");
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); // mAuth is your current firebase auth instance
user.getToken(true).addOnCompleteListener(this, new OnCompleteListener<GetTokenResult>() {
@Override
public void onComplete(@NonNull Task<GetTokenResult> task) {
Log.d(TAG, "Completed refresh token.");
if (task.isSuccessful()) {
Log.d(TAG, "token=" + task.getResult().getToken());
} else {
Log.e(TAG, "exception=" +task.getException().toString());
}
}
});
要使其正常工作,我必须清除我的应用程序中的数据并重新登录,以便它在短时间内再次运行。当我简单地注销帐户并重新登录时,它通常不起作用。尚未尝试使用 Facebook,但现在使用 Google 登录时会发生这种情况。
最佳答案
关于android - Firebase 不刷新 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42192045/