Ragul Ragul - 2 months ago 69
Swift Question

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

Hi Am using iOS 10 Swift3 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

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)
}
}