Like button in iOS app with Facebook Single-Sign-On
Asked Answered
W

5

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?

Wirephoto answered 17/3, 2011 at 14:55 Comment(1)
Have you figured out how to solve this problem?Ierna
L
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.

Larrikin answered 29/4, 2011 at 4:4 Comment(2)
Nice. Can you tell us where / how you are modifying the FB SDK?Monodic
You can fork the source on github here: github.com/Thuzi/iOS-Facebook-Authentication. It has examples for the like button baked in.Larrikin
S
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...

Strage answered 14/9, 2011 at 14:46 Comment(0)
Y
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 ;)

Yorick answered 7/6, 2012 at 14:36 Comment(0)
C
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.

Colocynth answered 11/8, 2011 at 13:24 Comment(0)
T
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/)

Tracitracie answered 2/12, 2011 at 6:23 Comment(2)
terribly sorry, this post explains that you can like pretty much everything, except for pages on facebook: #5837510Tracitracie
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.Oeflein

© 2022 - 2024 — McMap. All rights reserved.