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:

class SomeUIVC: UIViewController {
  @IBOutlet weak var textLabel: UILabel!

  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: "hello@example.com",
      configuration: [:]
    )
  }

  // On Button Click
  @IBAction func removeTrustedDevice(_ sender: Any) {
    func callback(token: String, err: Error?) {
      if err != nil {
        self.textLabel.text = err?.localizedDescription
        return
      }
      self.textLabel.text = token
    }

    CotterWrapper.cotter?.removeTrustedDevice(vc: self, cb: callback)
  }
}

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.