Integrating Interstitial Ad - adform/adform-ios-sdk GitHub Wiki
Basic Interstitial Ad Implementation
If you want to display large resizable ads between pages in your application, you have to use AFAdInterstitial class. You cannot use AFAdInline, because it has a fixed size, cannot resize and ads served to it usually have standard sizes, like 320x50 or 728x90. AFAdInterstitial class is a subclass of AFAdInline. Therefore, this ad placement type has all the controls as the inline ad. It should be used to add ads to UIPageViewController or any other custom implementation of pager using UICollectionView or UIScrollView. AFAdInterstitial can only be reloaded after being displayed to the user.
To simplify the implementation of in-page ads you can use AFPageViewControllerMediator or AFCollectionViewMediator helper classes. If these helper classes do not fulfill your needs feel free to modify them as you may need or implement your own ads mediator/controller. You can find these helper classes here;
Display page ads in UIPageViewController
The easiest way to display ads in UIPageViewController is to use AFPageViewControllerMediator provided by Adform. You just have to initialize it set the master tag, ads frequency, and the page view controller, everything else is handled by the mediator.
...
// Create a property for ads mediator.
private var mediator: AFPageViewControllerMediator?
...
override func viewDidLoad() {
super.viewDidLoad()
// This is your UIPageViewController implementation.
configurePageViewController()
// And to display ads you just need to add this line of code.
self.mediator = AFPageViewControllerMediator(
masterTagId: masterTagId,
adFrequency: 5,
pageViewController: self.pageViewController
)
}
As you can see in the example, to use AFPageViewControllerMediator you don't need to modify your current page view controller implementation, just add the mediator.
Display page ads in UICollectionView
Easiest way to display page ads in UICollectionView is to use AFCollectionViewMediator provided by Adform. You just have to initialize it set master tag, ads frequency and the collection view, everything else is handled by the mediator. For AFCollectionViewMediator to work properly your UICollectionView should be fullscreen, e.g. display only one cell per page.
...
// Create a property for ads mediator.
private var mediator: AFCollectionViewMediator?
...
override func viewDidLoad() {
super.viewDidLoad()
// This is you UICollectionView implementation.
configureCollectionView()
// And to display ads you just need to add this line of code.
let mediator = AFCollectionViewMediator(
masterTagId: masterTagId,
adFrequency: 5,
collectionView: self.collectionView,
presenting: self
)
}
As you can see in the example code above, to use AFCollectionViewMediator you don't need to make any modifications to your collection view implementation, just add the mediator on top of it.
Sample code:
For a complete example of how to integrate Adform interstitial ads into your application, check out the sample app.