我已多次阅读 Facebook“快速入门”指南,但似乎无法弄清楚是什么导致了此错误。我正在尝试使用以下函数调用通过 FB 进行身份验证:
FBSDKLoginManager().logIn(withReadPermissions: ["public_profile", "email"], from: self) { (result, error) in
}
但是,我收到以下错误控制台输出:
-canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
这是我的 AppDelegate 方法:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance()!.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
return FBSDKApplicationDelegate.sharedInstance()!.application(app, open: url, options: options)
}
按照快速入门指南的说明,我已将以下键/值添加到我的 Info.plist
中:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb719997618357318</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>719997618357318</string>
<key>FacebookDisplayName</key>
<string>Test</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
最佳答案
@开尔文路亚
需要在AppDelegate中实现该方法
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool{
return FBSDKApplicationDelegate.sharedInstance().application (
application,
open: url as URL!,
sourceApplication: sourceApplication,
annotation: annotation)
}
当用户从应用程序登录时将调用此方法。只需尝试一下,让我知道它是否有效,否则我们会尽力帮助您解决其他问题。
关于ios - Facebook 登录设置失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53928981/