News.me

Tag Results

2 posts tagged ios

Developing Stories: Paperboy

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!

Much love,
Rob Haining
iOS Developer at News.me

Developing Stories: Custom Label iOS Library

Hello out there news fans!

At a recent Brooklyn iOS Dev Meetup, I talked about our use of Core Text in the News.me iPhone app. In building out the app, I created a subclass of UILabel that takes advantage of Core Text for more robust formatting, such as kerning, mixed fonts, & line height. I thought this might be helpful to other developers out there, so we open-sourced it, and it’s now available on Github.com.

You can use the class much like you would UILabel. I’ve only included the features that we initially needed, but as people use it, it should be pretty straightforward to extend it to incorporate other Core Text features without too much effort.

Here’s a example of using the class:

NMCustomLabel *label = [[NMCustomLabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
label.text = @"Tacos are <b>delicious</b>, <i>seriously</i>";
label.font = [UIFont fontWithName:@"HelveticaNeue" size:12];
label.fontBold = [UIFont fontWithName:@"HelveticaNeue-Bold" size:13];
label.fontItalic = [UIFont fontWithName:@"HelveticaNeue-LightItalic" size:12];
label.kern = -0.5;
label.textColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
label.textColorBold = [UIColor colorWithRed:53/255.0 green:53/255.0 blue:53/255.0 alpha:1.0];
label.lineHeight = 12;
[self.view addSubview:label];

Check out the project & let me know what you think – I’m @tolar on Twitter.

-Rob Haining
iOS Developer at News.me