Background location updates...does pausesUpdatesAutomatically actually work?

Does anyone else use startLocationUpdatesAsync with “Always”?

It appears that even with “pausesUpdatesAutomatically” set to true, it will still show as “1h” of “background” in the battery even if the phone is sitting on a desk.

I’m using:

{
          accuracy: LocationAccuracy.Balanced, // Accurate to within one hundred meters.
          pausesUpdatesAutomatically: true,
          activityType: LocationActivityType.AutomotiveNavigation,
}

Has anyone been able to get the background location updates to run only for a few minutes every hour if the phone is not moving?

Expo Managed 40

Now I switched it to:

       accuracy: LocationAccuracy.Lowest,
          pausesUpdatesAutomatically: true,
          activityType: LocationActivityType.Other,

But as you can see, when I have the Location on “Always” it literally is always on, even with pausesUpdatesAutomatically.

The phone is resting on my desk the entire time…

I looked at Apple’s documentation:

https://developer.apple.com/documentation/corelocation/cllocationmanager/1620553-pauseslocationupdatesautomatical

After a pause occurs, it is your responsibility to restart location services again when you determine that they are needed. Core Location calls the locationManagerDidPauseLocationUpdates(_:) method of your location manager’s delegate to let you know that a pause has occurred. In that method, you might configure a local notification whose trigger is of type UNLocationNotificationTrigger and is set to notify when the user exits the current region. The message for the local notification should prompt the user to launch your app again so that it can resume updates.

Through Expo, can the pausing actually happen? What settings can I put to actually get the background location updates to pause? If it does get paused, does Expo handle starting it up again?

Has Expo ever actually tested the pausesUpdatesAutomatically functionality on iOS?

cc @charliecruzan @ide

The expo-location source code is probably the best place to find the answer to that question. My guess is that the pausing parameter is passed through and it’s down to the OS’s heuristics to decide what “automatically” means. Mobile development is sometimes “whatever Google or Apple’s heuristic/policy is for this OS or service” but it might also help to compile expo-location from source and explore.

@ide - The expo-location source code calls on the native modules in EXLocation. Running a search for “locationManagerDidPauseLocationUpdates”, I get no results.

Here is a description of that function:

https://developer.apple.com/documentation/corelocation/cllocationmanagerdelegate/1621553-locationmanagerdidpauselocationu

I see no mention of it in the source code. Since Apple’s documentation says that it will have to be restarted manually if it is paused, my guess is that Expo did not implement it, or maybe Expo will just automatically start it up again after some time interval? Again…I see no mention of it in the expo-location library. Maybe I need to look elsewhere?

Is there anyone that works at Expo that actually knows? Was this ever tested to see if actually gets paused? Perhaps it’s an oversight in Expo source code?

cc @charliecruzan

I believe all of the location code is inside of expo-location so if you don’t see something there, it probably isn’t implemented and you might want to try building it yourself.

@tsapeta might know more about the location library but it’s been awhile since he last worked on it IIRC, it’s one of 100+ packages.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.