Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone GPS Development - Tips + Tricks [closed]

I'm looking for some feedback, blog links, etc that offer some tips and tricks for iPhone GPS development. I've read and understand the API, I have my demo app up and running, etc but I have run into some "quirks" with gps on iphone. For example, it seems that you you will receive a lot less location updates when your iphone enters "power save" mode. I've read that you can combat this by playing music in your application [not sure if this is true].

It also seems that, terms of making a reasonable pedometer, you should filter out any reading with horizontal accuracies less than 20 meters. Does this sound right?

Is there any kind of checklist out on the web for iphone gps gotchas?

Thanks in advance.

like image 488
Keith Fitzgerald Avatar asked Jan 28 '09 15:01

Keith Fitzgerald


People also ask

Can you trick your iPhone GPS?

3uTools is the best way to fake your iPhone or iPad location because the software is free, and we've confirmed that it works with iOS and iPadOS 16. Download and install 3uTools. We tested it on Windows 11, but it works in other versions of Windows as well.

How can I improve my iPhone GPS?

To improve GPS accuracy: Make sure that you've set the date, time, and time zone correctly on the device in Settings > General > Date & Time. If possible, use Set Automatically. Keep a clear view in several directions.

Do newer iPhones have better GPS?

The new iPhone 14 Pro and iPhone 14 Pro Max feature dual-frequency GPS support for more accurate location tracking, according to Apple's tech specs for the devices. The functionality is also supported on the new Apple Watch Ultra.


2 Answers

I don't know of any specific list, but here are a few of things you should keep in mind:

  • You're not doing GPS lookups. You're doing Core Location lookups. Core Location might or might not be getting its information from GPS. Lots of people still use pre-3g iPhones that don't have GPS, and even on a 3g phone GPS may be unavailable in many cases (if the person is indoors, for example). In those cases the phone will attempt to triangulate based on cell phone towers, and Core Location will return the result. It'll be much less precise than GPS.
  • Core Location will cache data. The first reading it provides to your app is likely to be an old reading, which might or might not be accurate, depending on whether the phone has moved. Make sure to check the timestamp of any location and see if it's from before your app started.
  • I don't know what you mean by "power save" mode, but if you're thinking of when the screen is locked/off, that does not stop Core Location from running if your app is still running. On the contrary it's easy to run down your phone's battery much more quickly than you'd expect if you lock the phone while an app that uses Core Location is running, because the phone will continue to update the app as new location data is available. You could avoid this in your application by listening for UIApplicationWillResignActiveNotification to detect the screen locking, and UIApplicationDidBecomeActiveNotification to detect unlock.
  • Higher precision results will take more time to acquire, because the longer you wait, the better the results, up to a limit. If you decide you need to be within N meters, consider how long the user might have to stand there waiting for the phone to home in on its location.

Whether 20 meters is accurate enough is something only you can answer, based on how you expect your application to be used. Test the app and see if it works the way you want it to work.

like image 108
Tom Harrington Avatar answered Oct 06 '22 23:10

Tom Harrington


Tom had a great answer (I wanted to note especially the usual return of the first value might be an older cached location) but I had a few more things to add:

  • You can tell the location manager to stop and start again if you want to force it to issue you at least one more location update.
  • If you were not aware, there are convenience methods in CLLocation to give you the distance between two locations.
  • As the docs note, you should implement locationManager:didFailWithError: even though you do not have to (if only to stop the location manager updates for a time).
  • Test thoroughly scenarios where the user disallows location updates for your application!
  • Very, very infrequently you may get updates out of order (i.e. you get a more accurate location followed by a slightly less accurate one dated earlier)
  • The simulator will give you a location update, but will always report your location as Apple HQ.
like image 41
Kendall Helmstetter Gelner Avatar answered Oct 07 '22 00:10

Kendall Helmstetter Gelner