PFFacebookUtils.logInInBackgroundWithReadPermissions block returns user = nil and error = nil

218 views Asked by At

I have an iOS 9 app (Xcode 7.1, Swift 2.0) with the following pods, using the latest versions at the time of this post:

pod 'Parse'                 (using latest version 1.12.0)
pod 'ParseFacebookUtilsV4'  (using latest version 1.11.0)

I am attempting to run the following code:

let permissions = ["public_profile", "email"]
PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions) {
    (user, error) in
    // Both user and error are nil here
}

But I always get a nil user and a nil error. The login worked a couple months ago, but all of a sudden (I believe after a pod update), the login stopped working.

I have added all the proper plist entries as described on the Facebook developers site, and I have added all the appropriate functions in the app delegate:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)

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

    return true
}

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
    let sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String
    return FBSDKApplicationDelegate.sharedInstance().application(app, openURL: url, sourceApplication: sourceApplication, annotation: nil)
}

func applicationDidBecomeActive(application: UIApplication) {
    FBSDKAppEvents.activateApp()
}
1

There are 1 answers

0
macondt On

in AppDelegate, under didFinishLaunchingWithOptions initialize Parse before initializing PFFacebookUtils. I was making the same mistake