jeduan / cordova-plugin-facebook4

Use the latest Facebook SDK in your Cordova and Ionic projects
Other
764 stars 509 forks source link

Failed login in devices with android 9.0 #855

Closed feliperivero99 closed 3 years ago

feliperivero99 commented 4 years ago

Bug or feature request

[ X] I'm reporting a reproducible issue with the code [ ] I'm reporting a feature request

Describe the Bug of feature request

I am developing and app with Ionic 4, one the requirements is the users can log in with facebook. I installed the plugin cordova-plugin-facebook4, and worked good in devices with android 5,6,7 and 8.

But is failing completely in devices with android 9.0,

For what I researched, must be something related to the issue is related to the way how the plugin uses the web browser tab within the app. Or endpoint that use "http" instead of "https"

This is how the facebook login box look in a device with android 7.1 image

And this is how is look in a device with android 9.0

image

Always give me this error: “There is an error in logging you into this application. Please try again later”

Expected Behavior

I just want the users can log in with the facebook acounts in devices with android 9.0 in the same way the plugin do it with devices with lower android versions

Sample repo

Here is the code of the login function


    fbLogin() {
  this.fb.login(['public_profile', 'user_friends', 'email'])
    .then(res => {
      if (res.status === 'connected') {
        this.isLoggedIn = true;
        this.getUserDetail(res.authResponse.userID);
        this.router.navigateByUrl("/tutorial");
      } else {
        this.isLoggedIn = false;
      }
    })
    .catch(e => console.log('Error logging into Facebook', e));
}

Plugin version, OS, devices, etc

My specifications:

image

The plugin version:

image

And I tested with several android systems, the lowest is the version 5 and the highest the version 9

Additional Context

Several solutions I found in stackoverflow

Solution 1

Solution 2

I tried what is said on those answer but didnt work.

Any solution?

peterpeterparker commented 4 years ago

Could you try to reproduce the error with the sample repo?

feliperivero99 commented 4 years ago

I tried using the sample repo, I build a debug apk version and tested it, this is the result:

image

I created a realease version of my app, build it in android studio. and still is giving me the same error, of yesterday:

image

peterpeterparker commented 4 years ago

The above msg for the sample repo is absolutely correct. It relies on a test FB app.

I tested on my phone, Android v10, everything went fine.

Nothing we can do on the plugin side.

We can keep the issue open a bit, in case someone comes with a solution, but it ain't a bug of the plugin itself I'm afraid.

Screenshot_20200309-195727 Screenshot_20200309-195738

feliperivero99 commented 4 years ago

Thank you for you answer. I continued doing my searching and testing to found out what is the problem behind.

I found this, the facebook login works fine when the facebook app is not installed in the android device.

Here is my experiment:

The lfacebook login box without having the facebook app installed.

image

Then I installed the facebook app,

the app is launched when I call the facebook login function:

image

I logged in with the app and gave me the error:

image

There is an error in logging you into this application. Please try again later

Searching in the web I found this:

https://github.com/facebook/react-native-fbsdk/issues/633

Is a similar problem, I am having with the app. Their "workaround" was to do this:

if (Platform.OS === "android") {
            LoginManager.setLoginBehavior("web_only")
  }

Forcing the login to ignore the app and call the web login version, The plugin has somethin similar?

How can i force to call the normal login box and no the facebok app??

thank you.

peterpeterparker commented 4 years ago

@feliperivero99 thank you for the further analysis. To be honest with you, spontaneously, it gives me the feeling that there isn't much we can do in the plugin itself, sounds like a Facebook SDK issue to me. Therefore, what you could try is using another version of their SDK and check it the problem was or is or will be solved.

feliperivero99 commented 4 years ago

I see. I don't know if what I did was correct, I don't know if what I did was correct, but I wanted to put on record.

I check the plugin files. I studied one file in particular: ConnectPlugin.java

From what I see in others forums, I did the following

I added this library import com.facebook.login.LoginBehavior;

And any line where the following command was:

LoginManager.getInstance().logInWithReadPermissions(cordova.getActivity(), permissions);

In the line before I added this:

  // Create the request
            LoginManager.getInstance().setLoginBehavior(LoginBehavior.WEB_ONLY);
            LoginManager.getInstance().logInWithReadPermissions(cordova.getActivity(), permissions);

And worked perfectly. Now I can login in when the facebook added is installed.

I know this is a workaround.

Greettings.

danielehrhardt commented 4 years ago

Same Issue here. With the fix from @feliperivero99 the User need to enter the credentials every time. Bad UX :/

hnguyen48206 commented 4 years ago

Sadly, event after applying the fix from @feliperivero99 the problem still persists :(( any suggestion would be much appreciated.

vildhjarta8 commented 4 years ago

+1, faced same issue

Ionic + Capacitor + cordova-plugin-facebook4

boris1690 commented 4 years ago

Same error.

kwiiby commented 4 years ago

The problem isn't with the Plugin. Your Facebook App should have Hashes setted. You can generate the keys like this: https://stackoverflow.com/a/47183720

boris1690 commented 4 years ago

The problem isn't with the Plugin. Your Facebook App should have Hashes setted. You can generate the keys like this: https://stackoverflow.com/a/47183720

it´s correct, I generated the keys and attach in facebook developer and work.

The error was shown on Huawei.

noahcooper commented 3 years ago

This plugin is deprecated. Check out the actively maintained fork cordova-plugin-facebook-connect at https://www.npmjs.com/package/cordova-plugin-facebook-connect. I cannot reproduce any issues with that plugin and Android 9 (or above), but feel free to log a new issue if you're still running into problems.