Giter VIP home page Giter VIP logo

facebooklikeview's Introduction

#FacebookLikeView

FacebookLikeView is a Facebook Like button for native iOS apps.

It integrates with the Facebook iOS SDK so that authenticated users can Like with a single tap, and unauthenticated users are prompted with the standard authentication dialog.

FacebookLikeView is not officially supported by Facebook, and it requires your application to use the in-app authentication dialog rather than single sign-on via Safari or the Facebook app.

To see FacebookLikeView in action, build the included FacebookLikeViewDemo project.

##Getting started

  1. If you haven't already installed the Facebook iOS SDK, add the files in the FBConnect directory to your Xcode project.

  2. Add the files in the FacebookLikeView directory to your Xcode project.

  3. Instantiate a FacebookLikeView programmatically or in a nib.

  4. Set the URL to be liked, plus any Like button attributes you'd like to customize. Make sure the layout you choose fits within the view's bounds.

     _facebookLikeView.href = [NSURL URLWithString:@"http://www.yardsellr.com"];
     _facebookLikeView.layout = @"button_count";
     _facebookLikeView.showFaces = NO;
    
  5. Set a delegate that implements facebookLikeViewRequiresLogin:. Your implementation should call -[Facebook authorize:delegate:], and then -[FacebookLikeView load] once login is complete.

     _facebookLikeView.delegate = self;
    
     ...
    
     - (void)facebookLikeViewRequiresLogin:(FacebookLikeView *)aFacebookLikeView {
         [_facebook authorize:[NSArray array] delegate:self];
     }
    
     - (void)fbDidLogin {
         [_facebookLikeView load];
     }
    
  6. Finally, call -[FacebookLikeView load] before you display the view. You should also call this method any time the user signs in or out of Facebook, and after modifying any of the FacebookLikeView's properties.

##More delegate methods

You may want to be notified when the Like button is used. In that case, implement these optional FacebookLikeViewDelegate methods:

- (void)facebookLikeViewDidLike:(FacebookLikeView *)aFacebookLikeView;
- (void)facebookLikeViewDidUnlike:(FacebookLikeView *)aFacebookLikeView;

To avoid showing the Like button before it's completely rendered, you can hide the FacebookLikeView until this delegate method is called:

- (void)facebookLikeViewDidRender:(FacebookLikeView *)aFacebookLikeView;

##How it works

FacebookLikeView uses a web view to host the same Like button XFBML as would be used on a web page.

Since the web view shares cookies with all other web views in your app, a user that authenticates through Facebook's in-app dialog is also authenticated to use the Like button. The web view does not share cookies with Safari or the Facebook app, so FacebookLikeView monkeypatches FBConnect to never use those apps for authentication.

Unlike a plain web view, FacebookLikeView does not follow redirects. If redirected to the Facebook login page, it ignores the redirect and calls the delegate method facebookLikeViewRequiresLogin: so that you may present a dialog instead.

FacebookLikeView monitors Like/Unlike events using FB.Event.subscribe. When one of those events fires, a bit of JavaScript running inside the web view encodes the event into a URL request that is intercepted by native code, which then calls the appropriate delegate method.

##Caveats

FacebookLikeView is not supported by Facebook and is subject to break when changes are made in the Like button's implementation.

FacebookLikeView is also not necessarily compatible with future versions of the Facebook iOS SDK. To ensure compatibility, use the SDK snapshot contained in the FBConnect directory.

facebooklikeview's People

Contributors

brow avatar ezwart avatar nanoant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

facebooklikeview's Issues

Like Event Question

Its really good source. Thanks a lot~

i tried the DEMO, but i found the edge.create & edge.remove is not firing.
Do you have any glue?

How to know current status?

I've successfully implemented FacebookLikeView in my application, now based on like or unlike a page, I am performing my other actions, its working good if a user never liked my page, the flow will be,

  1. User will see the like button,
  2. User likes the page,
  3. The user performs next action

Now next time he again back to the same flow,

  1. The user will see the unlike button as it was already like

Now, I am looking for the status, which shows whether it's already liked or not? If liked before then I don't want to show the button.

A way that I know about that into, facebookLikeViewDidRender delegate method.

Please note,
It is a request and not an issue, but I can't find the way to request you so adding here.

Thanks! :)

Recent FB change has broken events?

I think Facebook have made some changes that seem to have broken the event notifications.
The like button still works but it is no longer possible to get an event when the user has liked or unliked.

Checked the demo too and it seems broken also.

Click on LIKE button and nothing happen

I'm trying to integrate sample project to my iPad's project.
The sample project works well but doesn't on my project.
Everything seems to work well(button appears, number of likes appears exactly) exempt clicking on it.
When is clicked on the button, It still call function

  • (void)facebookLikeViewRequiresLogin:(FacebookLikeView *)aFacebookLikeView {
    [_facebook authorize:[NSArray array]];
    NSLog(@"REQUEST CLICK");
    }
    the Log is printed out but nothing appear. Please help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.