adsLib V2: How to implement it and maximize your revenues

As announced a couple of days ago, adsLib V2 for Corona SDK is finally here.

What’s new?

Everything. It’s an entirely new library, written from scratch, that replaces our existing library in ALL of our templates.
You can now specify more than 2 ad providers, we’ve included PlayHaven support and fixed a series of bugs in banner positioning that affected a few providers in the previous library.
There’s a fallback system, so that when an ad fails to load, you can decide which other provider should take its place. And if that one fails again, it can fallback to another provider.
You can choose in which order the specific ad should choose its provider, be it a normal, numerical order, or a random one, based on specific percentage for each provider. You can also decide to keep the order between sessions, instead of always starting back from the first one.
Plus, each provider now accepts IDs for Android and iPhone within the same code.

How does it work?

Let’s take a look at the code. As always, you first need to place the various providers IDs you wish to use inside the adsLib.lua file. Here’s an example concerning chartboost:

There’s a separation between “Android” devices, and “iPhone” ones (which includes all iOS based devices).

After that’s taken care of, all that’s left is to setup the actual ads you wish to display. In this example, we’re going to setup an interstitial ad, that follows a random order based on percentage for each provider, and a banner ad, that follows a numerical order that’s kept between game sessions.
In our templates, this code is usually found in setupFile.lua, or in main.lua.

The first thing you might notice, is that here again we separated “Android” and “iPhone”. You can choose different providers for each, and different kind of ads.
Also notice how each ads we set, starts with a specific id. In this case “main_menu” and “during_game”. You can choose any id you like, and that will later be used to show the ad.
Check the commented lines for info about each specific parameter.

Now it’s time to initiate adsLib. This is the last bit of code we need in order to do so:

The activeAdsProviders table is required to choose which ads providers must be initiated. Here all the providers you setup in the adsSettings table must be included.
Now all our ads will initiate their session as soon as we start the app. All we have left is to make the ads we setup appear in our app.

We can do so by calling adsLib.showAd(“ad_id”); anywhere in our application. For example, we can call the ad with id “main_menu” in the createScene function of our menuScene.lua file:

We can do the same for our banner ad with id “during_game”, in the gameScene.lua file. To remove the banner ad, we can then simply call adsLib.removeAd(“during_game”); in the exitScene function of our gameScene.lua file, so that the ad is removed once we aren’t in the game scene anymore.

Our templates already include a set of ads in specific scenes, but if you wish to customize them, or to implement this library in any other project of yours, you can do so by following the examples above.

The adsLib V2 library will soon be updated to support a couple more features, for example the ability to define an URL from which the app can download the latest ads settings for your game, allowing you to fine tune your source of revenues without deploying a new app update to the stores. Meanwhile, you can start playing around with it in all our templates (new versions with the adsLib V2 should be up within a couple of hours from this blog post).


  1. This is great!!! Thank you very much for this update. It would be great if you could have an optional way to incorporate the ChartBoost Plugin from Gremlin Interactive for the Corona SDK Pro license holders who may wish to use this plugin in connection with your library. Thanks for considering.

    • It’s already on our to-do list, together with Vungle (;

      • Great news!!! Thank you very much.

  2. I second Kerem. This is a fantastic library and worth 1000X the price of the template! Quick questions:

    1- Does the library support Chartboost “more apps”?

    2- Any idea when the library will support the “Gremlin” Chartboost plugin?

    Thanks again for bringing this library to the Corona community :)


    • Thank you for your kind words (;
      Regarding your questions, as of now we don’t support any “More Games” button (we’ll definitely think about it though).
      As for the Gremlin Interactive plugin, it’s definitely coming, but we need just a bit more time to properly included everything we want in this update first (mainly more ads providers and a couple more features of adsLib v2).

  3. Ultra clean code


  1. Swing Copters Template V1.0 Now Available To All Our Members | Ragdog Studios - […] everything you need to reproduce one of the most recent mobile hits, it includes our new Ad Mediator library …