Last active
June 2, 2017 12:44
-
-
Save exocode/3da7c63fa67006ccab2b9f73c943b033 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import FacebookCore | |
| @UIApplicationMain | |
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| var window: UIWindow? | |
| public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { | |
| // Override point for customization after application launch. | |
| return SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions) | |
| } | |
| public func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { | |
| return SDKApplicationDelegate.shared.application(app, open: url, options: options) | |
| } | |
| public func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { | |
| return SDKApplicationDelegate.shared.application(application, open: url) | |
| } | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import Alamofire | |
| import FacebookCore | |
| import FBSDKLoginKit | |
| class LoginViewController: UIViewController { | |
| func getFBUserData(){ | |
| if((FBSDKAccessToken.current()) != nil){ | |
| FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email"]).start(completionHandler: { (connection, result, error) -> Void in | |
| if (error == nil){ | |
| //everything works print the user data | |
| print(result!) | |
| } | |
| }) | |
| } | |
| } | |
| @IBAction func facebookLoginButtonPressed(_ sender: Any) { | |
| let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager() | |
| fbLoginManager.logIn(withReadPermissions: ["email", "user_events", "user_likes", "user_birthday"], from: self) { (result, error) in | |
| if (error == nil){ | |
| let fbloginresult : FBSDKLoginManagerLoginResult = result! | |
| if(fbloginresult.grantedPermissions.contains("email")) | |
| { | |
| self.getFBUserData() | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment