Skip to main content

Associate profile

To associate new profiles you can either use a Deeplink or scan a QR Code.

An association code may require the user to share a precise location with the enrollment — see Precise location below.

Client requirements​

let url = URL(string: "https://....")

trustfactorClient.associateApplicationProfile(using: .deeplink(url)) { result, correlationId in
switch result {
case .success(let associationResult):
// handle result

case .failure(let error):
// handle errors
}
}

Using an association code​


let code = "....."

trustfactorClient.associateApplicationProfile(using: .code(code)) { result, correlationId in
switch result {
case .success(let associationResult):
// value is a boolean we can ignore

case .failure(let error):
// handle errors
}
}

Precise location​

An application can require a precise location per registration code, so the same application may require it for some enrollments and not for others. Read the requirement from Association details before you start, or simply pass a fix whenever your application holds one — TrustFactor ignores it when the code does not ask for one.

The fix has to be taken for this association. The position shared through updateLocation(_:) is the device's last known location, is kept without expiry and may not have come from GPS, so it never satisfies the requirement.

A refused association burns the code

TrustFactor consumes a registration code before it refuses the registration, so an association sent without the location it requires needs a fresh code to retry.

The SDK answers this locally whenever it can: if the code requires a location and none is usable, the association fails with profileAction(.preciseLocationRequired) before the request leaves the device and the code stays usable. The same error is returned when TrustFactor refuses the registration itself (E_400100004).

// A location the app captured for this enrollment — CLLocationManager.requestLocation(), not a cached one.
let location: CLLocation = ...

trustfactorClient.associateApplicationProfile(using: .code(code), preciseLocation: location) { result, correlationId in
switch result {
case .success(let associationResult):
// handle result

case .failure(let error):
if let error = error as? TrustFactorError,
error.domain == .profileAction(code: .preciseLocationRequired) {
// ask the user to allow precise location, then retry with the same code
}
// handle errors
}
}
Reduced accuracy

If your app declares NSLocationDefaultAccuracyReduced, a user who granted location access still gives you a fuzzed position. Call requestTemporaryFullAccuracyAuthorization(withPurposeKey:) before capturing the fix, and declare the purpose key in NSLocationTemporaryUsageDescriptionDictionary.