-canOpenURL: Failed for URL: “fbauth://authorize/?client_id=… error: “This app is not allowed to query for scheme fbauth”
你能帮助我吗?
https://developers.facebook.com/docs/ios/ios9
>下载最新的iOS版Facebook SDK
为您的应用程序下载适当版本的Facebook SDK。
v4.x – 推荐。
v3.24.0 – 仅当尚未迁移到SDK的v4.x时。
2.将Facebook服务器列入网络请求白名单
如果您使用iOS SDK 9.0编译应用程序,则会受到App Transport Security的影响。目前,您需要将以下内容添加到应用程序的plist中,才能在应用中将Facebook域列入白名单:
<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>
或者您将遇到错误,如:
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}}
>白名单Facebook应用程序
如果您使用任何可以执行应用程序切换到Facebook应用程序的Facebook对话框(例如,登录,共享,应用程序邀请等),您需要更新应用程序的plist以处理https://developer.apple.com/videos/wwdc/2015/?id=703中描述的canOpenURL的更改
如果您正在使用iOS SDK 9.0重新编译,请将以下内容添加到您的应用程序的plist中(如果您使用的是SDK v4.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>
如果你使用FBSDKMessengerShareKit从早于v4.6版本,也添加
<string>fb-messenger-platform-20150128</string> <string>fb-messenger-platform-20150218</string> <string>fb-messenger-platform-20150305</string>
如果您使用的是v4.6.0的SDK,您只需要添加:
<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)。