Code Monkey home page Code Monkey logo

hpsocialnetworkmanager's Introduction

HPSocialNetworkManager

iOS framework for handling authentication with Facebook and Twitter with reverse-auth support.

Thanks to native support for Facebook and Twitter accounts in iOS, it's much easier to implement one-tap login and registration to your apps now. However there are a few pain points in this process:

  • iOS5 doesn't have native Facebook authentication support
  • Twitter support between iOS5 and iOS6 is slightly different and confusing
  • iOS-supported Twitter login uses a "global" Twitter app rather than your own, so tokens cannot be used anywhere else
  • A custom "reverse-auth" process needs to be implemented to obtain Twitter tokens that can be stored on server side
  • Facebook no longer supports "offline access" permission, so your app needs to reauthenticate at every launch, renewing its access token

HPSocialNetworkManager aims to ease the integration process by adding native support for all of these scenarios, and giving you a single interface that you can use to authenticate a user with one or more social networks.

Usage

Basic usage is like this:

[[HPAccountManager sharedManager] setupWithFacebookAppID:@"Facebook App ID"
                                  facebookAppPermissions:@[@"email", @"user_location", @"user_about_me"]
                                      twitterConsumerKey:@"Twitter Consumer Key"
                                   twitterConsumerSecret:@"Twitter Consumer Secret"];

[[HPAccountManager sharedManager] authenticateAccountOfType:HPAccountTypeTwitter
                                               withHandler:^(HPAccount *authenticatedAccount, NSDictionary *profileInfo, NSError *error) {
                                                   if (error) {
                                                       NSLog(@"Failed to authenticate: %@", error);
                                                   } else {
                                                       NSLog(@"Authenticated: %@", authenticatedAccount.identifier);
                                                   }
                                               }];

And that's it! Completion block is called with an HPAccount instance that contains the identifier and account type, and a profileInfo dictionary that contains the raw profile data received from Twitter or Facebook.

You can see an example of this by checking out the example project in this repo.

Installation

Copy and include the HPAccountManager directory (found here under Dependencies) in your own project. There are some other dependencies as well, you can see their details below under Requirements.

If your project uses ARC, you will have to mark the following files to be compiled without ARC, using the -fno-objc-arc flag in build settings:

  • HPAccountManager.m
  • HPAccount.m
  • NSData+Base64.m
  • OAuth+Additions.m
  • OAuthCore.m

On the other hand, if your project does not use ARC, you will have to mark the following files to be compiled with ARC, using the -fobj-arc flag:

  • TWAPIManager.m
  • TWSignedRequest.m

Requirements

Project comes bundled with the following dependencies:

  • ABOAuthCore
  • TWAPIManager

And it depends on the Facebook SDK to work properly. You can download it and include it in your project from https://developers.facebook.com/ios/

Required system frameworks are:

  • libsqlite3.dylib
  • AdSupport.framework
  • Accounts.framework
  • Twitter.framework
  • Social.framework

If you find any issues, please open an issue here on GitHub, and feel free to send in pull requests with improvements and fixes. You can also get in touch by emailing us at [email protected].

Credits

HPSocialNetworkManager is brought to you by Taylan Pince and the Hipo Team.

Special thanks to Sarp Erdag from Apperto for his testing and contributions.

License

HPSocialNetworkManager is licensed under the terms of the Apache License, version 2.0. Please see the LICENSE file for full details.

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.