10

我已将 Parse Framework 与所有 Facebook 依赖项集成到我的应用程序中。我的 plist 配置如下所示:

<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>

我的登录代码如下所示:

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")
                }

            }
        })

一切正常,但是登录过程是在 Safari 中完成的,而不是在已安装的 Facebook 应用程序中。

我错过了什么?

4

1 回答 1

5

由于 iOS 9 Facebook SDK 不再通过 Facebook 应用提供授权。原因是在应用程序可以打开其他应用程序之前会提示用户,这会影响用户体验。

您唯一的选择是使用FBSDKLoginBehaviorSystemAccountFBSDKLoginBehaviorBrowser

PFFacebookUtils.facebookLoginManager().loginBehavior = FBSDKLoginBehavior.SystemAccount
于 2015-11-22T13:13:12.220 回答