9

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

Community
  • 1
  • 1
Wrags
  • 91
  • 1
  • 4

5 Answers5

2

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.

Joey Schluchter
  • 2,522
  • 3
  • 22
  • 26
2

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

Ariel
  • 2,430
  • 1
  • 17
  • 20
1

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

VLegakis
  • 470
  • 5
  • 10
0

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.

Confused Vorlon
  • 9,659
  • 3
  • 46
  • 49
0

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

Community
  • 1
  • 1
Oded Ben Dov
  • 9,936
  • 6
  • 38
  • 53
  • terribly sorry, this post explains that you can like pretty much everything, except for pages on facebook: http://stackoverflow.com/questions/5837010/facebook-api-liking-page-on-behalf-of-user-extended-permissions – Oded Ben Dov Dec 02 '11 at 07:05
  • 1
    Be careful when posting copy and paste boilerplate/verbatim answers to multiple questions, these tend to be flagged as "spammy" by the community. If you're doing this then it usually means the questions are duplicates so flag them as such instead. – Kev Dec 02 '11 at 11:15