capacitor-community / facebook-login

Facebook Login support
MIT License
103 stars 52 forks source link

login: overlapped calls not supported #88

Open xenonestudio opened 2 years ago

xenonestudio commented 2 years ago

I present a quite unusual problem, the plugin works well, it makes the call to the facebook activity for the login and everything is fine until the moment that it is authorized when logging in, since nothing else happens, it does not return any data, nor any error

when re-accessing the loginFacebook function in Ionic it throws the following error in the debug console of android studio

D/Capacitor/FacebookLogin: Entering login() E/Capacitor/FacebookLogin: login: overlapped calls not supported D/Capacitor: Sending plugin error: {"save":false,"callbackId":"54234492","pluginId":"FacebookLogin","methodName":"login","success":false,"error":{"message":"Overlapped calls call not supported"}}

I really don't understand what the problem is because I have the native login with google and it works fine

` async loginFacebook(): Promise{

try{
const result = await  FacebookLogin.login({ permissions: ['email', 'public_profile'] });
console.log(result);

  if (result.accessToken) {
    // Login successful.
    console.log(`Facebook access token is ${result.accessToken.token}`);

  }else{
    console.log(`I don't know logged in`);
  }

}catch(err){

  console.log(err);

}

}`

adelabd commented 2 years ago

Same problem. Is there any solutions ?

xenonestudio commented 2 years ago

In my case I found the problem and it depends a lot on the project and the use of a dependency.

I found a conflict although I still don't know the exact origin but when "D/Capacitor/FacebookLogin" is executed it does so at the same time as "capacitor-firebase-auth" and the function in the native android layer: "handleOnActivityResult" is executed by means of plugin and which expects a response from Capacitor/FacebookLogin but gets the one from capacitor-firebase-auth which is null and the promise from Capacitor/FacebookLogin is waiting

in my case I was using capacitor-firebase-auth": "^3.0.0 which was the dependency that caused this error

by removing "capacitor-firebase-auth": "^3.0.0" from package.json or uninstalling via console using

$ npm uninstall --save capacitor-firebase-auth

execute the command $ npm Intall

and then the command $ npx cap sync

and finally syncronize the gradle in android studio so that it takes the changes in the dependency and capacitor plugins to execute

and the result at the android studio console level would be:

D/Capacitor/FacebookLogin: Entering handleOnActivityResult(64206, -1) D/Capacitor/FacebookLogin: LoginManager.onSuccess D/Capacitor/FacebookLogin: onActivityResult succeeded D/Capacitor/AppPlugin: Firing change: true D/Capacitor/AppPlugin: No listeners found for event appStateChange D/Capacitor: App resumed D/Choreographer: updateAppVisible:true

I don't know if there is any problem with another dependency either from firebase or from some other.

optional

You can also advise them to use the gradle dependency facebook-android-sdk: 5.6' since the dependency found in the facebook documentation in some cases has a problem with some color XML files just add

inside build.gradle(:app) file in dependencies the implementation of implementation 'com.facebook.android:facebook-android-sdk:[5,6)'

and in build.gradle(:android) add inside repositories mavenCentral()

and this really saved me from any issues in the SDK and worked fine for me.

This facebook XML files not found error is here if you want to see more: https://stackoverflow.com/questions/57543127/android-gradle-fail-aapt-error-resource-color-com-facebook-button-background

even if I get to see at the native dependency level of capacitor-community facebook-login" that for the most recent capacitor updates, some functions need to be optimized. In addition, "call.setKeepAlive(true);" could be used to wait for several responses, although it has not been verified at the memory level how much resources it may require.