What Does startMonitoringSignificantLocationChanges uses to Deliver Location - ios

I want to Know what does startmonitoringsignificantlocationchanges uses to deliver location, is it GPS or Wifi/Internet? My Understanding is it uses cellular or wifi,to know if device has moved significantly but what I don't know is, at time of picking location does it use GPS alone to pick up location.
My Findings are : I travelled 30 KM in City Train but did not get any locations in background and during this journey my Wifi and Cellular data was off. So please tell if Significant fails to provide locations based on GPS only.

Building location apps in the past, I assumed that GPS was only used when startUpdatingLocation() was called. After double-checking the docs, Apple doesn't explicitly state whether significantLocationChanges CAN use GPS, but it is a power-saving option, and their docs specify that it "requires the presence of cellular hardware", which makes me pretty certain that my assumption (and yours) are correct. I'd leave this up for a bit, in case there's a hardware expert who knows for sure. The docs you want: https://developer.apple.com/reference/corelocation/cllocationmanager

Like all location functionality, it uses a combination of cell, wifi, and GPS. Use of cell is primary. The idea is to keep use of GPS to a minimum, in order to prevent drain on the battery.
You certainly cannot expect this to work with the cell turned off; indeed, if your code properly checks significantLocationChangeMonitoringAvailable with the cell off, I would intuitively expect the answer to be false.
(Also note that you will not get any events unless you have a location manager with a delegate.)

As explained in this answer "Hows does Significant Location Change work?" (and in WWDC videos from 2013-2015) Significant location change monitoring uses a technique called Cell Tower Triangulation.
You can think of it as almost the same mechanism as GPS triangulation except that the cellular hardware will be used to gauge distance from nearby cell towers instead of firing the GPS hardware to get signals from actual satellites.
In my experience I've noticed that this method gives accuracy of approx. 1000m. It does not use the GPS hardware and hence is more battery efficient. It is good for coarse location updates. See WWDC 2013 session Harnessing iOS to Create Magic in Your Apps where the presenter makes a passing reference to this technology.

Related

How much accurate does apps like Uber, GoogleMap, Life360 works, I mean what can be the minimum distanceFilterValue to listen to location updates?

I am working on a feature in an iOS app to send location updates to our backend when there is a change in the location.
Initially, I had set minimalDistanceFilter(minimum change in location value) to none to send location updates. But it is making the network calls continuously and it can increase the load on the backend.
If some of you worked on this case earlier, I wanted to know how you solved it. What can be the minimalDistanceFilter?
I am also curious about how the above-listed apps work with location-related events.
The distanceFilter and the desiredAccuracy go hand-in-hand. For the distance filter, it can be anything between kCLDistanceFilterNone and CLLocationDistanceMax. See the documentation.
Regarding what other people used, it will vary widely from app to app. For navigation apps, you tend to need high accuracy so you don't miss a turn. But a weather app might be perfectly happy with city-level accuracy.
If you really need reasonable precision and want to reduce volume, then a filter of 5–15 meters is a good starting point. Try different values yourself and see what the effect is.
But there is no magical answer to your question. You will have to balance the legitimate needs of your app with (a) the server load; and (b) the power consumption on the device.
By the way, if the app doesn't need high accuracy, you might contemplate the very efficient, but less accurate, significant change service which will report changes of roughly 500 meters, with a frequency not exceeding once every 5 minutes
Finally, remember, nowadays the user is in control of the accuracy. You can request whatever accuracy you want, but if the user wants to preserve their privacy, they can choose not to share their precise location, and there is nothing you can do about it (other than to try to make a case for why precise location data is essential for the proper functioning of your app).

Switching between significant-location-change monitoring and location-updates monitoring based on application state

We use significant-location-change monitoring to know about our user's whereabouts when the app is not running. This data is based on cellular towers signals and therefore is not very accurate. We would like to use more accurate data whenever it is possible, that is, when the app is active or running in the background.
The question is, should I use "startMonitoringSignificantLocationChanges" and "startUpdatingLocation" at the same time, or, should I switch between those two methods? And if the second option is better, what app delegate events should I use in order to perform the necessary switch?
Unless you want to support a feature that needs continuous high precision location stream, its best to avoid using the high accuracy GPS data via startUpdatingLocation all the time.
I understand from your question that you intend to use more accurate location only at certain points of interest, when your app is woken up. In that case, the second approach of switching-on the more accurate location data only when needed, would be a better idea.
locationManager(_:didUpdateLocations:) in your CLLocationManager delegate would be a good point to start this in your case. Remember that significant location change monitoring API wakes up the system at least once every 15 minutes, even if there are no location changes, until it is explicitly stopped. So one must use it with care.
Instrumenting accurate location tracking while making sure that you don't eat up all of the phone battery is a non-trivial problem to solve. You may want to give third party SDKs like Hypertrack, which specialise in this, a try.

