I'm trying to decide between Apple's significant location change services and start / stopping the location manager regularly myself. This is what Apple says about it :
Gathering location data is a power-intensive operation. It involves powering up the onboard radios and querying the available cell towers, Wi-Fi hotspots, or GPS satellites, which can take several seconds. Leaving the standard location service running for extended periods can drain the device’s battery. (The significant-change location service drastically reduces battery drain by monitoring only cell tower changes, but the service works only on devices with cellular radios.) For most applications, it is usually sufficient to establish an initial position fix and then acquire updates only periodically after that. If you are sure you need regular position updates, you should use the significant-change location service where you can; otherwise, you should configure the parameters of the standard location service in a way that minimizes its impact on battery life.
So, my usecase is to be able to alert the user if they are near (~1km) a certain location. Should I just skip Significant location updates and poll the location manager every 10 minutes or so myself?
Thanks,
Teja.
Consider using the region monitoring API. It's the only way to do what you're locking for while supporting iOS 4 multitasking. Be warned, however, it's a bit temperamental, particularly if you want to monitor many regions.
I would avoid the significant location change API if you just want to know when a user is near a specific location.
Related
Simultaneous use of Standard Location Service and Significant Location Change.
I’m trying to develop App using Location Information.
Can Standard Location Service and Significant Location Changes be used together?
I currently use Standard Location Service in the main.
However, Even when the app is in not running state, I want to use a location service in my app.
So I am trying to use not only Significant Location Changes but also Standard Location Service.
Then some questions came up,
When Standard Location Service and Significant Location Changes are used simultaneously, what`s happening?
Do the two functions work simultaneously?
Does only one function work? Assumption
If only one function works, which one will work?
If the two functions work simultaneously, Is there a problem with battery consumption?
The significant-change location service offers a more power-friendly alternative for apps that need location data but do not need frequent updates or the precision of GPS. This can run when the application is in foreground, background or not running state. So if your application does not need very frequent locations updates then you can use this. FYI it delivers location updates to your app only when the user’s position changes by a significant amount, such as 500 meters or more.
Standard location service will work when the application is running in foreground state and background state(when the back ground mode for location is enabled) only. As soon as the application will get killed(by user or iOS) the standard location service will stop working.
For this you have to set the significant location change service which will wake your application in the background and provide the location updates to your application.
So you should analyse the functionality in your application and check the required frequency of the location and decide your implementation.
Both do not work simultaneously. Only one will work according to the application's requirement and application state.
Both services will work according to the previously mentioned.
They do not work simultaneously. But if you choose significant location changes to implement then it will be far more battery efficient but the location fetching accuracy will be very low.
Some of my users ran into an issue where they couldn't fetch the location using Location Service.
In the screenshots they sent me, i noticed that the battery level was really low, like 2-5%.
My question is, does iOS stop the location service when the device is running out of battery?
Thanks
Enabling Low Power Mode (the one that turns the battery icon yellow) does several things to reduce the battery usage of your device. This probably includes the accuracy and refresh rate of the GPS.
If you're requesting a location with a high level of accuracy, the system might either take too long and timeout or just decide not to fulfill that request since the hit on the battery would be too much.
does iOS stop the location service when the device is running out of battery
It certainly might. The GPS is one of the highest power draws of all the sensors. Turning it off would make a lot sense. See also Apple's own statements about low power mode:
https://support.apple.com/en-us/HT205234
Note that if this is the case, it would hardly be an issue with your app. Your app might use a lot of battery, which could be a problem; but if location services itself is affected, all map/navigation apps would be affected.
I would like you to give me your feedback on which method consumes less battery.
My app will run in the background and will wake up with location changes, so I would like to use the method that consumes less battery.
Any ideas on which one it is?
Thanks
Neither of these choices is responsible for more or less battery consumption.
In order for your app to be notified of any location update, regardless of whether it is for a region change or a significant location change, you must specify in your app's Info.plist file that you will require location-services in the background.
There are actually two relevant choices for location services: location-services or gps.
In order NOT to drain the user's battery, choose location-services. If you say your app needs gps background services, you WILL drain the battery because this will cause the GPS hardware (assuming it is present) to be enabled, and THAT is the cause of battery drain. When you specify location-services, the device uses the cellular radio (which is on anyway, assuming you have an iPhone) to pinpoint the location instead. Not as accurate as gps, but most apps don't need GPS accuracy. (If you do, then use gps, of course, but know the consequences vis a vie battery life.)
I recently wrote a test app all about this (and I wrote about it last week here) and what I found was there was no significant battery drain when I had several regions setup for monitoring and I specified location-services as a required background service.
Question: Does the Significant Location Change background service drain battery easily? I'm trying to track longitude latitude readings when the there is a Significant Location Change. However, before starting, I just want to make sure that this doesn't drain the battery.
If the Location service described above does not drain battery, can someone recommend a way to store the location changes that would be battery efficient. My initial thought was to store the longitude latitude points locally on iPhone and then send the information to the server on a much less frequent basis (2 hours). Anyone have a better approach?
I'm trying to build a simple location tracking app that is battery efficient. Thanks all.
Significant location changes do not take any extra battery draining because the device uses information that the GSM system is working with anyway. It has to keep track of signal strength readings of multiple cell towers all the time anyway. Your app is only started/woken when certain criteria are met.
To conserve battery you have to watch two subsystems:
make sure that CoreLocation is turned off when you don't need it, GPS takes the most
make sure that you send location data to your server in bursts, to allows the transmitter to power down.
2 hrs might be too much because the user might be terminating the app and then the updates would never be made. Or if you implement an offline queue, they would only be sent next time the app is started. But that depends on your specific scenario.
It should be cellular tower triangulation, and not GPS location, which is more than enough for your needs. It shouldn't be battery heavy at all.Same with uploading the location, do it rarely and you are fine.
Edit: Confused Core Location with Significant Location.
I have and issue where i want to collect GPS data periodically, say every 5 minutes. I can do this no problem when the app is running. However i wanted to know if there is a standard way to do this using the iPhone 'multitasking'. I can collect the data using the background process using the constant updating model and the significant changes, but these are either too battery intensive or to inaccurate.
I am in the process at looking the the NSLocalNotification, how ever i'm not sure the keeps the app in a background state while checking location periodically, i think this only has the option of launching the app.
Thank in advance.
There is no way to perform periodically GPS acquisition (each 5 min for example).
From Apple documentation:
Tips for Conserving Battery Power
Receiving and transmitting data using the radios of an iOS-based device require more power than any other operation on the device. Because Core Location relies on these radios to determine the user’s location, you should use location services judiciously in your applications. Most applications do not need location services to be running all the time, and so turning off those services is the simplest way to save power.
Turn off location services when you are not using them. This may seem obvious but it is worth repeating. With the exception of navigation applications that offer turn-by-turn directions, most applications do not need location services to be on all the time. Turn location services on just long enough to get a location fix and then turn them off. Unless the user is in a moving vehicle, the current location should not change frequently enough to be an issue. And you can always start location services again later if needed.
Use the significant-change location service instead of the standard location service whenever possible. The significant-change location service provides significant power savings while still allowing you to leave location services running. This is highly recommended for applications that need to track changes in the user’s location but do not need the higher precision offered by the standard location services.
Use lower-resolution values for the desired accuracy unless doing so would impair your application. Requesting a higher accuracy than you need causes Core Location to power up additional hardware and waste power for precision you are not using. Unless your application really needs to know the user’s position within a few meters, do not put the values kCLLocationAccuracyBest or kCLLocationAccuracyNearestTenMeters in the desiredAccuracy property. And remember that specifying a value of kCLLocationAccuracyThreeKilometers does not prevent the location service from returning better data. Most of the time, Core Location can return location data with an accuracy within a hundred meters or so using Wi-FI and cellular signals.
Turn off location events if the accuracy does not improve over a period of time. If your application is not receiving events with the desired level of accuracy, you should look at the accuracy of events you do receive and see if it is improving or staying about the same over time. If accuracy is not improving, it could be because the desired accuracy is simply not available at the moment. Turning off location services and trying again later prevents your application from wasting power.