我正在尝试在我的应用程序中实现 facebook 登录。但是得到一个错误。 我的 info.plist 代码是:
<plist version="1.0">
<dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<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>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb_APP_ID</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>APP_ID</string>
<key>FacebookDisplayName</key>
<string>APP_Name</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
我收到这个错误:
2015-10-24 11:38:11.177 APP_Name[3553:150778] -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
2015-10-24 11:38:11.190 APP_Name[3553:150778] -canOpenURL: failed for URL: "fbauth2:/" - error: "(null)"
Facebook 登录正在发生,但也出现此错误。有什么办法可以解决这个问题?我在谷歌上搜索了很多,但无法修复它。我同时使用 Parse 和 facebook。感谢您的宝贵时间。
最佳答案
我得出了同样的结论,但在通往此错误消息的路径上还有其他问题,这可能对其他人有帮助 - 所以在这里分享。
我将 Parse v1.9.0 与 FBSDK v4.7 和 Xcode 7.0.1 一起使用。我在 udemy.com 上关注 Rob Percivals iOS9 & Swift 2 类(class). (第 131 讲)。
他使用了早期版本的 sdks - 他的压缩代码有效,但我遇到了 fbauth2 错误。当我尝试使用最新的 sdk 时,我什至无法解决错误。
Parse v1.9.0 下载缺少一个文件:ParseStarterProject-Bridging-Header.h - 没有它,所有导入语句都不起作用。
Parse AppDelegate 告诉您按照 Facebook 的说明在 FB 网站上设置所有内容并填充您的 info.plist 文件,然后取消注释缺少的标题中的一行文件。
我从头开始创建了一个 ParseStarterProject-Bridging-Header.h 并将导入语句放入 PFFFacebookUtilsV4/PFFFacebookUtils.h & FBSDKCoreKit/FBSDKCoreKit.h .
另请注意,当您解压 Parse v1.9.0 启动项目时,它并不包含所有框架,因此请确保解压 Parse Library zip 和然后拖到你的项目中。 Facebook 也是如此。
在这一点上,我认为一切都会奏效 - 但事实并非如此。仍然有很多红色错误信息。当我查看“问题导航器”时,它找不到FBSDK、ParseFacebookUtilsV4 或我创建的头文件。它们都在导航 Pane 中,所以我完全糊涂了。
关键/解决方案在目标build设置中。
在搜索路径下: 始终搜索用户路径 - 我将其设置为YES - 默认为NO。
框架搜索路径 - 您应该有一个指向您的项目的指针,但需要将一个指针添加到您的 FBSDK 位置。如果您遵循建议,它应该是 /Users//Documents/FacebookSDK。
Swift 编译器 - 代码生成:
Install Objective-C Compatibility Header = YES
Objective-C Bridging Header = ParseStarterProject/ParseStarterProject-Bridging-Header.h
我花了一些时间来获得正确的语法 - 如果您使用 ParseStarterProject 并将头文件放在与您的 AppDelegate 和 ViewController 相同的组中 - 以上应该适合你。
parse 为取消注释提供的默认 PFFacebookUtils.initializeFacebook() 行对我不起作用 - 一直显示错误,所以我用 Facebook 提供的测试代码的变体替换。工作得很好 - 仍然出现 fbauth2 错误,但现在进入了 fb 登录屏幕并已连接。那时我发现 fbauth2 错误消息没有负面影响 - 你可以忽略它们:)
如果您一直在为 Parse 和 FB 集成而苦苦挣扎 - 希望这对您有所帮助!
关于ios - Facebook登录错误,IOS 9,Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33315083/