swift 2解析facebookSDK ios9

时间:2015-06-09 15:36:59

标签: parse-platform facebook-sdk-4.0 swift2

我正在尝试通过Facebook登录用户。在之前版本的swift 1.2中,一切都运行良好,但在迁移后我似乎无法通过我的FB帐户登录,我仍然收到错误说:

  

-canOpenURL:网址失败:" fbauth:// authorize /?client_id = ...错误:"此应用不允许查询方案fbauth"

你能帮帮我吗?

3 个答案:

答案 0 :(得分:31)

来自WWDC 2015"隐私和您的应用"视频,将以下内容添加到info.plist文件中:

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbauth</string>
    </array>

答案 1 :(得分:5)

点击此链接查看Facebook推荐的iOS 9更新 https://developers.facebook.com/docs/ios/ios9

为了解决此特定错误

-canOpenURL: failed for URL: "fbauth://authorize/?client_id=... error: "This app is not allowed to query for scheme fbauth"

对于Facebook SDK版本4.6+,请转到info.plist文件并添加以下内容:

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
    </array>

对于4.5或更早版本:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fbapi20130214</string>
    <string>fbapi20130410</string>
    <string>fbapi20130702</string>
    <string>fbapi20131010</string>
    <string>fbapi20131219</string>    
    <string>fbapi20140410</string>
    <string>fbapi20140116</string>
    <string>fbapi20150313</string>
    <string>fbapi20150629</string>
    <string>fbauth</string>
    <string>fbauth2</string>
    <string>fb-messenger-api20140430</string>
</array>

答案 2 :(得分:0)

1]在Developer.facebook中进行身份验证并生成Facebook Id

2]设置Bitcode:No From Build Settings

3]设置Plist文件

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb460481580805052</string>
        </array>
    </dict>
</array>

<key>FacebookAppID</key>
<string>460481580805052</string>

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

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fbapi20130214</string>
    <string>fbapi20130410</string>
    <string>fbapi20130702</string>
    <string>fbapi20131010</string>
    <string>fbapi20131219</string>
    <string>fbapi20140410</string>
    <string>fbapi20140116</string>
    <string>fbapi20150313</string>
    <string>fbapi20150629</string>
    <string>fbauth</string>
    <string>fbauth2 </string>
    <string>fb-messenger-api20140430</string>
    <string>fb-messenger-platform-20150128</string>
    <string>fb-messenger-platform-20150218</string>
    <string>fb-messenger-platform-20150305</string>
</array>

4]下载4个Sdk框架,如

=>Bolts.framework
=>FBSDKCoreKit.framework
=>FBSDKLoginKit.framework
=>FBSDKShareKit.framework