Interstitial Ads
Interstitial ads are full-screened image or video ads that draw full attention of users.
Implementing View Controller
In the view controller that will present the ad view as subview,
-
add this property
GFPInterstitialAdManager *adManager
-
and implement this delegate protocol
GFPInterstitialAdManagerDelegate
- Objective-C
- Swift
// MyViewController.h
@import GFPSDK;
@interface MyViewController : UIViewController <GFPInterstitialAdManagerDelegate>
@property (nonatomic) GFPInterstitialAdManager *adManager;
@end
// MyViewController.h
import GFPSDK
class MyViewController : UIViewController, GFPInterstitialAdManagerDelegate {
private var adManager : GFPInterstitialAdManager?
}
GFPInterstitialAdManager
Initializing GFPInterstitialAdManager
Initialize GFPInterstitialAdManager
in your view controller, say, in viewDidLoad:
.
-
Provide
GFPInterstitialAdManager
with video ad Ad Unit ID (essential) andGFPAdParam
(optional) for better ad performance. -
Make sure to set
GFPInterstitialAdManagerDelegate
onGFPInterstitialAdManager
Use GFPInterstitialAdManager
instance for only single ad request, than create another for the next ad request. It is designed to manage the life cycle of only single ad.
- Objective-C
- Swift
- (void)viewDidLoad {
[super viewDidLoad];
GFPAdParam *adParam = [[GFPAdParam alloc]init];
adParam.yearOfBirth = 1990;
adParam.gender = GFPAdParamGenderTypeMale;
...
self.adManager = [[GFPInterstitialAdManager alloc] initWithUnitID:@"UnitID" adParam:adParam];
self.adManager.delegate = self;
self.adManager.requestTimeoutInterval = 60;
}
override func viewDidLoad() {
super.viewDidLoad()
let adParam = GFPAdParam()
adParam.yearOfBirth = 1990
adParam.gender = .male
...
self.adManager = GFPInterstitialAdManager(unitID: "UnitID", adParam: adParam)
self.adManager?.delegate = self
self.adManager?.requestTimeoutInterval = 60
}
Loading Ad
Since AppLovin and IronSource runs on a singleton to for loading ads, you can preload only one ad at a time, per Ad Unit ID.
- Objective-C
- Swift
[self.adManager load];
self.adManager?.load()
Showing Ad
On succefully loading ad, GFPInterstitialAdManagerDelegate
provides ad through interstitialAdManager:didLoadAd:
.
Than show the interstitial ad at the desired moment, using GFPInterstitialAdManager show:
Loaded ads don't have to be shown as soon as being loaded. Thus, preload ads for app's performance.
Be mindful, though, that loaded ads are valid for a only limited time. ex) for DFP, FAN: 60 mins.
- Objective-C
- Swift
[self.adManager show:self];
self.adManager?.show(self)
Additional Configurations
Ad Request Timeout (per GFPInterstitialAdManager)
Set timeout (seconds) for ad requests. GFPInterstitialAdManager
will call interstitialAdManager:didFailWithError:responseInfo:
on timeout. Default is 60 seconds.
- Objective-C
- Swift
self.adManager.requestTimeoutInterval = ...
self.adManager?.requestTimeoutInterval = ...
Ad Request Timeout (global configuration on GFPAdManager)
Set global interstitial timeout (seconds) for ad requests. GFPInterstitialAdManager
will call interstitialAdManager:didFailWithError:responseInfo:
on timeout. Default is 60 seconds.
- Objective-C
- Swift
[GFPAdManager adConfiguration].interstitialAdRequestTimeout = ...
GFPAdManager.adConfiguration().interstitialAdRequestTimeout = ...
GFPInterstitialAdManagerDelegate
Load Events
On Load Success
- Objective-C
- Swift
- (void)interstitialAdManager:(nonnull GFPInterstitialAdManager *)manager didLoadAd:(nonnull GFPInterstitialAd *)interstitialAd {
...
}
func interstitialAdManager(_ manager: GFPInterstitialAdManager, didLoad interstitialAd: GFPInterstitialAd) {
...
}
On Load Failure
- Objective-C
- Swift
- (void)interstitialAdManager:(nonnull GFPInterstitialAdManager *)manager didFailWithError:(nonnull GFPError *)error responseInfo:(nullable GFPLoadResponseInfo *)responseInfo {
...
}
func interstitialAdManager(_ manager: GFPInterstitialAdManager, didFailWithError error: GFPError, responseInfo: GFPLoadResponseInfo!) {
...
}
LifeCycle Events
On Start Showing Ad
- Objective-C
- Swift
- (void)interstitialAdManager:(nonnull GFPInterstitialAdManager *)manager didStartAd:(nonnull GFPInterstitialAd *)interstitialAd {
...
}
func interstitialAdManager(_ manager: GFPInterstitialAdManager, didStart interstitialAd: GFPInterstitialAd) {
...
}
On Finish Showing Ad
- Objective-C
- Swift
- (void)interstitialAdManager:(nonnull GFPInterstitialAdManager *)manager didCompleteAd:(nonnull GFPInterstitialAd *)interstitialAd {
...
}
func interstitialAdManager(_ manager: GFPInterstitialAdManager, didComplete interstitialAd: GFPInterstitialAd) {
...
}
On Dismiss
- Objective-C
- Swift
- (void)interstitialAdManager:(nonnull GFPInterstitialAdManager *)manager didCloseAd:(nonnull GFPInterstitialAd *)interstitialAd {
...
}
func interstitialAdManager(_ manager: GFPInterstitialAdManager, didClose interstitialAd: GFPInterstitialAd) {
...
}
On Click
- Objective-C
- Swift
- (void)interstitialAdManager:(nonnull GFPInterstitialAdManager *)manager wasClickedAd:(nonnull GFPInterstitialAd *)interstitialAd {
...
}
func interstitialAdManager(_ manager: GFPInterstitialAdManager, wasClickedAd interstitialAd: GFPInterstitialAd) {
...
}
For Google DFP = 7.X.X click events are not supported.