Home > Net >  Firebase Authentication using facebook and google signin not working when internet is turned off and
Firebase Authentication using facebook and google signin not working when internet is turned off and

Time:09-17

I have a strange issue with firebase authentication. SigninCredential callback never gets called when I turn off and turn back on the internet. Only after a few hours(probably after 4 hours) callback gets triggered

    val mCredential = FacebookAuthProvider.getCredential(mAccesstoken!!.token)
    mFirebaseAuth.signInWithCredential(mCredential)
        .addOnCompleteListener(this) { it ->
            if (it.isSuccessful) {
                // Sign in success, update UI with the signed-in user's information
                Log.d(TAG, "signInWithCredential:success")
                getCurrentUser(mFirebaseAuth.currentUser)
            } else {
                // If sign in fails, display a message to the user.// unable to retrieve details of the user
                Log.w(
                    TAG,
                    "signInWithCredential:failure:: FirebaseAuthentication failed even though accesstoken present",
                    it.exception
                )
                Toast.makeText(
                    baseContext, "Authentication failed.",
                    Toast.LENGTH_SHORT
                ).show()
            }
        }

If I do a fresh install of the app and perform a sign in it works properly provided that the internet is turned on while I try to login into the app

CodePudding user response:

I figured out the issue. I added a activeinternet condition before performing a login that actual fixed sigin problem that I faced

CodePudding user response:

First check for internet connection before executing the above code.

  • Related