-
Notifications
You must be signed in to change notification settings - Fork 8
Advanced Interstitial Ad Integration
AFPageViewControllerMediator
can display ads at a certain frequency or at specific pages. To show ads with frequency, you just have to use the convenience initializer initWithMasterTagId:adFrequency:pageViewController:
and set desired ad frequency. The mediator will ensure that ads are displayed as often as specified by the frequency.
Swift
// To display ads every 5-th page, pass 5 as ad frequency.
self.mediator = AFPageViewControllerMediator(masterTagId: masterTag, adFrequency: 5, pageViewController: self.pageViewController)
Objective-C
// To display ads every 5-th page, pass 5 as ad frequency.
self.mediator = [[AFPageViewControllerMediator alloc] initWithMasterTagId:MsterTagId
adFrequency:5
pageViewController:self.pageViewController];
To display ads on certain pages you have to implement AFPageViewControllerMediatorDelegate
protocol. This protocol has two methods which ask if ad should be displayed after (pageViewControllerMediator:shouldShowAdAfterViewController:
) and before (pageViewControllerMediator:shouldShowAdBeforeViewController:
) specific view controller. You can implement these methods to decide when to display ads. The first method decides if ads should be displayed when the user is scrolling forward and the other one when the user is scrolling back.
Swift
func pageViewControllerMediator(_ mediator: AFPageViewControllerMediator!, shouldShowAdAfter viewController: UIViewController!) -> Bool {
// Here you can decide if the ad should be displayed after the view controller.
return true
}
func pageViewControllerMediator(_ mediator: AFPageViewControllerMediator!, shouldShowAdBefore viewController: UIViewController!) -> Bool {
// Here you can decide if the ad should be displayed before the view controller.
return true
}
Objective-C
- (BOOL)pageViewControllerMediator:(AFPageViewControllerMediator *)mediator shouldShowAdAfterViewController:(UIViewController *)viewController {
// Here you can decide if the ad should be displayed after the view controller.
return TRUE;
}
- (BOOL)pageViewControllerMediator:(AFPageViewControllerMediator *)mediator shouldShowAdBeforeViewController:(UIViewController *)viewController {
// Here you can decide if the ad should be displayed before the view controller.
return TRUE;
}
The mediator can display ads at a certain frequency or at specific pages. To show ads with frequency, you just have to use convenience initializer initWithMasterTagId:adFrequency:collectionView:presentingViewController:
and set desired ad frequency. The mediator will ensure that ads are displayed as often as specified by frequency.
Swift
// To display ads every 5-th page, pass 5 as ad frequency.
self.mediator = AFCollectionViewMediator(
masterTagId: masterTag,
adFrequency: 5,
collectionView: collectionView,
presenting: self
)
Objective-C
// To display ads every 5-th page, pass 5 as ad frequency.
self.mediator = [[AFPageViewControllerMediator alloc] initWithMasterTagId:MsterTagId
adFrequency:5
collectionView:self.collectionView
presentingViewController:self;
To display ads on certain pages you have to implement AFCollectionViewMediatorDelegate
protocol. This protocol has one method which asks if the ad should be displayed at the index path (collectionViewMediator:shouldShowAdAtIndexPath:
). You can implement this method to decide when to display ads.
Swift
func collectionViewMediator(_ mediator: AFCollectionViewMediator!, shouldShowAdAt indexPath: IndexPath!) -> Bool {
// Here you can decide if the ad should be displayed at the index path.
return true
}
Objective-C
- (BOOL )collectionViewMediator:(AFCollectionViewMediator *)mediator shouldShowAdAtIndexPath:(NSIndexPath *)indexPath {
// Here you can decide if the ad should be displayed at the index path.
return YES;
}
AFCollectionViewMediator
uses different internal index paths to communicate with the collection view. Therefore, if you want to access collection view cells or index paths directly from collection view, e.g. use methods indexPathsForSelectedItems:
indexPathsForVisibleItems
, selectItemAtIndexPath:
or cellForItemAtIndexPath:
you should first convert the index paths you have to the inner index paths (used by the mediator to communicate to collection view) or outer index paths (outer index path, used by the mediator to communicate with data source provided by you). Only then use the index paths to interact directly with the collection view. For index path conversion use AFCollectionViewMediator
methods: indexPathFromOuterIndexPath:
, outerIndexPathFromIndexPath
.
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