Mobile Ads 101: Part II

Monetizing iOS Apps with ONE by AOL: Mobile

Malcom Jones
5 min readJun 13, 2017

Monetization through mobile advertising is a boon in the current app economy and with the ONE by AOL: Mobile platform, you gain access to the world’s top brand advertisers, putting money in your pocket in no time! In Part II of this Mobile Ads 101 series, we will focus on the iOS platform and cover:

  • Integrating the SDK
  • Project Configuration
  • Common Pitfalls

If you need to setup an account with ONE Mobile or integrate with the Android platform, you can check out Part I of this guide.

Part I: Monetizing Android Apps with ONE by AOL: Mobile

This guide will not be a deep dive of iOS development, so some of the app creation portions will be skipped. If you need assistance with this, there are many guides available for both Objective-C and Swift. Additionally, all of the code referenced in this guide can be found on my GitHub.

Disclaimer: Though I work for AOL, this blog is of my own volition and is not an endorsement by AOL of any non-AOL entities that may be cited

SDK Integration

In this guide, the sample application used for examples is written using Objective-C and will be made available on GitHub. It gives a general overview of how ads are integrated, but the details may differ from app to app. Feel free to clone or download this repo and tinker with the app yourself.

Add the SDK and Required Frameworks to Your Project

To begin, head over to the ONE Mobile developer site to download the mobile ad SDK. This site also contains setup documentation, mediation notes, and other useful tidbits. Once downloaded, place the SDK in an easy to find location as you will need to integrate it into your project.

Open your project in Xcode, select the top level directory in Project Navigator, and select the Build Phases tab. Within the the lower left portion of the Link Binary With Libraries subsection, press the + sign and ensure the following frameworks are included:

After adding the frameworks, you can use the Add Other… button in the same window to navigate to where you downloaded the SDK and select MMAdSDK.framework. Once the SDK has been added, ensure it is included in the apps Target Membership. This can be done by clicking on the framework and checking the box next to the app name within the File Inspector inside the Utilities panel (far right column).

Configure Info.plist and Set Linker Flag

The Information Property List, or Info.plist, is a structured text file that contains essential configuration information required to run your app. We will add a few new properties to this list to abide by rules Apple has set for iOS 10+. These include requests for the usage of the calendar, camera, location, photo library, and reminders. Your app requires these for full support of the Interactive Advertising Bureaus MRAID v2.0. Along with this, we will add a property to allow ads to be served with App Transport Security enabled. Both a screenshot and code are provided below:

The last bit of configuration involves setting the Linker Flag. This is done by navigating to the Build Settings tab, scrolling down to the Linking subsection and adding -ObjC as a value for Other Linker Flags.

Set SiteID and Initialize SDK

After finishing the project configuration, we will set our SiteID and initialize the SDK, so that we can begin to request and serve ads. To do this, we will modify our AppDelegate.m to include the following:

Inline Ads

Now that the SDK integration is complete, we will look at serving an inline ad. Inline ads take form as either banner (320x50) or medium rectangles (320x250) in mobile apps and appear inline with other app content. For this guide we will assume the banner is to be displayed in its own BannerViewController, something that will most likely differ in your app. We will use a button to navigate from the HomeViewController to the BannerViewController and another button to request the ad, but we won’t delve into that in this guide.

To do this, we must edit both the BannerViewController implementation and header files. The header will declare a container for the ad content and an inline ad.

Within the implementation file the ad size is set, along with our PlacementID. In this example, the button is also implemented, though in your app the ad will most likely be loaded through a different mechanism.

That completes your first banner ad. Next we will work through interstitials!

Interstitial Ads

Interstitials are fullscreen ads that display over the content of your app. They typically occur during game breaks or before other types of content are shown to the user. We will assume the interstitial is to be displayed in its own InterstitialViewController for this example, something that will most likely differ in your app.

Like banners, we will need to edit both the header and implementation files. Unlike banners, because Interstitials hover above content, we will not need a container to hold the ad. Instead we will create buttons to show and request the ad. In most applications, Interstitials are pre-loaded in the background to enhance the user experience and these buttons will mimic that behavior. In this example, we will only declare an interstitial ad in our header.

Within the implementation file our PlacementID is set and our buttons are implemented. As mentioned before, your app will most likely load the ad through a different mechanism.

With that, you are able to serve Interstitial ads on iOS and will be making money in no time!

Common Pitfalls

  • Ads will be blocked if your app uses ATS, but you don’t set NSAllowsArbitraryLoads to YES

References

--

--