Firebase addValueEventListener only working for a couple of hours

后端 未结 1 1653
情话喂你
情话喂你 2020-12-03 06:24

has anyone experienced this issue? My firebase code only works for basically a couple of hours (fully functional and all), and then when I try again it doesn\'t work anymore

相关标签:
1条回答
  • 2020-12-03 06:53

    This issue is caused by Firebase Auth tokens not refreshing themselves properly, which itself is caused by an underlying misconfiguration in your Firebase project.

    You can tell if the token refresh is failing by calling the following snippet after you sign a user in:

    FirebaseUser user = mAuth.getCurrentUser(); // mAuth is your current firebase auth instance
    user.getToken(true).addOnCompleteListener(this, new OnCompleteListener<GetTokenResult>() {
        @Override
        public void onComplete(@NonNull Task<GetTokenResult> task) {
            if (task.isSuccessful()) {
                Log.d(TAG, "token=" + task.getResult().getToken());
            } else {
                Log.e(TAG, "exception=" +task.getException().toString());
            }
        }
    });
    

    (If there is an issue, you will get an exception).

    You can follow this guide that we have put together in the Firebase team to troubleshoot and fix any issues with configuration that can cause this problem.

    The above steps should be a permanent fix for the issue, however, we are also working hard to implement a way of automatically detecting misconfigurations and fixing them transparently for you. Apologies for any problem this may have caused you.

    0 讨论(0)
提交回复
热议问题