iOS 上新的 facebook 登录重定向流程

Posted

技术标签:

【中文标题】iOS 上新的 facebook 登录重定向流程【英文标题】:New facebook login redirect flow on iOS 【发布时间】:2017-10-04 17:11:06 【问题描述】:

ios 11 开始,我在使用 FBSDKLoginKit 和 FBSDKCoreKit 时看到了新的登录流程。我意识到苹果最近改变了应用程序之间的通信方式:facebook 凭据意味着我们首先必须在身份验证流程中通过 safari……但由于某种原因,我看到了下面的警报对话框(请参阅第一个和第二个屏幕截图)即使在其他具有 facebook 登录功能的应用程序中,我也可以直接访问 facebook.com,然后可以选择通过本机 Facebook 应用程序进行身份验证使用电子邮件登录/password(见第二张截图)。

有谁知道为什么我在我的应用程序上看到了这个流程,但在我看过的几乎所有其他实现了 Facebook 登录的应用程序上都看到了不同的流程?我遵循https://developers.facebook.com/docs/facebook-login/ios 上列出的流程,所以我很难过。提前致谢。

【问题讨论】:

您尝试过更改loginBehavior 吗?请参阅github.com/facebook/facebook-ios-sdk/blob/master/FBSDKLoginKit/… 该警报是 iOS 11 的一部分'SFAuthenticationSession auth flow 该死,@nathan!谢谢。从FBSDKLoginBehaviorSystemNative 切换到FBSDKLoginBehaviorSystemBrowserFBSDKLoginBehaviorSystemAccount 解决了“缺少使用Facebook 应用程序登录”按钮的问题——但SFAuthenticationSession 警报仍然存在。切换到FBSDKLoginBehaviorSystemWeb 摆脱了SFAuthenticationSession 警报,但我们仍然缺少“使用 Facebook 应用程序登录”按钮。有什么方法可以不显示警报但有“使用 Facebook 应用程序登录”按钮(类似于 Breather 应用程序)? 啊,我看到你已经在别处回答了这个问题,@nathan ***.com/questions/45858774/… 部分正确。我不确定为什么使用 Native 而不是 Safari 时登录工具包不会打开应用程序(如果已安装)。 @nathan 随意用你上面所说的回答这个问题,我会继续接受。 【参考方案1】:

您可以尝试更改登录管理器的loginBehavior。见https://github.com/facebook/facebook-ios-sdk/blob/master/FBSDKLoginKit/FBSDKLoginKit/FBSDKLoginManager.h#L72。该警报是 iOS 11 的 SFAuthenticationSession 身份验证流程的一部分。

/**
  This is the default behavior, and indicates logging in through the native
 Facebook app may be used. The SDK may still use Safari instead.
 */
case native
/**
  Attempts log in through the Safari or SFSafariViewController, if available.
 */
case browser
/**
  Attempts log in through the Facebook account currently signed in through
 the device Settings.
 @note If the account is not available to the app (either not configured by user or
 as determined by the SDK) this behavior falls back to \c .native.
 */
case systemAccount
/**
  Attempts log in through a modal \c UIWebView pop up
 @note This behavior is only available to certain types of apps. Please check the Facebook
 Platform Policy to verify your app meets the restrictions.
 */
case web

【讨论】:

【参考方案2】:

这是一种有意的行为,Apple 和 Facebook 向我证实了这一点。这是 SafariViewController 身份验证的实现和流程,Apple 也记录了它(系统警报)&您发布的第三个屏幕截图很可能是使用旧版本 Facebook SDK 的应用程序。请查看this post 我几周前打开的用户体验与您描述的相同,然后您会发现更多 cmets 和指向正确文档的链接。除非您降级 FB 版本,否则您不能在代码中什么都不做以防止出现系统警报。

【讨论】:

以上是关于iOS 上新的 facebook 登录重定向流程的主要内容,如果未能解决你的问题,请参考以下文章

Facebook iOS 9 SDK 登录重定向到 Safari 上的 mbasic.facebook.com

facebook登录后重定向到一个URL

iOS Facebook SDK 3.0 登录未重定向到原始应用程序

成功登录 Facebook 后将 iOS 应用程序重定向到特定的视图控制器或 url

获得权限后的 Facebook 登录让 Safari 空白页面打开,而不是在 iOS 10 和 iOS 11 中重定向到我的应用

在我的 iOS 应用程序中集成 Facebook 应用程序时出现重定向问题