Skip to main content

Location

TrustFactor uses your location to calculate operations risk. You can set the location manually or allow the SDK to do it for you.

info

Location information can be updated in the background even if the user is not authenticated

Client requirements

Automatic

When using automatic make sure the user gives location permissions. On iOS, if you don't stop the location monitoring the operating system might wake up the app in the background to update the location. You need to handle this on your AppDelegate and update TrustFactor manually.

If your application does not need an accurate location consider Indicating whether the app requests reduced location accuracy by default.

// Start location monitoring
trustFactorClient.startMonitoringLocation()

// Stop location monitoring
trustFactorClient.stoptMonitoringLocation()

Manually

// Use .ip if you have no access to the user location
let provider = .ip

// Use .coreLocation if available
let provider = .coreLocation(<CLLOcation>)

trustFactorClient.updateLocation(provider) { result in
switch result {
case .success(let state):
switch state {
case .updated:
break;
case .notSignificant:
print("Not a significant location change since last update")
}

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

}
}