Facebook manager for social media login integration.
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
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])
}
fileprivate let facebookManager = FacebookManager()
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))")
}
}
NBFacebookManager is available under the MIT license. See the LICENSE file for more info.
Fahid Attique - (https://github.com/fahidattique55)