Check if Trusted Device is Enrolled
There are 3 methods that you can use to check about Trusted Device enrollment:

Check if this device is a Trusted Device

Example:
1
func checkTrustedDeviceStatusForThisDevice(userID: String) {
2
func callback(response: CotterResult<EnrolledMethods>) {
3
switch response {
4
case .success(let resp):
5
if resp.enrolled && resp.method == "TRUSTED_DEVICE" {
6
// This user's is enrolled in trusted device feature
7
}
8
case .failure(let err):
9
// Server returned error
10
}
11
}
12
​
13
CotterAPIService.shared.getTrustedDeviceStatus(userID: userID, cb: callback)
14
}
Copied!
JSON Result:
1
{
2
"enrolled": true, // If this user's device is enrolled in the below method, will show true
3
"method": "TRUSTED_DEVICE"
4
}
Copied!

Check if this account has any Trusted Device

Example:
1
func checkTrustedDeviceStatusForUser(userID: String) {
2
func callback(response: CotterResult<EnrolledMethods>) {
3
switch response {
4
case .success(let resp):
5
if resp.enrolled && resp.method == "TRUSTED_DEVICE" {
6
// This user is enrolled in trusted device feature (may not be on this device but another one)
7
}
8
case .failure(let err):
9
// Server returned error
10
}
11
}
12
​
13
CotterAPIService.shared.getTrustedDeviceEnrolledAny(userID: userID, cb: cb)
14
}
Copied!
JSON Result:
1
{
2
"enrolled": true, // If user is enrolled in the below method, will show true
3
"method": "TRUSTED_DEVICE"
4
}
Copied!
Last modified 1yr ago