How do startMonitoringSignificantLocationChanges and startUpdatingLocation effect one-another?
Asked Answered
O

3

19

What happens if I call startUpdatingLocation while startMonitoringSignificantLocationChanges is running? Does significantLocationChange monitoring get stopped? If I then stopUpdatingLocation will significantLocationChange monitoring continue or restart?

I can find no documentation covering the interplay between these two ways of monitoring location.

Oestrone answered 26/6, 2012 at 9:54 Comment(3)
Hey, did you find any more information regarding this ? Especially the interaction part. Does iOS stop one from running if the other one is started ?Belostok
Do you know if you can do startUpdatingLocation after you get a startMonitoringSignificantLocationChanges in the backgroundState?Hankhanke
I'm sorry but I haven't used this API for many years. Why don't you ask a new question?Oestrone
M
5

They are not meant to be used concurrently. It's either or as they both deliver heading and location changes to the same delegate method.

locationManager:didUpdateToLocation:fromLocation

They differ in the frequency and accuracy (and by extension hardware used and power consumption ) of the changes. You as the developer need to decide which is best based on your use case

I have a need to use both approaches at different times. When I switch from one to the other I set a flag that I can reference in my delegate so that I know the type of update.

Marabou answered 26/6, 2012 at 16:36 Comment(2)
Thanks. This is exactly what I'm doing at the moment. I've wrapped the CLLocationService with my own service and I'm using that to set flags for the type of services being used. I was just interested in how the two interact. It's interesting how completely the Apple docs neglect to mention this subject.Oestrone
In the latest docs, Apple does mention that they can be run simulaneously, but does not provide any detail on interaction. "If both location services are enabled simultaneously, they deliver events using the same set of delegate methods." developer.apple.com/reference/corelocation/cllocationmanagerOverthrow
D
28

I don't think the accepted answer really answers the question asked. I did some tests and you can use both if you want and they will not cancel each other out.

Why would someone want to use both ? Because startMonitoringSignificantLocationChanges wakes up the app from being suspended or terminated without the need of any background modes. So if you run both you can get accurate foreground location updates and significant location change background location updates.

Of course, you can switch the method, when going into background but a) that wasn't the question b) it adds unneeded logic

Of course, there's a question if running both methods drains more battery, but my bet is that it doesn't.

Degraded answered 24/9, 2015 at 19:57 Comment(0)
M
5

They are not meant to be used concurrently. It's either or as they both deliver heading and location changes to the same delegate method.

locationManager:didUpdateToLocation:fromLocation

They differ in the frequency and accuracy (and by extension hardware used and power consumption ) of the changes. You as the developer need to decide which is best based on your use case

I have a need to use both approaches at different times. When I switch from one to the other I set a flag that I can reference in my delegate so that I know the type of update.

Marabou answered 26/6, 2012 at 16:36 Comment(2)
Thanks. This is exactly what I'm doing at the moment. I've wrapped the CLLocationService with my own service and I'm using that to set flags for the type of services being used. I was just interested in how the two interact. It's interesting how completely the Apple docs neglect to mention this subject.Oestrone
In the latest docs, Apple does mention that they can be run simulaneously, but does not provide any detail on interaction. "If both location services are enabled simultaneously, they deliver events using the same set of delegate methods." developer.apple.com/reference/corelocation/cllocationmanagerOverthrow
S
5

Standard location service and significant location change service can be used together. Quote from the API Reference:

If both location services are enabled simultaneously, they deliver events using the same set of delegate methods.

A good reason to use both is that the standard service gives better accuracy, while the significant location change service works even when your app is suspended.

Seigneury answered 3/1, 2017 at 6:54 Comment(1)
Thank you for explaining why you'd use both. I was wondering that as the OP didn't state his reasons.Arsenate

© 2022 - 2024 — McMap. All rights reserved.