How does CLLocationManager get location?

TL;DR:
My objective: Try all forms of getting a location and then choose the most accurate one, (try get a location for a minute then time out).
I'm a little confused about where it gets the location from, is it GPS? Cellular? or a mix of both depending on toolkit?
While getting location on Android I used both and then choose which provider based on accuracy. I do not see anything similar for iOS.
I'm using CLLocationManager which is showing good accuracy but I'm not sure where the location is from.
On iOS, location manager is built more intelligently. Relying on your configuration, it either uses GPS or WiFi/cell radios, as described in the CLLocationManager documentation:
For the services you use, configure any properties associated with
that service accurately. Core Location manages power aggressively by
turning off hardware when it is not needed. For example, setting the
desired accuracy for location events to one kilometer gives the
location manager the flexibility to turn off GPS hardware and rely
solely on the WiFi or cell radios, which can lead to significant power
savings.
For more information, read
CLLocationManager documentation.
EDIT
And, If you want the most accurate location, you should put kCLLocationAccuracyBestForNavigation for location manager's desiredAccuracy property.

Determine whether user is at a specific location

What's the best way to determine whether the user is at a specific location, i.e. at a gas station?
I've implemented an approach where the app is listening for major location changes until the user get's close enough to a location. Then the app switches to the more accurate location updates (kCLLocationAccuracyBest). It then checks if the user is close enough, and if so, I consider this as a "check-in". This works quite well. If the user moves away from our location of interest, I switch back to the major location updates to save energy.
This works as the user does not live or work within the first threshold (I currently use 300 meters). This situation drains the user's battery for no reason. If I set this threshold to low, the major location updates might not be accurate enough to detect the user in front of our location.
I'm using MKLocalSearchRequest to find all the places of interest in close proximity to the user.
So, I assume there are better ways. Any suggestions?
Thanks!
– Flo
iBeacons are the low power way if that fits your use case. http://en.m.wikipedia.org/wiki/IBeacon Is a suprisingly good overview
They are reasonably cheap, and can be simulated with computer software

Switch btw. Location Manager & Region Monitoring

for an app that is part of a scientific study I have to implement location tracking (the users who take part in the study know this and are willing to supply this data). The two premises for this app are:
track the user's location with the highest accuracy possible while he/she is on the move
use as little power as possible so that users don't feel the need to shut down the app (turn off location services for it), while they aren't using it
I know these two requirements normally exclude each other :) So the general question is "What would be the best strategy to meet in the middle here?"
My thoughts were to monitor as usual with the highest accuracy possible while location changes keep coming in. If we detect that the delta between theses location updates become almost 0 over a certain period of time, we would assume that the user is not "on the move" anymore and would switch to region monitoring (with a radius of e.g. 40m). Once the user exits that region we'd switch back to regular location monitoring.
So two questions:
Can you tell me if the proposed approach will work for an app that is running in the background?
Have you maybe implemented something similar and know if it really saves a lot of battery power?
Regards,
Sebastian
My thoughts were to monitor as usual with the highest accuracy possible while location changes keep coming in. If we detect that the delta between theses location updates become almost 0 over a certain period of time, we would assume that the user is not "on the move" anymore and would switch to region monitoring (with a radius of e.g. 40m). Once the user exits that region we'd switch back to regular location monitoring.
Using region monitoring to re-engage the location monitoring has a few draw backs, that I have found:
If you set up a region for the user's current location, then wait for -didExitRegion to fire, you're reliant upon the system's default radius cushion, (probably 200m) and some time (probably 20 sec) after they cross out of their boundary before you'll get the message. If accuracy is your main goal, you're likely to loose a lot of data points in between when region monitoring started and when you cross out of the region. Is that acceptable for your needs?
So, to answer your questions:
Can you tell me if the proposed approach will work for an app that is running in the background?
You should not have any trouble running this type of thing in the background. Both location monitoring and region monitoring work when an app is backgrounded, provided you've set it up to do so. Also, to ensure Region Monitoring works on iOS 7 you must have Background App Refresh turned on for your app. That tripped me up.
Have you maybe implemented something similar and know if it really saves a lot of battery power?
In our experience the battery savings were not noticeable. Region Monitoring can be a battery drain that's just as significant as the high accuracy location updates because it uses all kinds of hardware to do it's thing. So pick your poison. Apple's recommendation for saving battery is and always has been to use the significant change location service. It gives you good location data just not as often.

Resources