Search code examples
androidkotlinfacebookfacebook-login

Methods of facebookCallback are not being called while trying to login with facebook


I am trying to login with facebook on click of my button I am able to open facebook custom tab and able to use "Continue as user" but after that I am navigating back to my app and nothing is happening.

I am using a fragment bottom sheet for login.

LoginManager.getInstance().logInWithReadPermissions(
                        requireActivity(),
                        listOf(E_MAIL, "public_profile")
                    )
LoginManager.getInstance().registerCallback(callbackManager,object :FacebookCallback<LoginResult>{
                        override fun onCancel() {
                            mViewModel.isLoading.set(false)
                        }

                        override fun onError(error: FacebookException) {
                            mViewModel.isLoading.set(false)
                        }

                        override fun onSuccess(result: LoginResult) {
                            handleFacebookAccessToken(result.accessToken)
                        }

                    })

and using the onActivity Result like this

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        if(this::callbackManager.isInitialized)
            callbackManager.onActivityResult(requestCode, resultCode, data);
        super.onActivityResult(requestCode, resultCode, data)
}

Solution

  • I found out the issue there was nothing wrong with the code I just added my SHA to the firebase project downloaded the json file and it worked fine.