🖥️Interstitial Ad
To receive Interstitial Ads, you need to conform to the MediationAdDelegate
protocol. Once the ad is loaded, it can be presented by calling presentInterstitial(from:)
.
Implementation:
extension MainViewController: MediationAdDelegate {
func onInterstitialAdLoaded(interstitialAd: any MediationInterstitialAd) {
interstitialAd.presentInterstitial(from: self)
interstitialAd.eventDelegate = self
}
func onAdFailedToLoad(error: AdError) {
print("Interstitial Ad request failed with reason \(error.description)")
}
}
Tracking Events:
To track click, impression, and fullscreen events, conform to MediationInterstitialAdEventDelegate
:
extension MainViewController: MediationInterstitialAdEventDelegate {
func ad(didFailToPresentFullScreenContentWithError error: AdError) {
// Handle error when fullscreen content fails to present
}
func adWillPresentFullScreenContent() {
// Prepare for the fullscreen content to present
}
func adDidDismissFullScreenContent() {
// Handle when fullscreen content is dismissed
}
func recordClick() {
// Ad click recorded
}
func recordImpression() {
// Ad impression recorded
}
}
Last updated