renjith kattappana
renjith kattappana

Reputation: 81

How to determine location source in iOS

I'm getting current location, In my app I want to know my location is from GPS or WIFI or cellular data. How do I check that ? Is there any way to determine location source ?

Apple iOS uses

Assisted Global Positioning System (A-GPS)

Crowdsourced Wi-Fi

Cellular network search

to determine your location:

These three stages are used in descending order of priority. In other words, iOS first attempts to fix your location by using a GPS satellite link. If it is unable to acquire a satellite, iOS fails over to Wi-Fi. If you are not connected to a Wi-Fi local area network (WLAN), then iOS uses cell tower data

Upvotes: 1

Views: 1427

Answers (1)

Avi
Avi

Reputation: 7552

Apple uses all the non-GPS systems simultaneously with GPS, as part of A-GPS. To say it's falling back is not really an accurate description. Rather, while trying to get a GPS lock, it will use the other systems to get a rough idea of your location. Only if no GPS lock can be obtained, will the phone simply report what it knows from the other sources.

CoreLocation does not provide its source (or sources), but you can use some heuristics to guess.

  1. Check the accuracy reported with location updates. A large range (e.g. 500+ meters) would indicate it's not a GPS fix.
  2. Check which radios are available. If there's no cellular radio in the device, fixes must come from Wifi.
  3. Check if the cellular radio is active. The device does not need service with available providers to use towers for a fix. Don't filter on that.

Those are my best guesses. If you really want this feature, you'll have to experiment.

Upvotes: 5

Related Questions