简体   繁体   English

iOS上的Facebook SDK 4.6登录按钮不使用Facebook应用程序进行身份验证

[英]Facebook SDK 4.6 login button on iOS doesn't use Facebook app for authentication

I'm using the Facebook SDK v4.6.0 for iOS 9 in a simple Swift app to add a login button to my app (I've followed the steps in Preparing Your Apps for iOS 9 ). 我在一个简单的Swift应用程序中使用适用于iOS 9的Facebook SDK v4.6.0来为我的应用程序添加登录按钮 (我已按照为iOS 9准备应用程序中的步骤)。

The login button always opens Safari to authenticate, and never uses the native Facebook app. 登录按钮始终打开Safari进行身份验证,从不使用本机Facebook应用程序。 Is this the expected behavior? 这是预期的行为吗? Is it possible to use the native app (where many users are already authenticated) instead of going straight to the web login? 是否可以使用本机应用程序(许多用户已经过身份验证)而不是直接进入Web登录?

I've tried testing the app on my iPhone by building and running using XCode, and with a build distributed by TestFlight. 我已经尝试通过使用XCode构建和运行以及使用TestFlight分发的构建来测试我的iPhone上的应用程序。 It always opens Safari to authenticate, even though I have the native app installed and configured. 即使我安装并配置了本机应用程序,它也始终打开Safari进行身份验证。

I found this relevant question where the answer seems to apply only to the 3.x SDK. 我找到了这个相关的问题 ,答案似乎只适用于3.x SDK。 I've also found other questions that had references to configuring tryFBAppAuth or authorizeWithFBAppAuth that seemed to apply to edge cases on previous versions of the FB SDK. 我还发现了其他一些引用配置tryFBAppAuthauthorizeWithFBAppAuth问题,这些问题似乎适用于以前版本的FB SDK上的边缘情况。 I haven't found a clear answer for 4.6. 我没有找到4.6的明确答案。

This is by design. 这是设计的。 I have filled a bug report a few days ago and Facebook still has some issue with iOS 9. 我几天前填写了一份错误报告,Facebook仍然存在iOS 9的问题。

See the Facebook team answer: https://developers.facebook.com/bugs/786729821439894/?search_id 请参阅Facebook团队的回答: https//developers.facebook.com/bugs/786729821439894/?search_id

You need to whitelist the facebook native app. 你需要将facebook原生应用程序列入白名单。 In your info.plist, make sure you have the following entry 在info.plist中,确保您有以下条目

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

Unless you whitelist an url scheme, your iOS app won't be able to switch to that app. 除非您将网址方案列入白名单,否则您的iOS应用将无法切换到该应用。 The facebook SDK will display Safari instead of the native app in that case. 在这种情况下,facebook SDK将显示Safari而不是本机应用程序。

Are you compiling with iOS9 SDK (XCode 7.x)? 您是否正在使用iOS9 SDK(XCode 7.x)进行编译? As mentioned in FB's iOS9 preparation page you should be compiling with the new SDK for app switching policies to take place. 正如FB的iOS9准备页面中所提到的,您应该使用新的SDK来编译应用程序切换策略。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM