Prerequisites for authentication
To start this example, your ViewController.swift
file should resemble the following:
//
// ViewController.swift
// DemoApp
//
import UIKit
import FRAuth
class ViewController: UIViewController {
@IBOutlet weak var statusLabel: UILabel?
@IBOutlet weak var loginButton: UIButton?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
FRLog.setLogLevel([.error, .network])
do {
try FRAuth.start()
print("SDK initialized successfully")
}
catch {
print(error)
}
updateStatus()
}
func updateStatus() {
if let _ = FRUser.currentUser {
statusLabel?.text = "User is authenticated"
}
else {
statusLabel?.text = "User is not authenticated"
}
}
@IBAction func loginButtonPressed(sender: UIButton) {
print("Login button is pressed")
}
}
-
Make sure to save your changes to the file.
-
In the
Main
storyboard, add a UILabel and a UIButton. -
Link these items to the IBOutlets and IBActions in the
ViewController
class.