How to do hourly location updates? - iphone

I'm building a location-based app, but I hate having the location services icon on. I only need coordinates once per hour, but I can't figure out how to do this without saying the app is a VoIP app. Is it possible to do this in a way that's App Store acceptable?

You can use location in the UIBackgroundModes of your app, see the documentation.
About the location services icon on, I think you should leave it. It's a fair feedback for your user. A user has to know its position is being tracked and leaving the icon on for a few seconds each time the geolocation actually happens wouldn't be fair. (and it sounds like a case of app rejection to me).
As long as you don't have a negative impact on the device battery, the user will be grateful you let it know you're tracking his position.
For instance, apps such as OpenPaths made my iPhone show the location icon on all the time and have no real negative impact on the battery.

I would register for significant location change updates. When updates happen compare timestamp with last update. Use update if time delta > 60 minutes. Worst case: I believe you get the location indicator outline. this tells the user that a kind of tracking is happening — but not all the time, so it' not a battery issue and you don't get too many support requests. Best case: Registering for significant location change update doesn't show the indicator outline. But I am not certain. Completely without icon might just not be possible.

Related

iOS background location updates

I have created an app which uses location updates in the background. I have submitted my app to apple but it got rejected by apple on the ground that you are using location updates in background rather than using significant location update and shape based region monitoring.
My app takes location updates and provided user with specific updates, which works perfectly for my scenarios and have made code to better save battery. With Apple's suggested approach the problem I'm getting with significant location update and shape based region monitoring is location accuracy. With significant location update I get events fired for all the region within that cell tower range or say 100 m - 3000 m rather than when user enters a region say lat long with 100 m radius.
I've had many conversations with apple and they don't seem to care about the developers and new technologies they are creating.
Is there any developer who faced same problem of using background location update to do something other than navigation and got accepted or has anyone used significant location update with shape based monitoring to provide precise updates with better location accuracy.
Any help is much much appreciated.
Varun welcome to SO community.
Here is some lines from docs
Any app that requests background location services should use those services to provide a tangible benefit to the user. For example, a turn-by-turn navigation app would be a likely candidate for background location services because of its need to track the user’s position and report when it is time to make the next turn.
So if you are using standard location service and whenever you get updates and you are not doing anything with that update (in terms of user not coding) then there are very high chances that Apple may reject your app, which they already did.
So what's the solution then?
1. Answer is try submitting the app with other approach.
2. Try submitting the app with other name :D
Solution Number 1. Instead of using standard services use significant location service which gives the accuracy of around hundreds of meters say 200-1700 m and track if user is moving near to your spot or far away from your spot.
If user is moving near to your spot and user is around 500m (depends upon you) near to your spot just start standard location services and track where user is going if user enters you spot then show user "Catch you" or if user moves away from your spot (>500m) then stop standard location service and start significant location service.

Issue with GPS icon while using "Location Significant Change" and user perception

I developed an application that uses "Location Significant Change" feature. I notice that after users download my app, they quickly tend to uninstall it because they see the white GPS icon on their iPhone, and they think it will drain their phone battery.
I wonder if there is any workaround or suggestion, I wonder also if Apple is going to do anything about the GPS icon when using "Location Significant Change" feature, either on iOS 6 or next versions.
on comparison Android have a feature where you could setup Alarm manager to wake up application on certain time intervals. This will solve the problem, is there something similar on iOS (or iOS 6 maybe).
Thanks.
This is going to be a non-negotiable aspect to using location services on an iOS device. Apple wants to inform users when their location is being used so they can make informed decisions. So overriding or hiding this location icon, is not going to happen. (jailbreak excluded)
In my opinion, you have a couple options to help yourself out.
Inform the users in your app description in the app store so they know up front that the battery life isn't going to be slammed that bad.
Have a good detailed message set when you ask for permission to use the user's location. This will let them know why and make sure they accept and allow it.
If you have an FAQ on your website or inside the app, make sure you detail what the icon means and reassure the user that Apple takes battery life very seriously, and so do you.
Outside that, there isn't a lot you can do. Just inform your users best you can and go from there. Good luck.
UPDATE
I found a setting in iOS 6 under Privacy-->Location Services-->System Services all the way at the bottom, there is a user setting to hide the stats bar icon. This frees up some status bar real estate for users that don't want to see it. It doesn't mean the app isn't using location, just the icon is hidden. This is something your users would have to do as overriding this is not an option. At least it is something to share with your users.
Note that the location arrow when using significant location changes is different from the one when you are actively using location services in the background. The best thing you can do is to make sure the user understand how is their location being used, and to teach them to identify the difference between location monitoring (like geofence and significant location changes) and location tracking.

