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.

Mike G
  • 4,232
  • 9
  • 40
  • 66
Johann
  • 27,536
  • 39
  • 165
  • 279

4 Answers4

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.

Community
  • 1
  • 1
Oded Ben Dov
  • 9,936
  • 6
  • 38
  • 53
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];
Mawoon
  • 1,045
  • 1
  • 7
  • 10
  • IT working only for above sample url not other object it i given below url as object id https://www.facebook.com/photo.php?fbid=1429823447278009&set=a.1408685429391811.1073741829.1408585776068443&type=1&theater but now working – ShivaPrasad May 17 '14 at 12:08
  • 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. – Mawoon May 17 '14 at 15:01
  • 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...https://www.facebook.com/Unofficial-badminton-clubs-636846216443867/ – vijay Nov 02 '15 at 12:45
2

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

See documentation here

Nate
  • 31,017
  • 13
  • 83
  • 207
  • 5
    Unfortunately that doesn't allow you to like pages. You get an error: "Like actions are not yet supported against objects of this type." – Josh Hinman Feb 02 '13 at 04:48
  • If you read [the Facebook article](http://developers.facebook.com/docs/opengraph/guides/og.likes) 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. – Justin Johns Apr 05 '14 at 05:40
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/

LolaRun
  • 5,526
  • 6
  • 33
  • 45