Getting background location on WatchOS with no phone present

WatchOS 3.2 and Apple Watch Series 2

I wanted to see if it was possible to get a constant location from the Apple Watch Series 2, from the GPS, without having the phone present.

Background Task

The first thing to check is if it was possible to run a background task to get the location every so often. The WKApplicationRefreshBackgroundTask allows you to do this, but it is budgeted by WatchOS to one task per hour so was not any use for our purpose. It is obvious why this is the case, to save battery on the watch.

Background Modes

Getting location updates from enabling CLLocationManager in the watch is not a supported background mode, so CLLocationManager is not fully featured on the watch. On an iPhone, you can run this in the background and it will provide location changes to your app in the background. The only supported mode on WatchOS 3 is Workout Processing, with the added option of sound and picture in picture related to workouts.

How does Strava get location?

Strava is a workout app, and I have checked that the watch can be used for a run and track location without the phone present. I assume that it calls a location update when it gets the callback to process workout data from HKWorkoutSession. It may call data from Health Kit and that contains location information from that workout session. I could not confirm in the Health Kit documentation that workout data contains location information.

Conclusion

It’s not possible to create an app (extension) on the watch that gets location tracking without running a workout session.

Leave a Reply

Your email address will not be published. Required fields are marked *