开发者

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?

I have an app that uses a UIWebView to display a webpage and with in that page there is a FB like button. I've gotten the开发者_StackOverflow like button to work as proposed in the post

Like button in iOS application

But the sign-in dialog doesnt look that nice and it would just be awesome if I could use the SSO flow instead. 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. This allows me to create my like buttons (or Like Boxes) inside the UIWebViews.


Facebook API actually first checks if your ios device supports multitasking. 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. Pay attention to use the same Facebook object, otherwise you'll need to login for every action...


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.

1) FB stores a login cookie for authorization.

2) Each Web component like e.g. UIWebView or external Safari uses its own sandboxed cookie storage. 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)

4) Let me know if you find some other way ;)


You can intercept the action from your like button.

Just set your like button with a link to http://mydomain.com/doLikeStuff

in the UIWebView, check in webView:shouldStartLoadWithRequest:navigationType:

for the /doLikeStuff link, return NO (so the web view doesn't actually do anything) and implement your custom flow.


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

To back it up, here's an excerpt from FB Graph API documentation:

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:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