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
func loginWithEmail() { | |
let inputState = NSUUID().uuidString | |
let vc = _accountKit!.viewControllerForEmailLogin(withEmail: nil, state: inputState) | |
self.prepareLoginViewController(loginViewController: vc) | |
self.present(vc as UIViewController, animated: true, completion: nil) | |
} |
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
func loginWithPhone(){ | |
let inputState = UUID().uuidString | |
let vc = (_accountKit?.viewControllerForPhoneLogin(with: nil, state: inputState))! | |
vc.enableSendToFacebook = true | |
self.prepareLoginViewController(loginViewController: vc) | |
self.present(vc as UIViewController, animated: true, completion: nil) | |
} |
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
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
if _accountKit?.currentAccessToken != nil { | |
// if the user is already logged in, go to the main screen | |
// ... | |
} | |
else { | |
// Show the login screen | |
} | |
} |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
// initialize Account Kit | |
if _accountKit == nil { | |
_accountKit = AKFAccountKit(responseType: .accessToken) | |
} | |
} |
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
class LoginViewController: UIViewController, AKFViewControllerDelegate { | |
var _accountKit: AKFAccountKit! | |
} |
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
func prepareLoginViewController(loginViewController: AKFViewController) { | |
loginViewController.delegate = self | |
//UI Theming - Optional | |
loginViewController.uiManager = AKFSkinManager(skinType: .classic, primaryColor: UIColor.blue) | |
} |
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 AccountKit | |
class LoginViewController: UIViewController, AKFViewControllerDelegate{ | |
//... | |
} |
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
<plist version="1.0"> | |
<dict> | |
... | |
<key>FacebookAppID</key> | |
<string>{your-app-id}</string> | |
<key>AccountKitClientToken</key> | |
<string>{your-account-kit-client-token}</string> | |
<key>CFBundleURLTypes</key> | |
<array> | |
<dict> |
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
$ pod install |
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
pod 'AccountKit' |