IOS 9 Swift - Parse Facebook login does not open native Facebook App

2.3k Views Asked by At

I've integrated Parse Framework with all Facebook dependencies to my App. My plist configuration looks like this:

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fbXXXXXXXXXXXXX</string>
            </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>XXXXXXXXXXXXX</string>
    <key>FacebookDisplayName</key>
    <string>XXXXX</string>

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>facebook.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            <key>fbcdn.net</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            <key>akamaihd.net</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
        </dict>
    </dict>

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbauth2</string>
    </array>

My Login code looks like so:

PFFacebookUtils.logInInBackgroundWithReadPermissions(permissionsArray, block: { (user, error) -> Void in
            if(error != nil){
                print("Login failed")
            }else{
                if let currentUser = user{
                    if(currentUser.isNew){
                        print("New user")
                    }else{
                        print("Login success")
                    }
                }else{
                    print("Login canceled")
                }

            }
        })

All works well, however the login process is being done in Safari and not in the installed Facebook App.

What am I missing?

1

There are 1 best solutions below

4
Armands L. On

Since iOS 9 Facebook SDK no longer offers authorisation via Facebook App. The reason is that users will be prompted before app can open other app and this affects UX.

Your only option is to use FBSDKLoginBehaviorSystemAccount or FBSDKLoginBehaviorBrowser

PFFacebookUtils.facebookLoginManager().loginBehavior = FBSDKLoginBehavior.SystemAccount