Firebase logout is not working

后端 未结 3 1545
猫巷女王i
猫巷女王i 2021-01-21 23:44

I have begin to use Firebase but my experience is terrible.

I cannot sign out user.

I have tried different things and spend all my 4 days to figure out how to si

相关标签:
3条回答
  • 2021-01-22 00:19

    I also have this problem, right now, the LogoutBtn is inside a drawer, like this:

    case R.id.initiates_logout:
                if(FirebaseAuth.getInstance().getCurrentUser()!=null){
                    new AlertDialog.Builder(this)
                            .setTitle("Text1")
                            .setMessage("Text2")
                            .setIcon(android.R.drawable.ic_dialog_alert)
                            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int whichButton) {
                                    FirebaseAuth.getInstance().signOut();
                                    LoginManager.getInstance().logOut();
    
    
                                }})
                            .setNegativeButton(android.R.string.no, null).show();
                }
                break;
    

    And i cant select another account after the logout.

    0 讨论(0)
  • 2021-01-22 00:27

    If you check the Firebase Auth Quickstart sample code, the sign-out for Google provider includes these steps.

    Are you calling Auth.GoogleSignInApi.signOut() when you sign-out? So, please use this code:

    private void signOut() {
        // Firebase sign out
        mAuth.signOut();
    
        // Google sign out
        Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
            new ResultCallback<Status>() {
                @Override
                public void onResult(@NonNull Status status) {
                    //do what you want
                }
            });
    }
    
    0 讨论(0)
  • 2021-01-22 00:41

    You are using a newer version than me, I doubt they introduced a new bug. You mentioned NullPointerException earlier, so I suggest you make sure the GoogleApiClient you pass to Auth.GoogleSignInApi.getSignInIntent is not null.

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