Menu

Interstitial Ads

1. Integration Recommendations

1.1 Displaying Interstitial Ads

  • It is recommended to check if the ad is ready before displaying, and only proceed with the display operation after it's ready
  • If you need to display ads in the ad placement loading success callback (didFinishLoadingADWithPlacementID:), you must first check (UIApplicationState==UIApplicationStateActive) before executing the display method, otherwise it may cause ads to fail to display properly and affect revenue
  • Please try to avoid Presenting other controllers to prevent third-party ad platform SDKs from failing when initiating Present, which could cause ad display failures and affect ad revenue

1.2 Ad Preloading

  • You can call the loading method to request ads in advance of the display scenario (for example, start loading ads when UIApplicationState==UIApplicationStateActive after app launch), so that when you reach the scenario where ads need to be displayed, they can be shown quickly

1.3 Sample Code

  • For detailed sample code, please refer to: InterstitialVC.m in Demo

2. Loading Interstitial Ads

The extra dictionary in this step supports passing in relevant parameters for configuring ads and your custom parameters. You can view more information about extra parameters here.

objc Copy
// Import header file
#import <AnyThinkInterstitial/AnyThinkInterstitial.h>
@interface InterstitialVC () <ATAdLoadingDelegate, ATInterstitialDelegate>

@property (nonatomic, assign) NSInteger retryAttempt; // Retry attempt counter

@end

@implementation InterstitialVC
 
// Placement ID
#define InterstitialPlacementID @"b680a1e0ae7a43"

// Scene ID, optional, can be generated in the backend. Pass empty string if not available
#define InterstitialSceneID @""

#pragma mark - Load Ad
/// Load ad button clicked
- (void)loadAd { 
    NSMutableDictionary * loadConfigDict = [NSMutableDictionary dictionary];
    
    // Optional integration, set loading pass-through parameters
    [loadConfigDict setValue:@"media_val_InterstitialVC" forKey:kATAdLoadingExtraMediaExtraKey]; 

    [[ATAdManager sharedManager] loadADWithPlacementID:InterstitialPlacementID extra:loadConfigDict delegate:self];
}

/// Ad placement loading completed
/// - Parameter placementID: Placement ID
- (void)didFinishLoadingADWithPlacementID:(NSString *)placementID { 
    // Reset retry count
    self.retryAttempt = 0;
}
 
/// Ad placement loading failed
/// - Parameters:
///   - placementID: Placement ID
///   - error: Error information
- (void)didFailToLoadADWithPlacementID:(NSString *)placementID error:(NSError *)error { 
    if (self.retryAttempt >= 3) {
       return;
    }
    self.retryAttempt++;
    
    // Calculate delay time: power of 2, maximum 8 seconds
    NSInteger delaySec = pow(2, MIN(3, self.retryAttempt));

    // Delayed retry loading ad
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
        [self loadAd];
    });
}

3. Displaying Interstitial Ads

  • If you need to display ads in the loading success callback (didFinishLoadingADWithPlacementID:), to avoid ads not displaying properly, please ensure the current app is in the foreground before calling the display method.
  • Scene reach rate statistics, displayed in the backend's Data Reports -> Funnel Analysis Report -> Reach Ad Scene, called before displaying ads.
objc Copy
#pragma mark - Show Ad
/// Display ad
- (void)showAd {
    
    // Scene statistics function, displayed in the backend's Data Reports -> Funnel Analysis Report -> Reach Ad Scene, called before displaying ads. Optional integration
    [[ATAdManager sharedManager] entryInterstitialScenarioWithPlacementID:InterstitialPlacementID scene:InterstitialSceneID];

    // Check if ready
    if (![[ATAdManager sharedManager] interstitialReadyForPlacementID:InterstitialPlacementID]) {
        [self loadAd];
        return;
    }
    
    // Display configuration, Scene passes in the backend scene ID, pass empty string if not available, showCustomExt parameter can pass in custom parameter string
    ATShowConfig *config = [[ATShowConfig alloc] initWithScene:InterstitialSceneID showCustomExt:@"testShowCustomExt"];
 
    // Display ad
    // For fullscreen interstitials, inViewController can pass in the root controller, such as tabbarController or navigationController, to let the ad cover the tabbar or navigationBar
    [[ATAdManager sharedManager] showInterstitialWithPlacementID:InterstitialPlacementID
                                                      showConfig:config
                                                inViewController:self
                                                        delegate:self
                                              nativeMixViewBlock:nil];
}

/// Got display revenue
/// - Parameters:
///   - placementID: Placement ID
///   - extra: Extra information dictionary
- (void)didRevenueForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra { 
}

/// Ad has been displayed
/// - Parameters:
///   - placementID: Placement ID
///   - extra: Extra information dictionary
- (void)interstitialDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra { 
}

/// Ad display failed
/// - Parameters:
///   - placementID: Placement ID
///   - error: Error information
///   - extra: Extra information dictionary
- (void)interstitialFailedToShowForPlacementID:(NSString *)placementID error:(NSError *)error extra:(NSDictionary *)extra { 
}

/// Video playback failed
/// - Parameters:
///   - placementID: Placement ID
///   - error: Error information
///   - extra: Extra information dictionary
- (void)interstitialDidFailToPlayVideoForPlacementID:(NSString *)placementID error:(NSError *)error extra:(NSDictionary *)extra { 
    // Preload next ad
    [self loadAd];
}

/// Video started playing
/// - Parameters:
///   - placementID: Placement ID
///   - extra: Extra information dictionary
- (void)interstitialDidStartPlayingVideoForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra { 
}

/// Video finished playing
/// - Parameters:
///   - placementID: Placement ID
///   - extra: Extra information dictionary
- (void)interstitialDidEndPlayingVideoForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra { 
}

/// Ad has been closed
/// - Parameters:
///   - placementID: Placement ID
///   - extra: Extra information dictionary
- (void)interstitialDidCloseForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra { 
    // Preload next ad
    [self loadAd];
}

/// Ad has been clicked (redirected)
/// - Parameters:
///   - placementID: Placement ID
///   - extra: Extra information dictionary
- (void)interstitialDidClickForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra { 
}

4. Advanced

Fully automatic loading : TopOn has launched a one-stop solution that intelligently determines the timing for preloading and caching the next ad based on the user's usage status and the progress of ad consumption.

Previous
Rewarded Video Ads
Next
Custom Interstitial Ads
Last modified: 2025-07-31Powered by