0

I want to fetch the location from the network provider, not using CoreLocation framework in IOS. Is it possible to do that?

Amal T S
  • 3,327
  • 2
  • 24
  • 57

2 Answers2

3

You can get the IP address of the device and use an open api to get IP address details. From there you will be able to get an approximate location.

You can use this link to get the device's IP address.

nishith Singh
  • 2,968
  • 1
  • 15
  • 25
  • From the IP address, I am only getting a location which is about 100 km away from my actual location. I dont want such a long distance, What i am looking is for a location based on the mobile tower. – Amal T S Feb 07 '20 at 06:41
  • 2
    Locating mobile towers is not possible on iOS. – nishith Singh Feb 07 '20 at 06:57
2

The best way to access a user's location is through CLGeocoder as it is the most reliable source . That is the only way you can get the most accurate location .

Best option would be to actually let the user select his location in an un-harmful way . This would not guarantee a successfull return for your request though .

You could also use NSLocale and time zone but they are not reliable because they're dependent on user's settings.

Your best option in my opinion is to try to access the user's location through IP .So reverse geocoding the IP address of a web service request using GeoIP

I'v attached a few links i found below , take a look ,hopefully its of use to you . You could also take a look at Maximinds GeoIP Api . Might be useful

How to get an Ip address programatically

Maximinds GeoIP API