简体   繁体   English

使用新的“ iOS iOS的Facebook SDK”与旧的“ Facebook iPhone SDK”进行Facebook身份验证

[英]Facebook authentication with new 'Facebook SDK for iOS' vs. old 'Facebook iPhone SDK'

I'm working on integrating Facebook with my iPhone/iOS application and I want to know if I'm understanding the nature of the login procedure correctly. 我正在将Facebook与我的iPhone / iOS应用程序集成,我想知道我是否正确理解了登录过程的本质。

With the old Facebook SDK ('Facebook iPhone SDK'), when we needed to request authentication permission from a user a UIWebView would be displayed with a login prompt. 使用旧的Facebook SDK(“ Facebook iPhone SDK”)时,当我们需要向用户请求身份验证权限时,将显示UIWebView并显示登录提示。 With the new SDK ('Facebook SDK for iOS'), the SDK uses Apple's fast-app-switching feature to temporarily place the app in background mode and then load the iOS Facebook app or Safari to authenticate. 借助新的SDK(“ iOS版Facebook SDK”),SDK使用Apple的快速应用程序切换功能将应用程序暂时置于后台模式,然后加载iOS Facebook应用程序或Safari进行身份验证。 Is this basically the gist of it? 这基本上是要旨吗?

I've experimented with authenticating my app via the new SDK's technique and due to the nature of my app, it just can't support backgrounding. 我已经尝试过通过新的SDK技术对我的应用程序进行身份验证,并且由于我的应用程序的性质,它不支持后台。 Does this mean I have to use the old SDK to launch a UIWebView-based authentication? 这是否意味着我必须使用旧的SDK来启动基于UIWebView的身份验证? I think this implementation is a lot cleaner anyway. 我认为无论如何,这种实现方式会更清洁。 Will I run into any major disadvantages from doing this? 我这样做会遇到任何主要的不利之处吗?

Check out this question and my answer: Iphone facebook connect example calls safari. 看看这个问题和我的答案: Iphone Facebook Connect示例调用safari。 I don't want to use safari 我不想使用野生动物园

You can make it use the UIWebView always. 您可以始终使用UIWebView Facebook is trying to make it so the user only has to log in once per device (through either the Facebook app or in Safari) but I didn't like this flow (especially on the iPad). Facebook试图做到这一点,因此用户只需要在每个设备上登录一次(通过Facebook应用程序或在Safari中登录),但我不喜欢这种流程(尤其是在iPad上)。 Though I'd rather not muck around with the Facebook code, I did find commenting out a few lines to be a quick way of getting the old behavior back. 尽管我宁愿不熟悉Facebook代码,但确实发现注释了几行是恢复旧行为的快速方法。

I don't believe this is the case. 我认为情况并非如此。

The Facebook SDK that I'm aware of, available at https://github.com/facebook/facebook-ios-sdk doesn't do anything like you describe. 我知道的Facebook SDK(在https://github.com/facebook/facebook-ios-sdk上提供)无法执行您所描述的任何操作。 Is this the SDK you're using? 您使用的是这个SDK吗? I believe the last major update to this SDK from the "old" facebook SDK was to add support for OAuth-style authentication. 我相信从“旧的” facebook SDK对该SDK的最后主要更新是添加了对OAuth样式身份验证的支持。 With this change they broke code compatibility so apps were forced to make changes to incorporate the latest SDK. 进行此更改后,它们破坏了代码兼容性,因此应用程序被迫进行更改以合并最新的SDK。

When you call 'authorize' in this SDK you pass the app id, the desired permissions, and a callback delegate for notifications of errors or success (did login, did not login, did logout). 当您在此SDK中调用“授权”时,您会传递应用ID,所需的权限以及用于通知错误或成功(已登录,未登录,已注销)的回调委托。 You can also set any access token that you might have persisted from a previous session. 您还可以设置上一个会话可能保留的任何访问令牌。 Facebook validates this access token, and if it doesn't exist or is invalid it presents a modal login dialog. Facebook会验证此访问令牌,如果它不存在或无效,则会显示一个模式登录对话框。 I believe the content of this dialog is a web page. 我相信此对话框的内容是网页。 The SDK authenticates the user using OAuth and makes the auth-token available for persisting between sessions. SDK使用OAuth对用户进行身份验证,并使身份验证令牌可用于会话之间的持久化。

At no time is the app exited to run the Facebook app or Safari. 该应用程序绝不会退出以运行Facebook应用程序或Safari。 I'm curious - what led you to believe this was the case? 我很好奇-是什么让您相信情况如此? (Or, perhaps there is some other SDK out there I'm unaware of?) (或者,也许还有一些我不知道的其他SDK?)

Take a look on this page: https://github.com/facebook/facebook-ios-sdk 在此页面上查看: https : //github.com/facebook/facebook-ios-sdk

And look at Single Sign-On . 并查看Single Sign-On That describes the above scenario with fast switching. 上面介绍了快速切换的情况。

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

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