User Location & Connection Status
In many scenarios, we need to know the location of the customer or the current VPN location, in case the customer is currently connected to the VPN, in order to either present them in the reports or to obtain the best smart location.
This is implemented, by performing an API call to the Instance Discovery Service /conn_status endpoint. This endpoint receives the request’s IP address and will use the Maxmind Service, to lookup information about that IP , such as Country, ISP, ASN etc.
In case the user is not connected to the VPN, the result will represent information about the user’s “real” aka ISP location. If the user is connected to the VPN, the result will represent the information about the current VPN server location. The Instance Discovery Service can thus lookup the request IP and check if it’s a known VPN IP. If that' the case the returned connection status is vpn_connected=true, otherwise it will be false.
fn get_user_location(&self, mode: LocationMode) -> Result<GeoLocation> func getUserLocation(mode: LocationMode) throws -> GeoLocationfun `getUserLocation`(`mode`: LocationMode): GeoLocation@Throws(InstanceDiscoveryException::class)LocationMode
The real location will be cached in the SDK. In order to update the location, always call the SDK Managers networkChanged() method whenever you change the status of the VPN connection, the user switched between WiFi/Cellular or a significant location change was detected (e.g. user switched into a different network).
Auto
This mode will return what ever location is currently available, based on whether the user is connected to the VPN or not.
RealLocation
This mode aims to provide the actual Internet Service Provider (ISP) location of the customer. If the customer is connected to a VPN, making the real location inaccessible, the SDK will attempt to retrieve a previously cached location. In the event that no cached location is available, an exception, SdkException::RealLocationNotAvailable, will be thrown, which is encapsulated by an InstanceDiscoveryException.
VPNLocation
This mode is only available while the user is currently connected to the VPN and will return the VPN Location. If the user is not connected, the SDK will return SdkException::VPNLocationNotAvailable.
The VPN location is not cached for privacy reasons.
Geolocation
current_ip
String
IP Address
iso_country_code
String
ISO country code associated with the IP
region
String
Region code associated with the IP
isp
String
ISP name associated with the IP
asn
String
Autonomous System Number associated with the IP
latitude
Float
Latitude of the geolocation associated with that IP
longitude
Flaot
Longitude of the geolocation associated with that IP
vpn_connected
Bool
true, if that IP is associated with the brand's IP pool.
Last updated