facebook / facebook-android-sdk

Used to integrate Android apps with Facebook Platform.
https://developers.facebook.com/docs/android
Other
6.17k stars 3.66k forks source link

Facebook App open twice when trying to log in (App & Chrome) #1214

Open axitasavani opened 1 year ago

axitasavani commented 1 year ago

Checklist before submitting a bug report

Java version

11

Android version

33

Android SDK version

16.0.1

Installation platform & version

Gradle

Package

Login

Goals

Here. I have attached the code for Login. When I have logged in twice, I open the Facebook Chrome Custom Tab if the Facebook App is not installed. And I Facebook App is Installed then also Open twice time Authorization page twice from the Facebook Page.

Expected results

  1. Not Open Twice Time Facebook Login.
  2. Callback only One time if Failed , Success or Cancel

Actual results

  1. Open Login Twice time
  2. Multiple times callback getting in CallBackManager.

Steps to reproduce

If Facebook app Installed

  1. Implement Code
  2. Click on Login Button from App
  3. Open Twice time Facebook App

If Facebook App Not installed

  1. Implement Code
  2. Click on Login Button from App
  3. Open Twice time Facebook Custom Chrome Tab

Code samples & details

`public void startFaceBookLogin(Activity activity) {

            LoginManager.getInstance().setLoginBehavior(LoginBehavior.NATIVE_WITH_FALLBACK);

            LoginManager.getInstance().logInWithReadPermissions((ActivityResultRegistryOwner) activity, getCallbackManagerInstance(),
                    Arrays.asList(ObSocialLoginConstants.FB_EMAIL,
                            ObSocialLoginConstants.FB_PUBLIC_PROFILE,
                            ObSocialLoginConstants.FB_PAGES_MANAGE_POSTS));

            LoginManager.getInstance().logInWithPublishPermissions((ActivityResultRegistryOwner) activity, getCallbackManagerInstance(),
                    Collections.singletonList(ObSocialLoginConstants.FB_PUBLISH_TO_GROUPS));

            LoginManager.getInstance().registerCallback(getCallbackManagerInstance(),
                    new FacebookCallback<LoginResult>() {
                        @Override
                        public void onSuccess(LoginResult loginResult) {

                        }
                        @Override
                        public void onCancel() {
                            ObLogger.i(TAG, "onCancel:  --> ");

                        }

                        @Override
                        public void onError(@NonNull FacebookException e) {

                        }
                    });
        } `