Remove Trusted Device
You can remove the current device from being a trusted device.
In the future, you can also revoke other trusted devices from any trusted device.

Removing this Trusted Device

To remove the current device from being a trusted device, do the following:
Example:
1
class SomeUIVC: UIViewController {
2
@IBOutlet weak var textLabel: UILabel!
3
​
4
var cotter: Cotter?
5
​
6
override func viewDidLoad() {
7
super.viewDidLoad()
8
​
9
self.cotter = Cotter(
10
apiSecretKey: "588d6f67-0981-4718-899b-bcd512de1aca",
11
apiKeyID: "w4FK6Zz0XIhtGY3o5biI",
12
cotterURL: "https://www.cotter.app/api/v0",
13
userID: "[email protected]",
14
configuration: [:]
15
)
16
}
17
​
18
// On Button Click
19
@IBAction func removeTrustedDevice(_ sender: Any) {
20
func callback(token: String, err: Error?) {
21
if err != nil {
22
self.textLabel.text = err?.localizedDescription
23
return
24
}
25
self.textLabel.text = token
26
}
27
​
28
CotterWrapper.cotter?.removeTrustedDevice(vc: self, cb: callback)
29
}
30
}
Copied!
For the above callback, a text label will be populated to let the user know whether the removal succeeded or failed. Otherwise, if desired, the user can also perform a segue to another view controller in the callback function as well.
For the above example, clicking on the button linked to removeTrustedDevice in the view controller will make a request to remove the current device as a trusted device. If the request is successful, no error will exist, and a text label will be populated to let the user know whether the removal succeeded or failed. Otherwise, if desired, the user can also perform a segue to another view controller (on success or failure) in the callback function as well.
You cannot remove the last Trusted Device. You will need to have 1 remaining Trusted Device.