-
Notifications
You must be signed in to change notification settings - Fork 8
Integrating Interstitial Ad
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;
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.
Swift
...
// 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
)
}
Objective-C
...
// Create a property for ads mediator.
@property (nonatomic, strong) AFPageViewControllerMediator *mediator;
...
- (void)viewDidLoad {
[super viewDidLoad];
// This is your UIPageViewController implementation.
[self configurePageViewController];
// And to display ads you just need to add this line of code.
self.mediator = [[AFPageViewControllerMediator alloc] initWithMasterTagId:MsterTagId
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.
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.
Swift
...
// 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
)
}
Objective-C
...
// Create a property for ads mediator.
@property (nonatomic, strong) AFCollectionViewMediator *mediator;
...
- (void)viewDidLoad {
[super viewDidLoad];
// This is you UICollectionView implementation.
[self configureCollectionView];
// And to display ads you just need to add this line of code.
self.mediator = [[AFPageViewControllerMediator alloc] initWithMasterTagId:MsterTagId
adFrequency:5
collectionView:self.collectionView
presentingViewController: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.
For a complete example of how to integrate Adform interstitial ads into your application, check out the sample app.
Basic integrations
- Integrating Inline Ad
- Integrating Full Screen Overlay Ad
- Integrating AdHesion Ad
- Integrating Interstitial Ad
- Video Ad Integration
- Debug mode
- Troubleshooting
Advanced integrations
- Advanced Inline Ad Integration
- Integrating Inline Ads in UITableView
- Advanced Full Screen Overlay Ad Integration
- Advanced Interstitial Ad Integration
- Instream Video Ads
Other
- Adding Custom Values
- Adding Keywords
- Adding Key Value Pairs
- Adding Search Words
- Location Tracking
- Security
- Ad Tags
- Header Bidding
- Changing ADX Domain
- Specifying banner loading behaviour
- Customizing in app browser
- GDPR
- US Privacy
- Localization
- In app deeplinks
Mediation adapters