Any way to request that the GPS stays active, even in a low-motion situation?

I'm trying to create an application that keeps track of an anchored boat, and sounds an alarm if the boat moves outside of a certain radius (indicating the anchor is dragging instead of holding, or the boat is swinging around it to an undesirable location).

However, right off the bat, I've got an issue retrieving the device's location: the latitude and longitude values stop changing when the device is sitting still on the slow moving boat.

I'm setting desiredAccuracy to kCLLocationAccuracyBestForNavigation, but if I'm not holding the device in my hands, latitude and longitude updates stop coming in, and they won't come in regularly unless I pick up the device and rotate it around a little bit.

It seems to me like the GPS is being put to sleep at the system level because it's detecting that the device isn't moving very fast, and accelerometer data doesn't look like an active user, but I need to override that somehow so my app can stay on top of a boat's real-time location.

I've been able to reproduce this on multiple iOS devices, which is why I feel like something's going on at the system level, and isn't device-specific.

Is there any way for me to work around this behavior (other than building a motorized tray to keep physically rotating the device, of course :D)?

Accepted Reply

After posting this I tried one more thing, and it seems to be working!

I tried the various location manager "activityType" values, and while most of them allow the location to sleep, it seems like "airborne" requests high priority location data, even for low-speed things like runway taxiing.

With that activityType set, I'm now getting consistent location updates, even with subtle boat movements.

  • Marking this one as solved, but please do let me know if you foresee any issues with using the "airborne" activity type on a boat! The only obvious one I can think of is higher power consumption, but that's a worthwhile tradeoff for safety in this case.

Add a Comment

Replies

After posting this I tried one more thing, and it seems to be working!

I tried the various location manager "activityType" values, and while most of them allow the location to sleep, it seems like "airborne" requests high priority location data, even for low-speed things like runway taxiing.

With that activityType set, I'm now getting consistent location updates, even with subtle boat movements.

  • Marking this one as solved, but please do let me know if you foresee any issues with using the "airborne" activity type on a boat! The only obvious one I can think of is higher power consumption, but that's a worthwhile tradeoff for safety in this case.

Add a Comment

Do you have pausesLocationUpdatesAutomatically set?

If you don’t know - you do have it set; the default is enabled, to the surprise of everyone who discovers it.

  • Thanks for the heads-up on that value!

    I gave it a quick test and just setting that to false with the non-airborne activity types still results in paused lat/long for me. I keep getting location updates, but the updates contain the exact same lat/long even though I'm slowly moving.

    That said, I'll be sure to set it to false to make sure I keep getting the updates, too.

  • Just tested on two different iPads (one older and one newer) with the airborne activity type and default "true" value for pausesLocationUpdatesAutomatically. While the older iPad updated coordinates regularly, I needed to set pausesLocationUpdatesAutomatically to false in addition to the airborne activity type to get consistently updating coordinates, so not all devices are created equal here, and adjusting both values is required, thanks again!

Add a Comment

I keep getting location updates, but the updates contain the exact same lat/long even though I'm slowly moving

That’s probably because you’re using one of the activity types where Apple snaps your location to roads, or similar, in order to get tidier lines on the screen.

I use the running/hiking/ activity type (forget the exact name) for everything; it’s the least messed-about.

P.S. Don’t post comments, post replies. Comments don’t seem to generate email notifications.