简体   繁体   English

喜欢Facebook单点登录的iOS应用程序中的按钮

[英]Like button in iOS app with Facebook Single-Sign-On

Is there any way to use the FB Single-Sign-On sign in flow in combination with the like button in a UIWebView? 有没有办法在UIWebView中结合使用FB Single-Sign-On登录流程?

I have an app that uses a UIWebView to display a webpage and with in that page there is a FB like button. 我有一个使用UIWebView显示网页的应用程序,在该页面中有一个类似FB的按钮。 I've gotten the like button to work as proposed in the post 我已经按照帖子中提出的那样按钮工作了

Like button in iOS application 喜欢iOS应用程序中的按钮

But the sign-in dialog doesnt look that nice and it would just be awesome if I could use the SSO flow instead. 但是登录对话框看起来并不好看,如果我可以使用SSO流程,那就太棒了。 But I haven't gotten this to work yet. 但我还没有把它发挥出来。 Any body who has tried this out? 有没有试过这个的人?

I actually modify the Facebook source to alway use safari for auth instead of the single sign on. 我实际上修改了Facebook的源代码,总是使用safari代替auth而不是单点登录。 This allows me to create my like buttons (or Like Boxes) inside the UIWebViews. 这允许我在UIWebViews中创建我喜欢的按钮(或Like Boxes)。

Facebook API actually first checks if your ios device supports multitasking. Facebook API实际上首先检查您的ios设备是否支持多任务处理。 If not it is using the pop up dialog. 如果不是,则使用弹出对话框。 If the device does support, then it trying to use Facebook app (if it is installed on the device of course), then safari and only then fallbacks to pop up dialog. 如果设备确实支持,那么它试图使用Facebook应用程序(当然,如果它安装在设备上),然后是safari,然后才会回退到弹出对话框。 Pay attention to use the same Facebook object, otherwise you'll need to login for every action... 注意使用相同的Facebook对象,否则你需要为每个动作登录...

Its not possible to use Web components (like UIWebView or external Safari) and native code (like a UIButton you refer to) in order to intercommunicate between them in a SSO-like manner. 它不可能使用Web组件(如UIWebView或外部Safari)和本机代码(如您所指的UIButton),以便以类似SSO的方式在它们之间进行相互通信。

1) FB stores a login cookie for authorization. 1)FB存储用于授权的登录cookie。

2) Each Web component like eg UIWebView or external Safari uses its own sandboxed cookie storage. 2)每个Web组件(如UIWebView或外部Safari)都使用自己的沙盒cookie存储。 I've found (and I strongly believe there is) no way to achieve intercommunication between them. 我发现(我坚信有)没有办法实现它们之间的相互通信。

3) Native code uses an AccessToken which is stored per app's sandbox in order to use in external FBs API calls (like authorize, graph calls etc) 3)本机代码使用AccessToken,它存储在每个应用程序的沙箱中,以便在外部FBs API调用中使用(如授权,图形调用等)

4) Let me know if you find some other way ;) 4)如果你找到其他方法,请告诉我;)

You can intercept the action from your like button. 您可以从喜欢按钮拦截操作。

Just set your like button with a link to http://mydomain.com/doLikeStuff 只需设置您喜欢的按钮,其链接指向http://mydomain.com/doLikeStuff即可

in the UIWebView, check in webView:shouldStartLoadWithRequest:navigationType: 在UIWebView中,检入webView:shouldStartLoadWithRequest:navigationType:

for the /doLikeStuff link, return NO (so the web view doesn't actually do anything) and implement your custom flow. 对于/ doLikeStuff链接,返回NO(因此Web视图实际上不执行任何操作)并实现自定义流。

It seems there is an agreement on not being able to do this. 似乎有一项协议无法做到这一点。 However, this post shows you can: Using 'Like' with the Facebook Graph API on iOS 但是,这篇文章显示你可以: 在iOS上使用Facebook图谱API的“赞”

To back it up, here's an excerpt from FB Graph API documentation: 要备份它,这里是FB Graph API文档的摘录:

You can comment on or like any object that has a /comments or /likes connection by posting to https://graph.facebook.com/OBJECT_ID/comments and https://graph.facebook.com/OBJECT_ID/likes , respectively: 您可以分别发布到https://graph.facebook.com/OBJECT_ID/commentshttps://graph.facebook.com/OBJECT_ID/likes ,对具有/ comments或/ like连接的任何对象发表评论或喜欢:

(source: http://developers.facebook.com/docs/reference/api/ ) (来源: http//developers.facebook.com/docs/reference/api/

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

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