Facebook login always comes back as cancelled. (iOS Swift)

Earl Ferguson picture Earl Ferguson · Mar 28, 2015 · Viewed 14.2k times · Source

I'm currently trying implement Facebook login using the 4.0 version of the SDK, this also happens with the 3.+ version. When I call logInWithReadPermissions (4.0 version) or openActiveSessionWithReadPermissions (3.+ version). The closure/block is called immediately with isCancelled (4.0 version) and ClosedFailedLogin (3.+ version) before the user can make a selection (cancel or ok). I thought it may be a problem with the URL Scheme in my plist settings but I've checked it over and over and everything seems to be right. Just wondering if anyone may have any ideas on solving this problem. My Bundle ID is right, single signin is on, native app is enabled, in the Facebook dev console. See some sample code and configurations below (4.0 version).

Login Call: Login Call

AppDelegate: AppDelegate

Plist: Plist

Answer

Philipp Otto picture Philipp Otto · Jan 10, 2017

With Facebook SDK version 4 I only had to add this to my application delegate on iOS 10 & Swift 3 to make the authentication work. Before that I also only had cancelled logins.

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
    return SDKApplicationDelegate.shared.application(app, open: url, options: options)
}