iOS Location Tester
The goal of this iOS project is to provide a sample app to play with the 3 different types of location monitoring offered by the CoreLocation framework:
- Location Monitoring – This foreground-only monitoring is the most powerful (and potentially battery consuming) mode that you can use to monitor the user’s location
- Significant Location Change – This foreground and background monitoring indicates when a user location significantly simply by firing when (s)he changed to a different cell tower. As this realies on the cell tower, this monitoring cannot be simulated and it requires a device with a cell connectivity (i.e. iPhone or 3G iPage)
- Region monitoring – Since iOS 4, CoreLocation offers region monitoring both in the fore and background. This app. uses the region monitoring the user location in a more precise way (and with different hardware requirement) than the significant location change (see bellow)
Why should I use this application?
If you are like me and want to add some location awareness – including some monitoring of the user location when you app is in the background – you might enjoy this application to walk / drive around and test how the CoreLocation framework behave and play with the configuration to fine something that suit your needs. The background aspect is the main one that pushed me to develop this test app. as the simulator mainly offers support for the foreground location monitoring and not much for the significant change and region monitoring. In other words, this application will allow you to go outside and be able to test the monitoring and see what’s happening.
I just hope it will save you time and allow you to focus on the development of your app.
This application is offered to you “as is”, without any guarantee or licensing requirement. You can just go ahead, slice / copy / distribute the code. I would just greatly appreciated if you can point any bugs or improvement. Note that this application has not and is not intended to be approved by Apple. It has not been senctioned by Apple and it does not offer any guarantee in the quality or precision of the location monitoring it perfoms. On the contrary, its goal is to help you experience how the CoreLocation behave in real-life conditions.
How do I use this app?
Using this application should be, I hope, simple and intuitive. Just open it with Xcode, run it on your favorite device (to install it), configure the monitoring you want to use, take it outside for a walk, bike ride or a drive and see the location changes either by looking at the monitoring logs within the application or by enabling local notifications when running in the background. All of this is control by the two tabs of the app.:
|This tab exposes the configuration of the 3 differents monitorings and this is where you can start and stop them||This tab show you the monitoring logs and it let you reset the logs or email it to yourself|
Note that you can also access the logs from iTunes by selecting this app. in the File Sharing section of the Apps tab when your device is selected.
Using Region Monitoring to track a user’s location
As I mentioned earlier, the Location Monitoring is not available in the background, so how can we track the user location when the app. is running in the background in a more precise fashion than what the significant change offers? While thinking about this challenge, I came up with the idea to use the region monitoring. The concept is super simple:
- when the app. starts monitoring the user’s location, use the location monitoring to find the current user location
- uses this location as the center point for a region with a specified radius and accuracy
- register this region for monitoring
- whenever the system fires the fact that the user left the region, record the current location and establish a new region around it
- replace (by using the same identifier) the region to monitor
This application let you play with this technique, by defining the radius for the region as well as the accuracy. This should allow you to find a proper compromise between your desire for precision and the preservation of the battery life.
Note that, when run in the background, the accuracy is not guaranteed by the OS and you, most likely, will not get perfect results where each new region is centered at the exact point of exit of the previous region:
Instead, you will get something like the following where regions are spread over the path of the user: