Authenticate from a Non-Trusted Device
Steps
Step 1: Making an Authentication Request
class SomeUIVC: UIViewController {
var cotter: Cotter?
override func viewDidLoad() {
super.viewDidLoad()
self.cotter = Cotter(
apiSecretKey: "588d6f67-0981-4718-899b-bcd512de1aca",
apiKeyID: "w4FK6Zz0XIhtGY3o5biI",
cotterURL: "https://www.cotter.app/api/v0",
userID: "[email protected]",
configuration: [:]
);
}
// On Button Click
@IBAction func login(_ sender: UIButton) {
func callback(token: String, err: Error?) {
if err != nil {
// Failed login. Go to Error Page View Controller
print(err?.localizedDescription)
self.performSegue(withIdentifier: "segueToErrorView", sender: self)
return
}
// Successful login. Go to Dashboard View Controller
self.performSegue(withIdentifier: "segueToDashboard", sender: self)
}
/* Login using Cotter's Trusted Device Feature. */
self.cotter?.loginWithTrustedDevice(vc: self, cb: callback)
}
}Case 1: The current device is a Trusted Device
Case 2: The current device is NOT a Trusted Device
Step 2: How to approve a pending request from a Trusted Device

Receiving the result and check if the request was approved
Case 1: The request is approved
Handle the response in your callback class
Case 2: The request is rejected

Last updated