Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubles with native login #2

Closed
leshik opened this issue Nov 13, 2018 · 7 comments
Closed

Troubles with native login #2

leshik opened this issue Nov 13, 2018 · 7 comments

Comments

@leshik
Copy link

leshik commented Nov 13, 2018

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
Copy link
Contributor

sebdej commented Nov 13, 2018

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
Copy link
Author

leshik commented Nov 14, 2018

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

@leshik
Copy link
Author

leshik commented Nov 14, 2018

@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
Copy link
Author

leshik commented Nov 14, 2018

@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 leshik changed the title Troubles with native login on iOS Troubles with native login Nov 14, 2018
@leshik
Copy link
Author

leshik commented Nov 14, 2018

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
Copy link
Contributor

sebdej commented Nov 14, 2018

@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
Copy link
Author

leshik commented Nov 14, 2018

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

@leshik leshik closed this as completed Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants