Skip to main content

Adding the Facebook Like Button in an iPhone App



Does anyone know how I would include a facbeook "like button" in an iphone app. I tried calling the iframe inside of a uiwebview but that doesn't work.




Comments

  1. Check out this nice bit of code:
    http://angelolloqui.blogspot.com/2010/11/facebook-like-button-on-ios.html

    Add the FBLikeButton class to your view:

    FBLikeButton *likeButton = [[FBLikeButton alloc] initWithFrame:CGRectMake(0, 372, 320, 44)
    andUrl:@"http://www.facebook.com/pages/De-Zilk/108209735867960"];


    Thanks a lot Angel García Olloqui

    EDIT: Nice to add... For bonus points:
    If you use above method the webpage is not well formatted for an iPhone. What you can do is run some JavaScript code to remove all the disturbing divs. Use this (long sentence):

    [_webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"javascript:document.getElementsByClassName('uiButton')[2].style.visibility='hidden';var child1 = document.getElementById('standard_status');var parent1 = document.getElementById('login_form');parent1.removeChild(child1);var child2 = document.getElementById('pageheader');var parent2 = document.getElementById('booklet');parent2.removeChild(child2);document.getElementById('loginform').style.width = '200px';var child3 = document.getElementById('reg_btn_link');var parent3 = document.getElementsByClassName('register_link')[0];parent3.removeChild(child3);var child4 = document.getElementById('signup_area');var parent4 = document.getElementById('login_form');parent4.removeChild(child4);var child5 = document.getElementsByClassName('mbm')[0];var parent5 = document.getElementById('loginform');parent5.removeChild(child5);var child6 = document.getElementsByClassName('reset_password form_row')[0];var parent6 = document.getElementById('loginform');parent6.removeChild(child6);var child7 = document.getElementsByClassName('persistent')[0];var parent7 = document.getElementById('loginform');parent7.removeChild(child7);"]];


    You can place it in the delegate method webViewDidFinishLoad from the FBDialog Facebook class.

    ReplyDelete
  2. You can include it in a UIWebView, just make sure it's inside <html><body>. The problem is that once the user clicks the button, the UIWebView may redirect to a log-in form, so you would have to make it large enough to fit that thing.

    Have fun creating a design that presents the button in a sensible fashion.

    ReplyDelete
  3. Several of the solutions above (e.g. @floorjiann, @fabiobeta, @Stephen-Darlington, @scott) assume that the iPhone application is also a Facebook application (with its own id).

    However if your iPhone application just has a fan page, this is not the case.

    ReplyDelete
  4. maybe this is helpful

    http://www.raywenderlich.com/1626/how-to-post-to-a-users-wall-upload-photos-and-add-a-like-button-from-your-iphone-app

    ReplyDelete
  5. Facebook have recently updated their iPhone Facebook Connect framework to work with the Graph API. This is the API that you need to "Like" objects on Facebook.

    ReplyDelete
  6. I this moment in time you can't. The mobile APIs are not exposing this capability.
    You can use some workaround consisting in embedding the html way of doing it in your app.

    Some details on the workaround here: http://petersteinberger.com/2010/06/add-facebook-like-button-with-facebook-connect-iphone-sdk/

    ReplyDelete
  7. Here you go - w the source code...enjoy -and please leave a comment if its useful.

    http://nowbranded.com/blog/adding-a-facebook-like-button-to-an-iphone-application/

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?

CCNA 3 Final Exam => latest version

1 . Which security protocol or measure would provide the greatest protection for a wireless LAN? WPA2 cloaking SSIDs shared WEP key MAC address filtering   2 . Refer to the exhibit. All trunk links are operational and all VLANs are allowed on all trunk links. An ARP request is sent by computer 5. Which device or devices will receive this message? only computer 4 computer 3 and RTR-A computer 4 and RTR-A computer 1, computer 2, computer 4, and RTR-A computer 1, computer 2, computer 3, computer 4, and RTR-A all of the computers and the router   3 . Refer to the exhibit. Hosts A and B, connected to hub HB1, attempt to transmit a frame at the same time but a collision occurs. Which hosts will receive the collision jamming signal? only hosts A and B only hosts A, B, and C only hosts A, B, C, and D only hosts A, B, C, and E   4 . Refer to the exhibit. Router RA receives a packet with a source address of 192.168.1.65 and a destination address of 192.168.1.161...