facebook / facebook-android-sdk

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

Facebook Login opening Webview instead of Native App #1175

Open ibrahim-musa opened 1 year ago

ibrahim-musa commented 1 year ago

Checklist before submitting a bug report

Java version

1.8

Android version

API 31

Android SDK version

15.0.0

Installation platform & version

Gradle

Package

Login

Goals

I want to use a Facebook Login function in my app with these permissions:

"ads_management", "pages_manage_ads", "leads_retrieval", "pages_manage_metadata", "pages_read_engagement"

The issue is even when user had installed native Facebook app in their devices and already logged in, when calling Facebook login function it sometime open a webview instead of native Facebook app. This happen not every time but only some time such as when user switch their Facebook profile to a Page Profile instead of a User Profile (see steps below for reproduce the issue). But the issue will usually remain even after user switching back to user profile instead of a page profile.

Expected results

It should open a Facebook native app if device had already install Facebook native app and even if device don't have it, it should at least open a chrome custom tab Facebook web and not webview since webview is no longer supported and causing the user not able to log in at all.

Actual results

It open a Facebook webview instead of Facebook native app although the I've set the login behaviour to NATIVE_WITH_FALLBACK, NATIVE_ONLY, or KATANA_ONLY.

But I notice it works when I set the login behaviour to WEB_ONLY, it correctly open a chrome custom tab in my app and not a webview. But what I need is login using native app not web app.

Steps to reproduce

Devices used to test:

Screenshot_20230403_193136_Chrome Screenshot_20230403_193301_Facebook Screenshot_20230403_193412_Facebook

Code samples & details

public void logInWithPermissions(final Promise promise) {
    List<String> permissions = Arrays.asList("ads_management", "pages_manage_ads", "leads_retrieval", "pages_manage_metadata", "pages_read_engagement");
    final LoginManager loginManager = LoginManager.getInstance();
    loginManager.registerCallback(getCallbackManager(), new LoginManagerCallback(promise));
    loginManager.setLoginBehavior(LoginBehavior.NATIVE_ONLY);
    Activity activity = getCurrentActivity();
    if (activity != null) {
        loginManager.logIn(activity, permissions);
    }
}
manuelcoders commented 1 year ago

Same issue. News?