A few weeks ago, we launched a new feature in our iPhone app called Paperboy. Its purpose is simple yet incredibly useful – whenever you leave home, News.me will download the latest news, so it’s ready for you whenever you want to read. Our team is based in New York City, so it’s super helpful for us when we hop on the subway. I wanted to take a few minutes to share the basics of how we did this technically.
There are essentially two items we added to the app for Paperboy. A simple map view lets you drop a pin on your home location, which we store locally. This is a little trickier than simply rendering an MKMapView – you have to create your own class that implements the MKAnnotation protocol in order to make a pin for the map. A UILongPressGestureRecognizer allows you to pick up the pin and drop it elsewhere. For convenience sake, a simple button in the navigation bar lets you drop the pin on your current location, which we store in NSUserDefaults [your location is safe! it never leaves your phone]. Reverse geocoding gives us the address, which shows up in the main Settings view.
If you enable Paperboy, then whenever you close the app, we use geofencing [aka “region monitoring” in Apple parlance] so if you leave a pre-defined area, iOS will wake up News.me & allow us to perform the necessary steps to update your news. But don’t worry, Paperboy won’t kill your battery. From what we can discern, geofencing typically uses the coarser measure of switching cell towers to detect where you are, rather than the more expensive GPS. The downside is that if your home is a short distance from the subway, then Paperboy might not work until you get off. However, the benefits of not killing your battery by enabling the GPS 24/7 outweigh that issue.
To enable Paperboy, simply open News.me up to the Settings section [available via the left sidebar] and select Paperboy. The app will walk you through the rest of the process. From then on, you don’t have to do a thing – News.me will automagically download the news whenever you leave home!
iOS Developer at News.me