PFFacebookUtils Parse login callback not called with safari

38 views Asked by At

I'm using the latest version of the ParseFacebookUtils which uses safari to log a user in. The process works as expected where it asks for your permission to your public profile in Safari and returns to the app. The weird behavior is that when the login request returns to the app the code inside of the block is never executed.

It is only executed if I press the login button again or if I set the login behavior to be web-based where a webview is presented within the app. But this isn't the best since the user has to login and they may have forgotten their details. Below is the code which I'm using to log the user in.

   PFFacebookUtils.logIn(withPermissions: ["public_profile"]) { user, error in

            if let user = user {
                if user.isNew {
                    print("User signed up and logged in through Facebook!")
                } else {
                    print("User logged in through Facebook!")
                }
            } else {
                print("Uh oh. The user cancelled the Facebook login.")
            }
        }

Here is the code in my app delegate which I'm using to initialize and handle the url.

import UIKit
import Parse
import ParseFacebookUtils

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        Parse.initialize(with: ParseConfig.configuration)
        PFFacebookUtils.initializeFacebook()

        // Configure an anon user on startup
        PFUser.enableAutomaticUser()
        PFUser.current()?.saveInBackground()


        return true
    }

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

        return FBAppCall.handleOpen(url, sourceApplication: UIApplicationOpenURLOptionsKey.sourceApplication.rawValue)
    }
}
0

There are 0 answers