facebook-android-sdk icon indicating copy to clipboard operation
facebook-android-sdk copied to clipboard

Facebook login always gets cancelled but nothing has changed within my codebase and its working since it was released

Open renzified opened this issue 3 years ago • 1 comments

Checklist before submitting a bug report

Java version

11

Android version

Android 11, Android 12

Android SDK version

14.1.1

Installation platform & version

gradle

Package

Login

Goals

Login via facebook login sdk

Expected results

The facebook login sdk should proceed and return the result

Actual results

The callback always triggers cancelled

Steps to reproduce

  1. Create a jetpack compose project
  2. integrate the login sdk

Code samples & details

if (context is ActivityResultRegistryOwner) {
                            val callBackManager = CallbackManager.Factory.create()
                            val loginManager = LoginManager.getInstance()
                            loginManager.registerCallback(
                                callbackManager = callBackManager,
                                callback = object : FacebookCallback<LoginResult> {
                                    override fun onCancel() {
                                        Log.i("spawned", "this always triggers")
                                    }

                                    override fun onError(error: FacebookException) {
                                        if (error.message != null) {
                                            if (error.message == "CONNECTION_FAILURE: CONNECTION_FAILURE") {
                                                showError("Network error, Please check your internet connection.")
                                            } else {
                                                showError("Facebook is not available at the moment. Please try again later")
                                            }
                                        } else {
                                            showError("Facebook is not available at the moment. Please try again later")
                                        }
                                    }

                                    override fun onSuccess(result: LoginResult) {
                                        loginFacebookUser(result.accessToken.token)
                                    }
                                }
                            )
                            LoginManager.getInstance()
                                .logIn(
                                    activityResultRegistryOwner = context,
                                    callbackManager = callBackManager,
                                    permissions = listOf("email", "public_profile")
                                )
                        }

renzified avatar Sep 15 '22 23:09 renzified

We are facing the same issue. Facebook login always gets cancelled for Android 6.0.1. We are not using jetpack compose but still getting onCancel event for Android 6.0.1.

[fyi] If we uninstall facebook app from device and use web, then we get onSuccess event in Android 6.0.1.

Al-Rasel avatar Sep 16 '22 00:09 Al-Rasel

We are facing the same issue too, my sdk version is 12.2.0, and my facebook app version is 382.0.0.33.111. I try in several devices and facebook accounts, but suffer the same issue. And I debug the source code, and found when we call logIn function, the final call is in NativeAppLoginMethodHandler.tryIntent(),following is source code:

protected boolean tryIntent(Intent intent, int requestCode) {
    if (intent == null) {
      return false;
    }

    try {
      getLoginClient().getFragment().startActivityForResult(intent, requestCode);
    } catch (Exception e) {
      // We do not know if we have the activity until we try starting it.
      // FB is not installed if ActivityNotFoundException is thrown and this might fallback
      // to other handlers
      return false;
    }

    return true;
  }

and in the LoginFragment we receive the result in onActivityResult, but the param data in the callback is null, and finally triger the onCancel() in FacebookCallback. Is someone know why, and pls tell me how to resolve it?

 // data is null
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    loginClient.onActivityResult(requestCode, resultCode, data);
  }

zfc580 avatar Sep 16 '22 07:09 zfc580

same issue last friday always cancelled when facebook app installed, but after uninstalled, has no problem by web login it seems fixed/resumed now

mpcht avatar Sep 19 '22 03:09 mpcht

its not fixed yet for some of our users

renzified avatar Sep 19 '22 06:09 renzified

its not fixed yet for some of our users

we tried downgrading sdk last friday but not work, we did nothing today and it works maybe you need to complain in other ways: https://business.facebook.com/direct-support/ https://developers.facebook.com/support/bugs/

mpcht avatar Sep 19 '22 07:09 mpcht

Some account works, and some don't

renzified avatar Sep 19 '22 07:09 renzified

image https://metastatus.com/facebook-login

mpcht avatar Sep 19 '22 07:09 mpcht

image https://metastatus.com/facebook-login

Nice thanks for the info did not know facebook has page like that

renzified avatar Sep 21 '22 01:09 renzified

Any solution why fb login not working ?

ubrainrepo avatar Sep 23 '22 08:09 ubrainrepo

Any solution why fb login not working ?

The only thing we can do is to wait for facebook to fix the problem

renzified avatar Sep 23 '22 10:09 renzified

My problem is resolved. It's the problem of my facebook account, which was new registered. when I add some friends in facebook app, explore news and watch videos some while. Then switch to my app to login with facebook, and it works!

zfc580 avatar Oct 10 '22 06:10 zfc580

We are facing the same issue.

realxz avatar Nov 22 '22 09:11 realxz

This has been closed because it has been resolved please file a new issue if you are facing this issue

renzified avatar Nov 24 '22 01:11 renzified