I like to track the users "location" by using the device's IP address.
I've already looked for some API services like:
- freegeoip.net
- api.petabyet.com
- ip-api.com
But I have no idea how to use this services to get the location of the users device.
Actually I've already looked for some Swift code snippets to get achieve the wanted result (to get the Location) but I couldn't find any code matching to the current version of Swift.
let url = NSURL(string: "http://freegeoip.net")
let task = URLSession.shared.dataTask(with: url! as URL) {(data, response, error) in
let httpResponse = response as? HTTPURLResponse
if (httpResponse != nil) {
} else { }
}; task.resume()
The few lines above are all that I got so far. But I really hope somebody could help me with this problem.