Latest 0.0.2
Homepage https://github.com/fahidattique55/NBFacebookManager
License MIT
Platforms ios 9.0
Dependencies FBSDKCoreKit, FBSDKLoginKit
Authors

Swift version
Support Dependecy Manager
Version
License
Platform

Features

  • Integrate facebook login in your application with only two steps.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

 $ gem install cocoapods

To integrate NBFacebookManager into your Xcode project using CocoaPods, specify it in your Podfile:

 source 'https://github.com/CocoaPods/Specs.git'
 platform :ios, '9.0'
 use_frameworks!

 target '<Your Target Name>' do
 pod 'NBFacebookManager'
 end

Then, run the following command:

 $ pod install

Pre-Requisite

  • Please visit Facebook Developer Site to create a new application and follow the instructions to get facebook App-ID setup in plist file of your Xcode project.

Usage

Step 1

  • Install the NBFacebookManager pod.
  • Add following code in your Appdelegate.swift file,

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    return true
}

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {

    return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}

@available(iOS 9.0, *)
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {

    return FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}

Step 2

  • Create the FacebookManager instance in your controller to authenticate user and get its facebook profile.

fileprivate let facebookManager = FacebookManager()

  • Authenticate the user using ‘facebookManager’ as given below

facebookManager.tryAuthenticate(fromViewController: self, success:{ facebookToken in

    self.getProfileIfNeeded()

}) { error in

    print("Error: (String(describing: error?.localizedDescription))")
}

private func getProfileIfNeeded(){

    facebookManager.fetchLoggedUserInfo(successBlock: { (userInfo) in

        print("(String(describing: userInfo))")

    }) { (error) in
        print("Error: (String(describing: error?.localizedDescription))")
    }
}
  • Congratulations! You have successfully integrated facebook login in your application.

License

NBFacebookManager is available under the MIT license. See the LICENSE file for more info.

Author

Fahid Attique – (https://github.com/fahidattique55)

Latest podspec

{
    "name": "NBFacebookManager",
    "version": "0.0.2",
    "summary": "Facebook manager for social media login integration",
    "description": "Integrate Facebook login in your application with only two steps.",
    "homepage": "https://github.com/fahidattique55/NBFacebookManager",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Fahid Attique": "[email protected]"
    },
    "source": {
        "git": "https://github.com/fahidattique55/NBFacebookManager.git",
        "tag": "0.0.2"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "NBFacebookManager/Classes/**/*.{swift}",
    "dependencies": {
        "FBSDKCoreKit": [],
        "FBSDKLoginKit": []
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This