oxylian / capacitor-facebook-login

Facebook Login plugin for Capacitor
Apache License 2.0
4 stars 25 forks source link

Troubles with native login #2

Closed leshik closed 6 years ago

leshik commented 6 years ago

Hi,

I'm unable to login through native FB app on iOS, but the login works just fine with web popup. I tried to enable keychain sharing capability as cordova-plugin-facebook4 FAQ suggests, but it didn't help. Their plugin doesn't work either.

What might be the reason?

sebdej commented 6 years ago

Hello,

Did you configure AppDelegate.swift as explained?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    return SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
}
leshik commented 6 years ago

Sure I did. Should I use other callback(s) maybe?

leshik commented 6 years ago

@sebdej I was able to make it work by adding the following code:

  func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

    // The code that I added:
    if let scheme = url.scheme, let host = url.host {
      if scheme == "fb\(SDKSettings.appId)" && host == "authorize" {
        return SDKApplicationDelegate.shared.application(app, open: url, options: options)
      }
    }
    // end of the code snippet

    return CAPBridge.handleOpenUrl(url, options)
  }
leshik commented 6 years ago

@sebdej now I have similar problem on Android – web popup works just fine, but nothing happens when native FB app is installed, it doesn't even try to open it. What might be the reason?

leshik commented 6 years ago

Here is what I see in debug log:

V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 42060668, pluginId: FacebookLogin, methodName: login
V/Capacitor: callback: 42060668, pluginId: FacebookLogin, methodName: login, methodData: {"permissions":["email"]}
D/Capacitor/Plugin/FacebookLogin: Entering login()
V/FA: Recording user engagement, ms: 37908
V/FA: Connecting to remote service
D/Capacitor: App paused
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@9055880
V/FA: onActivityCreated
V/FA: Activity paused, time: 1060150
D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=37908, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-222832233282186919}]
V/FA: Connection attempt already in progress
D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=MainActivity, firebase_previous_id(_pi)=-222832233282186919, firebase_screen_class(_sc)=FacebookActivity, firebase_screen_id(_si)=-222832233282186918}]
V/FA: Connection attempt already in progress
    Connection attempt already in progress
V/FA: Activity resumed, time: 1060272
D/EGL_emulation: eglMakeCurrent: 0xf2044cc0: ver 3 0 (tinfo 0xec0953f0)
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 4
V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 901
V/FA: Activity paused, time: 1061172
D/Capacitor/Plugin/FacebookLogin: Entering handleOnActivityResult(64206, -1)
D/Capacitor/Plugin/FacebookLogin: LoginManager.onSuccess
D/Capacitor/Plugin/FacebookLogin: onActivityResult succeeded
D/Capacitor/Plugin/App: Firing change: true
V/Capacitor/Plugin/App: Notifying listeners for event appStateChange
D/Capacitor/Plugin/App: No listeners found for event appStateChange
D/Capacitor: App resumed
D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=FacebookActivity, firebase_previous_id(_pi)=-222832233282186918, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-222832233282186919}]
V/Capacitor/Plugin/Network: Notifying listeners for event networkStatusChange
D/Capacitor/Plugin/Network: No listeners found for event networkStatusChange
D/EGL_emulation: eglMakeCurrent: 0xf2044cc0: ver 3 0 (tinfo 0xec0953f0)
V/FA: Activity resumed, time: 1061252
V/FA: Inactivity, disconnecting from the service
sebdej commented 6 years ago

@sebdej I was able to make it work by adding the following code:

  func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

    // The code that I added:
    if let scheme = url.scheme, let host = url.host {
      if scheme == "fb\(SDKSettings.appId)" && host == "authorize" {
        return SDKApplicationDelegate.shared.application(app, open: url, options: options)
      }
    }
    // end of the code snippet

    return CAPBridge.handleOpenUrl(url, options)
  }

Yes, you're right, I have a similar handler, in my AppDelegate class, I will update the documentation.

leshik commented 6 years ago

Oh I'm sorry – it actually works! That was my mistake on Android.