Implement interstitial ads in iOS
Implement interstitial ads in your iOS app. Load ad content, display it through Objective-C or Swift code, and use a delegate to handle ad events.
Read time 1 minuteLast updated a month ago
Interstitial ad load example
Use to construct a load request with the placement ID, mediation metadata, and optional ad markup for bidding, then pass it to . The completion block receives the loaded instance on success. Retain it, as it's required to show the ad later, or an error object on failure.
UADSLoadConfigurationBuilderUADSInterstitialAd.load()UADSInterstitialAdAds expire if they aren't shown within a set time after the SDK loads them. Assign on the loaded ad instance to detect this. Attempting to an expired rewarded ad fails, which is especially important to catch since rewarded ads are often preloaded and held until the user requests a reward. Use the callback to clear your stored reference and issue a new call so a fresh ad is ready when needed.
onAdExpiredshow()load()@property (strong) UADSInterstitialAd *interstitialAd;UADSLoadConfigurationBuilder *builder = [[UADSLoadConfigurationBuilder alloc] initWithPlacementId:placementId];builder = [builder withMediationInfo:self.mediationInfo];builder = [builder withAdMarkup:bidResponse];[UADSInterstitialAd load:[builder build] completion:^(UADSInterstitialAd *ad, id<UnityAdsError> error) { if (error) { NSLog(@"Failed: %ld %@", (long)error.code, error.message); } else { __weak typeof(self) weakSelf = self; ad.onAdExpired = ^(UnityAd *expiredAd) { weakSelf.interstitialAd = nil; // reload here }; }}];
Interstitial ad show example
Call on the retained instance, passing a built with the presenting view controller, and a . The delegate provides callbacks for each stage of the ad's lifecycle: when the ad displays, when the user interacts with it, when it closes, and if an error occurs.
show()UADSInterstitialAdUADSShowConfigurationUADSInterstitialShowDelegateshowDidStartshowDidClickshowDidCompleteshowDidFail@interface MyDelegate : NSObject <UADSInterstitialShowDelegate>@end@implementation MyDelegate- (void)showDidStart:(UADSInterstitialAd *)unityAd {}- (void)showDidClick:(UADSInterstitialAd *)unityAd {}- (void)showDidComplete:(UADSInterstitialAd *)unityAd with:(UADSShowFinishState)finishState {}- (void)showDidFail:(UADSInterstitialAd *)unityAd error:(id<UnityAdsError>)error {}@endUADSShowConfigurationBuilder *builder =[[UADSShowConfigurationBuilder alloc] init];builder = [builder withViewController:viewController];[self.interstitialAd show:[builder build] delegate:delegate];
Next steps: To improve your implementation, refer to the Implement rewarded ads in iOS documentation.