Wrags
Wrags

Reputation: 91

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

Upvotes: 9

Views: 7348

Answers (5)

VLegakis
VLegakis

Reputation: 470

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

Upvotes: 1

Oded Ben Dov
Oded Ben Dov

Reputation: 10397

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

Upvotes: 0

Ariel
Ariel

Reputation: 2440

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

Upvotes: 2

Confused Vorlon
Confused Vorlon

Reputation: 10446

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.

Upvotes: 0

Joey Schluchter
Joey Schluchter

Reputation: 2612

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.

Upvotes: 2

Related Questions