CLLocationManager - Monitoring regions vs. Significant Location Changes - ios

I am currently using significant location change updates to monitor whether or not the user has entered a particular area of interest (my definition of an area of interest is more broad than can be defined simply by geographic regions). My requirements are that my app should be woken up periodically to check if the user is said defined area (if it is not currently running).
My question is: would registering for region updates (since I have a number of regions that are known to fit my area of interest), provide me with more updates than simply listening for all significant lcoation changes, or would they simply be duplicate updates? The reason I ask this question is to clairify whether or not region monitoring is simply a filter on significant location change updates (since neither are documented as powering the GPS), or if region monitoring somehow is able to be more specific (maybe it powers the GPS, but with more specificity). In particular, I would be interested to know if anyone has seen data or documentation on this issue.
Thanks.

Region monitoring seems to pull from more specific location signal changes than the significant location change service. I say this because I've defined small regions (~100 m radius) that region monitoring picks up in the background, but that Significant location change does not. However please remember that the two events are triggered on different types of user actions.
Region monitoring - triggered on boundary crossings only. So a user must have two location update events on either side of the boundary. If you define large regions and the user walks around inside of them you will get no updates.
Significant location change - Seems to be triggered on the phone switching cell towers and the Location Awareness docs seem to suggest that. Here is some great data on general accuracy of these updates that suggests about 500 m between notification.

Related

How does CLVisit work?

I am working on a app that relies heavily on monitoring user visits in possibly multiple regions / areas. I am currently experimenting with region monitoring which works pretty well, however, the location callback is not as accurate as I want it to be. I have seen CLVisit, but the documentation out there doesnt explain it very well, especially its use.
I think you are misunderstanding the concept of CLVisits. There is actually no Visit object that you need to create. The CLLocationManager delegate method is triggered by the algorithm that apple has determined (see wwdc lecture for more info). This is explained in the CLLocationManager documentation...
Getting the Visited Locations
In iOS, the visits service provides an alternative to the significant location change service for apps that need location information about interesting places that the user visited. For example, if the user is in one location for an extended period of time, the service might generate an event when the user arrives at that location and another when the user leaves that location. The service is intended for apps that might already be using the significant location change service and want an even lower power way to do so. You would not use this service to create navigation apps or apps that rely on regular location updates.
To begin the delivery of visit-related events, assign a delegate to the location manager object and call its startMonitoringVisits method. As the location manager generates visit events, it delivers that information to its delegate’s locationManager:didVisit: method. The event data delivered to your delegate includes only the information that occurred after you started the delivery of events. In other words, if you start the delivery of events after the user arrived at an interesting location, the event delivered by the system when the user departed that location would not reflect the actual arrival time. If the system terminates your app, this service relaunches it when new visit events are ready to be delivered.
That said if you look at this article from NSHipster, it references some current issues with CLVists (for iOS 8.1). It essentially goes on to say that if you want infrastructure that extremely precise don't use CLVisit. Seems like you're doing it right (for now at least).
CLVisit is, as of iOS 8.1, not all that precise. While start and end times are
generally accurate within a minute or two, lines get blurred at the edges of
what is and what is not a visit. Ducking into a corner coffee shop for a minute
might not trigger a visit, but waiting at a particularly long traffic light
might. It’s likely that Apple will improve the quality of visit detection in
future OS upgrades, but for now you might want to hold off on relying on CLVisit
in favor of your own visit detection for use cases where it’s vital your data is
as accurate as it can be.

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.

Does the accuracy property influence the accuracy of mapview.userLocation? [Titanium]

I'm using the mapview property userLocation to show the users location on a map. Does it matter what value Ti.Geolocation.accuracy has or is the accuracy of the position marker (as it is a part of the map app) only influenced by the map app?
If it's latter: On Android I (as a User) can choose only between wifi/gps accuracy. Is the accuracy controlled automaticly (e.g. according to the battary charge)?
It seems that accuracy settings only apply to the Geolocation module. According to this thread, these settings have no effect on the user location accuracy on map views.
Based on the accuracy you choose, iOS uses its own logic to select location providers and filter location updates to provide location updates that meet your accuracy requirements.
Also remember: Location services stay enabled for as long as a listener is registered for the location event, so be sure to remove the event listener when you do not require location updates.
You can read more about it in Titanium.Geolocation documentation.
Rule of thumb is not overusing accuracy level when you are accessing user location. Be nice for your users and their devices. If your app will drain their battery in minutes they will remove your app and never come back to it.

Best way to monitor for a large (50000+) number of regions

I want to create an app which does a specific action when the user enters a certain area.
Since the regions I want to monitor reside server-side (approx. 50.000 locations) and the number of regions is far too large to be registered for monitoring all at once, I want to start monitoring for regions which are close to the current location of the user.
To accomplish this I am thinking about using startMonitoringSignificantLocationChanges
to monitor whether the user has changed location and then use locationManager:didUpdateToLocation:fromLocation:
to register new regions to monitor and unregister regions which are now too far away.
My questions:
Am I allowed do a call to a
web-service in
didUpdateToLocation while the app is
in the background?
Is this the best way to implement this kind of functionality or do you
know of a better way?
Thanks.
What you want is a space-filling-curve for example a z-curve of a hilbert-curve. It reduce the 2D problem to a 1D problem but it's most likely not answering your question.

Resources