9

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?

Shlomi Schwartz
  • 8,693
  • 29
  • 109
  • 186

1 Answers1

5

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
Armands L.
  • 1,885
  • 2
  • 14
  • 18
  • Thanks for the reply, however I can see other apps using this method successfully (like AirBnB). I've tried adding `(PFFacebookUtils.facebookLoginManager()).loginBehavior = FBSDKLoginBehavior.SystemAccount` with no luck. any other idea? – Shlomi Schwartz Nov 22 '15 at 13:26
  • You can always use older version of SDK to get back the `FBSDKLoginBehavior.Native`, but it's not recommended. In order for `FBSDKLoginBehavior.SystemAccount` to work, FB needs to be set up in iOS settings, otherwise it will fall back to browser. – Armands L. Nov 22 '15 at 13:31
  • Can you please elaborate on what settings, needs to be configured? the only thing I've set in the IOS platform is the Bundle ID. P.S - the .Native have the same effect – Shlomi Schwartz Nov 22 '15 at 13:35
  • To configure `Info.plist` see FB documentation [here](https://developers.facebook.com/docs/ios/getting-started). Bundle ID and Single Sign On enabled is all you need – Armands L. Nov 22 '15 at 13:45