It seems every app has its own way to handle Geo Location. In many of my cases, your destination is more important then your journey. In iOS 8 Apple provides the CLVisit API specifically designed to provide this type of functionality. Events are generated when you arrive to a location, and another is generated when you leave. This provides a very battery friendly approach to solving place based Geo Location problems.
So how do you use this in Titanium? Like almost any other Titanium requirement you run into there is a module already available. You can download the Ti.GeoVisits module to use this functionality today. I used the example app.js for a week and found that the Visit event fired reliably after I was in a single location for more then 10 minutes and about 5 minutes after leaving a location. This wait time does cause for quick stops such as picking up take away to be missed. Although this approach has trade offs, it virtually has no impact on battery life.
Below is a record of my tests over the last 9 days. I’d encourage you to try the same test yourself. As simulator testing isn’t really a meaningful option for Geo Location apps, I would suggest installing the example app.js and heading out to do a few errands.
Results for the last 9 days:
Image may be NSFW.
Clik here to view.
What does the Ti.GeoVisits API look like?
The full Ti.GeoVisits API is very small consisting of only three methods and four events. The below snippet summaries all of these. For full documentation please visit here for details.
var visits = require('ti.geovisits'); //Fired when Ti.GeoVisits starts visits.addEventListener('started',function(e){}); //Fired when Ti.GeoVisits stops visits.addEventListener('stopped',function(e){}); //Fired when Ti.GeoVisits errors visits.addEventListener('errored',function(e){}); //Fired when Ti.GeoVisits registers a place visited or left visits.addEventListener('visited',function(e){}); //Boolean indicating if module supported visits.isSupported() //Method used to start monitoring for visits visits.startMonitoring(); //Method used to stop monitoring visits visits.stopMonitoring();
Learn more about Ti.GeoVisits on Github at https://github.com/benbahrenburg/Ti.GeoVisits.
You can also download the module GitTio at http://gitt.io/component/ti.geovisits
Image may be NSFW.
Clik here to view.

Clik here to view.
