iOS: Adding a Facebook Like button to a native iPhone app

21,302

Solution 1

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.

Solution 2

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

Solution 3

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

See documentation here

Solution 4

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/

Share:
21,302
Johann
Author by

Johann

Medium Articles Creating responsive layouts with Jetpack Compose https://johannblake.medium.com/creating-responsive-layouts-using-jetpack-compose-7746ba42666c Create Bitmaps From Jetpack Composables https://proandroiddev.com/create-bitmaps-from-jetpack-composables-bdb2c95db51 Navigation with Animated Transitions Using Jetpack Compose https://proandroiddev.com/navigation-with-animated-transitions-using-jetpack-compose-daeb00d4fb45 In-App Testing For Android https://proandroiddev.com/in-app-testing-for-android-6f762bb97387 Github https://github.com/JohannBlake ANDROID DEVELOPMENT 10 years of native Android development with Kotlin, Java & Android Studio Design, develop, test and deploy Android applications Professionally looking UIs with Jetpack Compose & Material Design Develop using continuous integration APIs: Google Cloud Messaging, Google Maps, Google Drive, Gmail, OAuth Frameworks & Patterns: MVVM, RxJava, Dagger, Koin, Retrofit, Sqlite, Room, Realm, Crashlytics Communicate with web services via RESTful APIs Troubleshoot, optimize and performance tune Code versioning using Git and the Gitflow model Project management with Jira Agile development with Scrum WEB DEVELOPMENT 25 years of web development React, Material-UI Javascript, HTML5, CSS3, jQuery, ASP.NET, C#, Java, Servlets Microservices running on the Google Cloud Platform ELECTRON DEVELOPMENT 2 Years of Electron development Javascript, jQuery Node.js HTML5, CSS3 Published Apps Motel One https://play.google.com/store/apps/details?id=com.motelone.m NBC Sports https://play.google.com/store/apps/details?id=air.com.nbcuni.com.nbcsports.liveextra Telemundo Noticias https://play.google.com/store/apps/details?id=com.nbcuni.telemundo.noticiastelemundo TD Mobile Banking https://play.google.com/store/apps/details?id=com.td

Updated on July 09, 2022

Comments

  • Johann
    Johann almost 2 years

    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.

  • volting
    volting over 11 years
    Unfortunately that doesn't allow you to like pages. You get an error: "Like actions are not yet supported against objects of this type."
  • Justin Johns
    Justin Johns about 10 years
    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.
  • ShivaPrasad
    ShivaPrasad about 10 years
    IT working only for above sample url not other object it i given below url as object id facebook.com/… but now working
  • Mawoon
    Mawoon about 10 years
    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.
  • vijay
    vijay over 8 years
    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-6368462164438‌​67