Skip to content

Instantly share code, notes, and snippets.

@codegefluester
Created September 22, 2016 15:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save codegefluester/f797dd723e93e545b855525a4b9ab057 to your computer and use it in GitHub Desktop.
Save codegefluester/f797dd723e93e545b855525a4b9ab057 to your computer and use it in GitHub Desktop.
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)
}
}
@jliu716
Copy link

jliu716 commented Sep 30, 2016

YOU SAVED MY LIFE!!!!!!!!!

@anand-y
Copy link

anand-y commented Oct 4, 2016

Thanks for you solution!!!!

@thisfiore
Copy link

Good job!

@thisfiore
Copy link

Also guys having this issues look at:

Error OSStatus -10814 occures when canOpenURL: can't find any application, that can open this URL (actually, Facebook trying to find their application by calling canOpenURL: with argument "fbauth2:/"). Printing happens inside of function, so you can't do anything with that. But if you will run your application on device with installed Facebook app, you will not see this error.

Error 308 occures because of the situation, when value, stored in keychain is not equal to value, that is stored in facebook completion parameters (for more information you can check -[FBSDKLoginManager completeAuthentication:expectChallenge:]).

It happens because Apple changed the way of working with keychain in iOS 10. To fix this issue you simply should go to Targets->Capabilities and enable keychain sharing (it enables access to keychain for your app):

Full answer here http://stackoverflow.com/questions/38689631/how-to-use-facebook-ios-sdk-on-ios-10
by Roman Ermolov

@srabeeh
Copy link

srabeeh commented Oct 10, 2016

I converted the Objective-C here https://developers.facebook.com/docs/ios/getting-started/ but @thisfiore saved me on the Error 308! Thanks buddy.

@nielst
Copy link

nielst commented Oct 11, 2016

GREAT! Thank you

@nahaponia
Copy link

Long live bra

@delhiveryakshay
Copy link

Thanks buddy . you are life saver

@nevinjethmalani
Copy link

I am using this with version 4.17 of the FB SDK and getting nil for the token. Any idea on why that might be. If i use this with an older version of the FB SDK (4.15.1), it works perfectly.

@exocode
Copy link

exocode commented Jun 2, 2017

@chmziaurrehman
Copy link

Good job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment