swift 2 解析 facebookSDK ios9 [英] swift 2 parse facebookSDK ios9

查看:19
本文介绍了swift 2 解析 facebookSDK ios9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 Facebook 登录用户.在以前版本的 swift 1.2 中一切正常,但迁移后我似乎无法通过我的 FB 帐户登录我仍然收到错误消息:

I am trying to Log In a user via Facebook. In the previous version of swift 1.2 everything worked perfectly, but after migration I can't seem to log in via my FB account I am still getting the error saying:

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

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

你能帮我解决这个问题吗?

Can you please help me with that?

推荐答案

我建议按照 Facebook 的说明为 iOS 9 准备一个应用程序:https://developers.facebook.com/docs/ios/ios9

I suggest following the instructions from Facebook to prepare an app for iOS 9: https://developers.facebook.com/docs/ios/ios9

  1. 下载适用于 iOS 的最新 Facebook SDK

为您的应用下载适当版本的 Facebook SDK.

Download the appropriate version of the Facebook SDK for your app.

v4.x - 推荐.v3.24.0 - 仅当您尚未迁移到 SDK 的 v4.x 时.2. 为网络请求将 Facebook 服务器列入白名单

v4.x - Recommended. v3.24.0 - Only if you have not migrated to v4.x of the SDK yet. 2. Whitelist Facebook Servers for Network Requests

如果您使用 iOS SDK 9.0 编译您的应用,您将受到应用传输安全的影响.目前,您需要将以下内容添加到应用程序的 plist 中,将应用程序中的 Facebook 域列入白名单:

If you compile your app with iOS SDK 9.0, you will be affected by App Transport Security. Currently, you will need to whitelist Facebook domains in your app by adding the following to your application's plist:

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

否则你会遇到如下错误:

or you will encounter errors like:

NSUnderlyingError=0x7f88f9436eb0 {Error Domain=kCFErrorDomainCFNetwork
Code=-1200 "An SSL error has occurred and a secure connection to
the server cannot be made." UserInfo={NSErrorFailingURLStringKey=
https://graph.facebook.com/v2.4, NSLocalizedRecoverySuggestion=
Would you like to connect to the server anyway?,
_kCFNetworkCFStreamSSLErrorOriginalValue=-9802,
kCFStreamPropertySSLPeerCertificates=<CFArray 0x7f88f9536e00
[0x10719f7c0]>{type = immutable, count = 2, values = (
0 : <cert(0x7f88f963f840) s: *.facebook.com (http://facebook.com/)
i: DigiCert High Assurance CA-3>
1 : <cert(0x7f88f96444c0) s: DigiCert High Assurance CA-3 i:
DigiCert High Assurance EV Root CA> )}, 
_kCFStreamPropertySSLClientCertificateState=0,
kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x7f88f9644d10>,
NSLocalizedDescription=An SSL error has occurred and a secure connection
to the server cannot be made.,_kCFStreamErrorDomainKey=3,
NSErrorFailingURLKey=https://graph.facebook.com/v2.4,
_kCFStreamErrorCodeKey=-9802}}

  1. 将 Facebook 应用列入白名单

如果您使用任何可以将应用程序切换到 Facebook 应用程序的 Facebook 对话框(例如,登录、共享、应用程序邀请等),您将需要更新应用程序的 plist 以处理对 canOpenURL 中描述的更改https://developer.apple.com/videos/wwdc/2015/?id=703

If you use any of the Facebook dialogs (e.g., Login, Share, App Invites, etc.) that can perform an app switch to Facebook apps, you will need to update your application's plist to handle the changes to canOpenURL described in https://developer.apple.com/videos/wwdc/2015/?id=703

如果您使用 iOS SDK 9.0 重新编译,如果您使用的是 SDK v4.5 或更早版本,请将以下内容添加到应用程序的 plist 中:

If you're recompiling with iOS SDK 9.0, add the following to your application's plist if you're using a version of the SDK v4.5 or older:

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

如果您使用的是早于 v4.6 版本的 FBSDKMessengerShareKit,还需要添加

If you're using FBSDKMessengerShareKit from versions older than the v4.6 release, also add

<string>fb-messenger-platform-20150128</string>
<string>fb-messenger-platform-20150218</string>
<string>fb-messenger-platform-20150305</string>

如果您使用的是v4.6.0的SDK,您只需要添加:

If you're using v4.6.0 of the SDK, you only need to add:

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

这将允许 FacebookSDK 集成正确识别已安装的 Facebook 应用程序以执行应用程序切换.如果您不使用 iOS SDK 9.0 重新编译,则您的应用程序仅限于 50 个不同的方案(之后调用 canOpenURL 返回 NO).

This will allow the FacebookSDK integration to properly identify installed Facebook apps to perform an app switch. If you are not recompiling with iOS SDK 9.0, your app is limited to 50 distinct schemes (calls to canOpenURL afterwards return NO).

这篇关于swift 2 解析 facebookSDK ios9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