iOS: Adding a Facebook Like button to a native iPhone app
Asked Answered
F

4

10

I would like to know whether it is possible to add a Facebook Like button to a native iPhone app. In the app, the user browses a business directory or deals. When they tap on an item to view the details, it would be nice to have a Facebook Like button that can be used to post the item to the user's Facebook page.

Facebook writes: "Currently, the Like button is only available in mobile web apps".

My app is a native app and not a web app, so therefore I assume it's not possible. However, I do assume that it is possible to mix native UI components on a screen along with web components and therefore it might be possible to implement the Like button, although I am not sure how you pass data from the native portion to the web portion.

If the only solution is a hack, then I won't implement it because at some point the hack will fail when Facebook alters their API.

Fluviomarine answered 13/11, 2011 at 8:1 Comment(0)
D
7

read around SO a little, you get many leads. Here's one: Like button in iOS application

And a comment points to github.com/brow/FacebookLikeView

It has same caveats, but it seems there aren't any magic solutions.

There are these blogposts as well:

http://angelolloqui.blogspot.com/2010/11/facebook-like-button-on-ios.html

http://petersteinberger.com/2010/06/add-facebook-like-button-with-facebook-connect-iphone-sdk/

But not sure you get a native UIButton. Maybe you can open a webview in the background and emulate a click on it...

GL, update if you have some findings, Oded.

Dotson answered 15/11, 2011 at 22:8 Comment(0)
E
3

Now you can use the FBlike button using the following code but it need to download latest sdk and it is the beta version :(

Here is the code:

[FBSettings enableBetaFeature:FBBetaFeaturesLikeButton];
[FBSettings enablePlatformCompatibility:NO];
FBLikeControl *like = [[FBLikeControl alloc] init];
like.objectID = @"http://shareitexampleapp.parseapp.com/photo1/";
like.likeControlHorizontalAlignment=FBLikeControlHorizontalAlignmentRight;
like.likeControlStyle=FBLikeControlStyleBoxCount;
[self.view addSubview like];
Equivocation answered 12/5, 2014 at 12:40 Comment(3)
IT working only for above sample url not other object it i given below url as object id facebook.com/… but now workingLimbourg
The Like Button can be used to like a Facebook Page or any Open Graph object and can be referenced by URL or ID. I have checked in my project. its working.Equivocation
Only this url only its working for check this url its not working but like count correctly its showing.Please help me if you found any solution for this...facebook.com/Unofficial-badminton-clubs-636846216443867Morning
E
2

It looks like Facebook finally decided to allow this, more directly, via the Open Graph API.

See documentation here

Errantry answered 30/12, 2012 at 9:59 Comment(2)
Unfortunately that doesn't allow you to like pages. You get an error: "Like actions are not yet supported against objects of this type."Minatory
If you read the Facebook article carefully, they allow an app to post an open-graph action that informs the user's friends that they like the page, but you still cannot make the user's account 'Like' your page. At best, you can jump to your Facebook page and hope the user presses the 'Like' button.Memorial
S
1

Check this out, FB just made it possible through their SDK. Only for testing and ios for now

https://developers.facebook.com/docs/ios/like-button/

Sallee answered 6/5, 2014 at 7:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.