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.
- iOS (Swift)
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
- iOS (Swift)
- Android (Java)
// 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
}
}
// Use IP if you have no access to the user location
TFLocation location = new TFLocation(TFLocationProvider.IP);
// Use PRECISE if access is allowed
TFLocation location = new TFLocation(TFLocationProvider.PRECISE, preciseLocation: <Location>);
trustFactorClient.updateLocation(location: <TFLocation>, new Result<Boolean, Error>() {
@Override
public void onSuccess(Boolean value, String correlationId) {
// handle success
}
@Override
public void onFailure(Error error, String correlationId) {
// handle error
}
});