FB Login using Swift 3 not returning any values and not get back the user to the App after successful login

Ragul picture Ragul · Sep 22, 2016 · Viewed 12.4k times · Source

I'm using iOS 10 Swift 3 to integrate FB Login. I have followed all steps from Facebook documentation. Now the issue is, after successful login it doesn't returning any values and not get back the user to the app.

Note: The same works perfectly in Swift 2.

Answer

Ragul picture Ragul · Sep 23, 2016

Hi I raised this issue to facebook developer support and the issue is that I have not implemented the correct delegate methods for iOS10. and you can find the correct delegate implementation here

import UIKit
import CoreData

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


public func application(_ application: UIApplication,  didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
// Override point for customization after application launch.

return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}

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

return FBSDKApplicationDelegate.sharedInstance().application(
  app,
  open: url as URL!,
  sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String,
  annotation: options[UIApplicationOpenURLOptionsKey.annotation]
)
}

public func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
  application,
  open: url as URL!,
  sourceApplication: sourceApplication,
  annotation: annotation)
}
}