Overview
Interstitial ads are ads displayed in full-screen format covering the entire app screen. They are suitable for display at natural transition points in the app, such as game level transitions or content page changes.Features
- Immersive ads covering the entire screen
- Maintained until user explicitly closes
- Supports both image and video ads
- High visual attention
Use test unit ID in development environment:
PUBLIC_TEST_UNIT_ID_INTERSTITIALImplementation Steps
Implement interstitial ads in 4 steps:- Initialize - Create AdropInterstitialAd instance
- Set Delegate - Set delegate to receive ad events
- Load Ad - Request and receive ad
- Show Ad - Display ad on screen
UIKit Implementation
Basic Implementation
isLoaded Property
Property to check if the ad is loaded. It’s recommended to check this value before callingshow().
Delegate Implementation
SwiftUI Implementation
In SwiftUI, get the view controller of the screen withUIViewControllerRepresentable and pass it to show(fromRootViewController:).
From SDK 1.16.1, the ad appears in the window that contains the view controller you pass. If your app opens multiple windows (iPad, iPhone Duo split view), a view controller found through
UIApplication.shared.connectedScenes.first may belong to another window. The ad then appears in that window, or fails to show when that window is inactive.Get the Screen’s View Controller
Add this helper once and reuse it on every screen that shows ads. It places a zero-size view controller behind the screen and keeps a weak reference to it.Method 1: ViewModel Pattern
Delegate Methods
Required Methods
(AdropInterstitialAd) -> Void
Called when ad is received successfully. You can call
show() at this point to display the ad.(AdropInterstitialAd, AdropErrorCode) -> Void
Called when ad fails to load. You can check the cause of failure through the error code.
Optional Methods
(AdropInterstitialAd) -> Void
Called when ad impression is recorded.
(AdropInterstitialAd) -> Void
Called when user clicks the ad.
(AdropInterstitialAd) -> Void
Called just before the interstitial ad is displayed. You can pause animations, etc.
(AdropInterstitialAd) -> Void
Called immediately after the interstitial ad is displayed on screen.
(AdropInterstitialAd) -> Void
Called just before the interstitial ad is dismissed.
(AdropInterstitialAd) -> Void
Called immediately after the interstitial ad is dismissed. Good time to preload the next ad.
(AdropInterstitialAd, AdropErrorCode) -> Void
Called when ad fails to show. You can check the cause of failure through the error code.
Closure Callbacks
As an alternative to delegates, you can use closure-based callbacks.If both a delegate and closures are set, both will be called.
Best Practices
1. Preload Ads
Preload ads before displaying them to improve user experience.2. Appropriate Display Timing
Display ads at natural transition points in your app.3. Reload After Dismissal
Preload the next ad after the ad is dismissed.4. Error Handling
Implement error handling for ad load failures.5. Frequency Capping
Limit how often ads are displayed to avoid being too intrusive.Next Steps
Rewarded Ads
Improve user engagement with rewarded ads
Banner Ads
Implementing banner ads
Targeting Settings
User attributes and contextual targeting
Reference
API reference documentation