BannerAdTest

Overview

A minimal app that fetches and displays banner ads. The goal is to test various preloading techniques and debug visibility issues like early auto-play. The UI is designed to mimic Flipboard.

CocoaPods

This project uses Cocoapods to import the iOS GoogleMobileAds SDK. Run the pod update command and then open the generated .xcworkspace file.

Functionality

The app has a bottom bar with three buttons:

Reset

Cancels in-progress fetching/preloading and deletes downloaded ads.

Fetch/Present

Fetches a new ad with the unit ID selected in Settings.

If "Auto-Present" is off, the "Fetch" button will turn into a "Present" button once the ad finishes fetching/preloading.

Settings

Unit ID
The unit ID used for ad fetches.
Preload
Enables a hack that forces banner ads to preload before they appear. Banners are attached to the main window behind other views until they finish preloading, or a max time is reached (5 seconds).
Outside Screen Bounds
Preload the banner outside of the screen's bounds. Specifically, origin.x is set to the screen width.
In Detached Parent View
Preload the banner inside a parent view that's not part of the view hierarchy.
Wait for Completion Event
Preload the banner until it sends a completion event to the app. When disabled the creative will load for a constant amount of time (currently 5 seconds).
Hide Afterwards
Hide the banner after downloading and preloading finishes, and then unhide when presented.
Remove From Parent Afterwards
Remove the banner from its parent view after downloading and preloading finishes.
Inject Visibility Javascript
Inject javascript when the ad is presented to let it know that it's *actually* visible. Creatives can be modified to delay autoplay until this happens.
Auto-Present
Automatically display ads when they finish downloading and preloading. Turn this off to help isolate activity that happens before ads appear.
Manual Impressions
Manually report impressions rather than letting the SDK do it automatically.