iOS 9 Facebook 登录模拟器 -canOpenURL:URL 失败:“fbauth2:///” - 错误:“(空)”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32676334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS 9 Facebook login simulator -canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"
提问by Can Poyrazo?lu
I've updated to Xcode 7 and the latest iOS SDK. I've added the appropriate entries in my app's plist:
我已经更新到 Xcode 7 和最新的 iOS SDK。我在我的应用程序的 plist 中添加了适当的条目:
My app's Facebook login works fine on device. However, on iOS 9 simulator, I'm getting:
我的应用程序的 Facebook 登录在设备上运行良好。但是,在 iOS 9 模拟器上,我得到:
-canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"
-canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"
And login is not working. I've seen facebook login issue - canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"but I have FBSDKCoreKit framework. I've also seen Facebook SDK 4.5 IOS 9but it's answer doesn't solve my problem.
并且登录不起作用。我见过facebook 登录问题 - canOpenURL: failed for URL: "fbauth2:///" - error: "(null)"但我有 FBSDKCoreKit 框架。我也看过Facebook SDK 4.5 IOS 9但它的答案并不能解决我的问题。
Why am I getting this error on simulator and not on device even though I've done the checklist at https://developers.facebook.com/docs/ios/ios9?
即使我已经在https://developers.facebook.com/docs/ios/ios9完成了清单,为什么我在模拟器上而不是在设备上收到此错误?
采纳答案by SoftDesigner
Why do I see console messages like 'canOpenURL: failed for URL: "fb...://' or ?
为什么我会看到类似 'canOpenURL: failed for URL: "fb...://' 或 ?
This is an Xcode warning indicating the the canOpenURL: call returned false. As long as you have configured the
LSApplicationQueriesSchemes
entry in your plist as described above, you can ignore this warning.
这是一个 Xcode 警告,指示 canOpenURL: 调用返回 false。只要
LSApplicationQueriesSchemes
您按照上述方式在 plist 中配置了条目,就可以忽略此警告。
回答by Pradeep K
This is not a problem. The FB SDK is trying to open the native facebook app which has the fbauth2:// url type. In Simulator its not available, so its just putting a log that it could not open the native Facebook app. You can configure the Facebook acct in Simulator and then tell the FB Login button to use the native Facebook account instead of opening the web view. But Facebook contends that millions of people use Facebook in browser and so in iOS 9 they have used the new SFSafariViewController as the default behaviour for facebook logins even on devices. You can try to use the native Facebook and see if it works.
这不是问题。FB SDK 正在尝试打开具有 fbauth2:// url 类型的本机 facebook 应用程序。在模拟器中它不可用,所以它只是放置一个无法打开原生 Facebook 应用程序的日志。您可以在模拟器中配置 Facebook 帐户,然后告诉 FB 登录按钮使用本机 Facebook 帐户而不是打开 Web 视图。但 Facebook 声称,数以百万计的人在浏览器中使用 Facebook,因此在 iOS 9 中,他们使用新的 SFSafariViewController 作为 Facebook 登录的默认行为,即使在设备上也是如此。你可以尝试使用原生的 Facebook,看看它是否有效。
Check this link for the discussion.
检查此链接以进行讨论。
回答by ChrisHaze
After you have updated your App's .plist
file with the LSApplicationQueriesSchemes
array, which you seem to have already done:
.plist
使用LSApplicationQueriesSchemes
数组更新应用程序文件后,您似乎已经完成了:
Next, verify that your Facebook SDKis version 4.6.0. Follow the Facebook directionsif it's not.
接下来,验证您的Facebook SDK是否为4.6.0版。如果不是,请按照Facebook 说明进行操作。
Lastly, which is probably where the problem arises, is to Resetyour Simulator's content and settings
最后,这可能是出现问题的地方,是 重置模拟器的内容和设置
To Reset your Simulator:
重置模拟器:
- Choose Simulator
- Select Reset Content & Settings
- and the Resetoption
- 选择模拟器
- 选择重置内容和设置
- 和重置选项
Apple's Simulator, even the IDE, will have bugs and closing and reopening, along with reseting the simulator, are always something to consider early on in your search for a solution.
Apple 的模拟器,甚至 IDE,都会有错误,关闭和重新打开,以及重置模拟器,在您寻找解决方案的早期总是要考虑的事情。
Hope this helps!
希望这可以帮助!
回答by Marco Antonio Rojo Marcondes
I downgraded my Facebook SDK from version 4.7 to 4.5.1 and worked fine on both Simulator and iphone device(without Facebook app installed).
我将我的 Facebook SDK 从 4.7 版降级到 4.5.1 版,并且在模拟器和 iPhone 设备上都运行良好(没有安装 Facebook 应用程序)。
回答by Manab Kumar Mal
According to Facebook:
根据脸书:
iOS SDK supports SafariViewController which lets us switch show web-rendered dialogs instead of doing an app-switch. This beta SDK will automatically determine the best app switch experience for people based on their device. For example, defaulting the person's experience through SafariViewController instead of Safari for Facebook Login....
iOS SDK 支持 SafariViewController,它让我们可以切换显示 Web 渲染的对话框,而不是执行应用程序切换。此测试版 SDK 将根据人们的设备自动确定最佳的应用切换体验。例如,通过 SafariViewController 而不是 Safari 来默认用户的体验以进行 Facebook 登录......
Facebook reference link: https://developers.facebook.com/bugs/786729821439894/?search_id
Facebook 参考链接:https: //developers.facebook.com/bugs/786729821439894/?search_id
Stack ref link: https://stackoverflow.com/a/32593070/2905967
回答by Bhavin Chauhan
By following these steps, you may be able to avoid this error:
通过执行以下步骤,您或许可以避免此错误:
1) go to -> Supporting File
1) 转到 -> 支持文件
2) info.plist
2) info.plist
3) Right click on info.plist -> Open As -> Select Source Code
3) 右键单击 info.plist -> 打开为 -> 选择源代码
* Add code below inside <dict>...</dict>
*
* 在下面添加代码<dict>...</dict>
*
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
回答by Gaurav Patel
1] Authentication in Developer.facebook and generate Facebook Id like :=>460481580805052
1] 在 Developer.facebook 中进行身份验证并生成 Facebook Id 像 :=>460481580805052
2] Set Bitcode : No From Build Settings
2]设置位码:从构建设置中没有
3] Set up Plist File
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] Download 4 Sdk Framework like
4] 下载 4 Sdk 框架,如
=>Bolts.framework
=>FBSDKCoreKit.framework
=>FBSDKLoginKit.framework
=>FBSDKShareKit.framework
回答by viveksharma
please use LSApplicationQueriesSchemes or addd into plist your app id .
请使用 LSApplicationQueriesSchemes 或将您的应用程序 id 添加到 plist 中。
回答by Muzammil
For iOS 9 or above, add this method in your AppDelegate file:
对于 iOS 9 或更高版本,在您的 AppDelegate 文件中添加此方法: