The Only Lars

Byte-sized adventures in iOS software development

Stupid Easy iOS Ad Mediation With LARSAdController 3.0


When I originally built LARSAdController, I was building it to fulfill a very specific purpose for my first app (Droid Light): leverage a singleton to serve a single ad instance for iAds using best practices, and serve AdMob ads as a backup when iAds (stellar) inventory ran dry. Since then, I’ve expanded it to support multiple devices, as well as multiple orientations, all while being super-easy to integrate.


Version 3.0 now supports all of the things that the old version did, but now allows you much more flexibility and freedom in how you would like your ads to be used.

Major Changes from v2.x

A detailed changelog of what has changed can be found in the LARSAdController 3.0 release-candidate post, but here’s the tl;dr version:

  • TOL as a new class prefix
  • Arbitrary ad networks
  • Ad network priority
  • Conversion to ARC
  • Presentation types
  • Pinning locations (have ad reside at the top of your view)
  • Easy setup with a new view controller subclass TOLAdViewController
  • Optional verbose debug logging for development
  • Upgrade base iOS dependency to iOS 5.0

Easy Integration

So let’s get started integrating your ad with some ad networks. If you would like to use Google as your ad vendor, then you will need to go ahead and setup an account with them and have your publisher ID handy.

This is going to be so stupid simple it’s going to blow your mind1.

LARSAdController 3.0 RC

Edit Jan 10, 2013: Since publishing this post, LARSAdController v3.0 has been pushed to the master branch on github!

I’ve been working hard on refactoring LARSAdController 2.0 into a more modular and maintainable state over the past few months. I think it’s finally in a place that could warrant some final testing from other developers before being merged into the master branch.

Let’s take a look at what’s changed:

A New Class Prefix

I’ve been using the class prefix LARS for all of my open-source classes. While this really is short and unique, it’s always felt pretty egotistical to have my name plastered all over my classes. This is just how I feel from this side of the keyboard. Does it look the same from the user’s end? Let me know what you think.

Anyway, I’ve migrated new classes to the new TOL prefix, for @TheOnlyLars. This feels more anonymous and I haven’t seen the prefix used by anyone else before, yet. I’d love to know if someone well known is using the TOL class prefix. If I feel like I like this prefix better, I may just start using it for everything.

I also like that it sounds like “toll”. I have grand visions of having some cool project named TOLBooth, TOLRoad, or TOLHouse. I can’t think of practical project ideas to put those names on, however.

Modular Ad Networks

The big new feature for this release is modular ad networks. Ad junkies will know this as ad mediation. AdMob has an ad mediation framework, so does AdWhirl, MobClix, and others. This is my implementation. The actual mediation logic is in a single .h/.m file pair. The other files support the ad networks. I feel this is a very lightweight implementation compared to other company’s mediation platforms, not to mention it’s open source so you can peek under the hood to see how another developer has solved a problem.

Right now I’ve built ad network adapters for iAds and AdMob ads. These are the only two ad networks that I use in Droid Light, so I don’t know much about others, and these two seem to be the most popular for banner ads on iOS.

House Ads

A third planned adapter I’m particularly excited about is an adapter for “house” ads, but I have not started on it as of yet. House ads would basically amount to an image and a tap destination that you supply yourself. It’s an ad for yourself.

Don’t Forget the “C” in Objective-C: C Declarations

It’s been awhile. I blame my bike and the Thanksgiving Steam sale. If you’re seriously reading this, then it is statistically likely your productivity was at some point affected by Steam’s Thanksgiving sale.

This post is going to primarily serve for my personal purposes to bookmark some articles and blog posts I’ve been referencing to remind myself some of the basics of C declarations while working in, as well as how they relate to Objective-C. This is going to be one of those posts that I’m probably going to add to as time goes on. This is also kind of a prelude to a future similarly-themed bookmarking post for myself on ARC.

Note also that while using very specific type and storage qualifiers can be unnecessary for most Objective-C development, Apple pretty much threw everyone into the fray when they introduced such common identifiers such as __block with Grand Central Dispatch. It got even better when ARC was introduced. You’ll see…

Variable Declaration

The Problem

This is something that was either not immediately obvious to me when writing software, or I simply was never formally shown this. I’m not entirely sure how I never picked up on this in all my years of writing software (even informally), but here it is:

This: const NSString * myString is totally not the same as this: NSString * const myString.

iOS 6 “Smart” App Banners

When iOS 6 was announced, one of the lesser features was a “Smart” App Banner that displayed unobtrusively over your webpage and displayed an app that users could directly download on the app store from your webpage. After the keynote, I forgot to investigate the documentation about it all through the iOS 6 Beta and never really heard much about it until the GM release of iOS 6. So I went to check out how to do this thinking it was going to be super-involved, at least html-wise.

Are you ready?

<meta name="apple-itunes-app" content="app-id=379660205"/>

That’s it. Add this meta tag to the <head> section of your website template. Then, replace your app ID with the one iTunes Connect displays for your app in the app details.

If you’re on an iOS 6 device, then you will see this at the top of this webpage:

When the user taps on the banner, iOS will take the user to the app store to complete the transaction. When the user returns to your website, a progress indicator will display showing the progress of the app install. After the download and installation is complete, the banner’s action will launch the app.

You can even go one or two steps further and pass in affiliate link information when your app gets downloaded or have information passed to your app on first launch in the app’s url handling delegate method. More detail can be found in the documentation on Apple’s website.

If you’re running an Octopress blog and aren’t sure where to make this change to include it in your blog, mosey on over to source\_includes\head.html and add it in with the rest of the <meta tags.

I’ve installed it on my blog with a link to Droid Light, since that’s the only personal app I have that actually moves any units on the app store.

Go Forth and Build

In the US today, it is what our government has deemed “Labor Day”. This holiday is marked (at least from what I see here in Texas) by beer, boats, and barbecue. If you live here in Austin - it also means you better not expect to get in your car and get anywhere anytime soon. If you work at any retail establishment, it means you’re being paid 1.5x today and will have the busiest day second only to black friday (according to Wikipedia).

I, however, simply enjoyed family, food, and taking my bike to the park to get dirty on the trails. Still really out of shape, but that’s kind of to be expected when you spend 8-12 hours a day hunched in front of a computer 5-6 days out of the week.

So now that I’ve had my rest, I’m going to get back to doing what I do best - building.

Now go forth and build - I don’t care what it is. Bonus points for being the one who broke it to begin with.