Determine whether user is at a specific location - ios

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

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).

Dynamic accuracy with Core Location

I would like my iOS app to get notified in background whenever user stops (or slows down below some velocity threshold) at a place while maintaining maximum battery life.
The catch is that I don't really care for accuracy when the user is moving but I need as accurate measurement as possible when user stops or walks around the same spot.
There are many Core Location tools available:
Standard Location Service
Significant Change Location Service
Geofencing and Ranging Service
Integration with Core Motion and M7 Motion Coprocessor
Which one of them should I use? Is there a best practice for what I am attempting to do? Has anybody experience with this sort of stuff? I found this app which does exactly what I want to incorporate in my app but I'm not permitted to use their API.
I've read the documentation but my case doesn't really fit any of the categories they discuss.
Thanks in advance.
Pete.
In iOS8 there is a new technology that fits what it sounds like you are asking for. CLVisit objects are sent to your app in the background when the user arrives or departs after stopping at a location. Power consumption is very low with this feature. You enable it by calling startMonitoringVisits on a CLLocationManager object.

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.

CLLocationManager not very accurate inital updates

This is stated in CLLocationManager class reference:
When requesting high-accuracy location data, the initial event delivered by the location service may not have the accuracy you requested.
This is really affecting my app. How can I make sure that the location found is the one with the correct accuracy?
I tried to use the 4th or 5th update rather than first retrieved location but this is not a good solution. Any idea?
You should check the accuracy of the updates, CLLocation
contains a property horizontalAccuracy which you can use to check the accuracy.
When the CLLocation has an accuracy that you find accurate enough you use and ignore al others.
Als you should tel CLLocationManager your desired accuracy. To do this set the desiredAccuracy property in CLLocationManager.
I think you will have to live with that. That's how Apple implemented it. Getting a fine grained position takes time, just think about how long any windshield-mounted GPS devices in cars take to fix up their position.
So instead of letting your application wait for a longer time, they provide with what accuracy is available almost immediately, based on cell-towers and WiFi hotspots in the vicinity. Only when there has been a more reliable GPS fix will they call into your app again and let you know.
In the end, it is just a question of where the waiting for the fine-grained position is: In your app, where you have the chance of doing something with the more coarse-grained data you get quickly, or in their framework with no chance for apps to do anything useful in the meantime. I think, letting you decide is the better choice.
Depending on the type of app, you could have a map that automatically zooms in deeper as soon as better position data comes in, draw a smaller circle around the position you are expecting etc. For the end user, nothing's worse than waiting without getting any feedback. So even though this is probably not the answer you would have liked, I advise to make the best of it from a user's perspective.

CLLocationManager - Monitoring regions vs. Significant Location Changes

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.

Resources