问题
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.
回答1:
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.
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/11204816/how-do-startmonitoringsignificantlocationchanges-and-startupdatinglocation-effec