Is it possible to get distance from user location to specific location in background in IOS?

I need to calculate distance from user location to specific location, when the app is in background, and get a local notification based on that.
Background location tracking is totally possible, and I have already done that, but is it possible to execute a block of code, containing some condition checking and based on that update and get a local notification?
I am not getting any proper solution. Is there any way to do so?
Can you help me please?
Yeah, you can definitely do that. I'm doing it in an app right now. Use significant location changes, or regions, as previously suggested, to keep the pressure off the users battery as much as possible.
We observe regions (and significant location changes where regions are not supported by the device) then check a few things and fire off a local notification if needs be.
We started with a basic prototype to prove the concept and I highly recommend that approach as a way to get familiar with the location and notification frameworks.
Start with the Location Awareness Programming Guide. Most everything you need to know is in there. (Most things that aren't in there are simply impossible for an AppStore app.) See also Tracking the User's Location in the iOS App Programming Guide.
The best tool for what you're describing is likely "Shape-Based Regions." You can basically draw a box on a map and say "when the user enters or leaves this box, let me know." If at all possible, this is the tool you should use. It has the least impact on battery life.
If you absolutely cannot solve the problem any other way, it is legal to request background location delivery with startUpdatingLocation (and the appropriate background mode in Info.plist; see the above docs). An app that tracks your route while you hike would be be appropriate for this kind of setup. But you should avoid it if at all possible since it's a major battery drain.
You will want to update for significant locations in the background: http://mobile.tutsplus.com/tutorials/iphone/ios-multitasking-background-location/. Then you will want to create a location notification based on that.
My issue is that I am not sure if you can create a local notification in the background.

Advice on determining close locations while iPhone app in background

I need some advice for a location based iPhone app.
I'm building an app that informs the user of nearby locations. When the app is in the foreground it will use the normal didUpdateToLocation:fromLocation: method (calculates distance between user and place of interest), but when it is in the background I'm not sure what is the best way to do this.
I'm thinking of creating CLRegions from all the places of interest just before the app goes to the background. If the user enters a region the app will do a local notification and inform the user of the place of interest.
Or I could register for CL significant update, calc distance between user and all the places and notify of any close ones. Maybe not the best solution, the OS might not give me enough time to compute close places?
Has anyone any experience doing the same? any advice?
I think you should register for significant locations updates (cell change events), and then do your math on events. You can do anything on the basis of this event. As per my experience, region monitoring is also dependent on cell change events along with some extra computations which you don't need.
However you need to enable background location updates. For which you need to convince Apple that this background location services are required for your app. As Apple docs say that background location services are only for apps who provide turn by turn navigation.
how to enable background location updating
Understanding background tracking of user's location in iOS

Time based GPS location in background (iphone)

I want to create an (game based) iPhone application which sends your GPS location on a specific time (like 3-5 times a day) to a server. I found an apple page explaining some functionality to run in the background like location, music and VOIP.
I need the GPS to be accurate on the meter.
Can someone help me with a small example?
It really depends on your usage of the location. If you monitor actively, kiss the battery of your user goodbye. Very detailed accuracy, even bigger hit to battery. The backgrounding of location is all or nothing as far as accuracy goes.
Less hit, less accuracy is -startMonitoringForSignificantLocationChange. May not be accurate enough for you.
Better depending on usage, region monitoring. Triggers event on entry or exit of defined region.
You don't have the benefit of accuracy and timed location based events. You can do it, but is going to require a lot more effort on your end.
While this is untested, I am planning an app with a similar need. My solution is that on a significant location change, the app will determine what interval exists between the update timestamp, and when I care to know the users location (5pm for instance). If that's below some threshold, it will go into startUpdatingLocation mode (full power, battery draining, which is why that threshold is important) and then, on each location update, check if that target time has passed. if SO, send the update to your server, and go back to monitoring for significant changes. The catch is that if it still requires some movement to trigger the significant change update...so it isn't a perfectly reliable solution, but it may work depending on how you're using the data
You can't "schedule background work". iOS doesn't allow it.
The solution is to set yourself up for notification on significant change (which is some hit to the battery, but it's not horrible), and then only DO anything with that at occasional intervals.