💡Tips
- 🚀 Smart Cache automatically manages multi-placement parallel loading and cache comparison — no need to manually manage multiple
MCInterstitialAdinstances- ⚠️
MCInterstitialAdManageris a normal instance class; recommended to hold as a property- 🔧 SDK auto-replenishes after display; simply check
isReady→showAdagain to reuse
#import <MCSDK/MCSDK.h>
@interface SmartCacheInterstitialVC () <MCSmartCacheDelegate>
@property (nonatomic, strong) MCInterstitialAdManager *interstitialManager;
@end
@implementation SmartCacheInterstitialVC
#pragma mark - Load Ad
- (void)loadAd {
if (!self.interstitialManager) {
self.interstitialManager = [[MCInterstitialAdManager alloc] init];
}
// Set delegate before the first loadAd call
self.interstitialManager.delegate = self;
[self.interstitialManager loadAd];
}
#pragma mark - MCSmartCacheDelegate
// At least one ad in cache pool is ready
- (void)smartCacheDidLoadAd:(MCAdInfo *)ad {
}
// All placements failed in first round (mutually exclusive with smartCacheDidLoadAd:)
- (void)smartCacheDidFailToLoadAdWithError:(MCError *)error {
}
// Current round loading completed
- (void)smartCacheDidAdLoadFinished {
}
// Ad displayed successfully
- (void)smartCacheDidDisplayAd:(MCAdInfo *)ad {
}
// Ad closed; SDK auto-replenishes
- (void)smartCacheDidHideAd:(MCAdInfo *)ad {
}
// Ad clicked
- (void)smartCacheDidClickAd:(MCAdInfo *)ad {
}
// Ad display failed
- (void)smartCacheDidFailToDisplayAd:(MCAdInfo *)ad withError:(MCError *)error {
}
// Revenue callback
- (void)smartCacheDidPayRevenueForAd:(MCAdInfo *)ad {
}
// Rewarded video exclusive callbacks — not triggered for interstitial; implement as empty
- (void)smartCacheDidRewardUserForAd:(MCAdInfo *)ad withReward:(MCReward *)reward { }
- (void)smartCacheDidAdVideoStarted:(MCAdInfo *)ad { }
- (void)smartCacheDidAdVideoCompleted:(MCAdInfo *)ad { }
if ([self.interstitialManager isReady]) {
// Pass the current top-level VC; can be nil for SDK default behavior
[self.interstitialManager showAdWithViewController:self];
}
To pass a scene ID or other extra parameters:
if ([self.interstitialManager isReady]) {
[self.interstitialManager showAdWithViewController:self
withExtra:@{kMCAPIPlacementScenarioIDKey: @"your scene id"}];
}
[self.interstitialManager destroyAd];
Call
destroyAdwhen the page or module is destroyed to release cache pool resources and avoid memory leaks. After release,loadAdmust be called again to continue using.
- (void)loadAd {
if (!self.interstitialManager) {
self.interstitialManager = [[MCInterstitialAdManager alloc] init];
}
self.interstitialManager.delegate = self;
// Set load extra parameters; call before loadAd
[self.interstitialManager setLoadExtraParameter:@{
@"userData": @"test_userData"
}];
// Set mediation extra parameters; call before loadAd
[self.interstitialManager setExtraParameter:@{
@"test_extra_key": @"test_extra_value"
}];
[self.interstitialManager loadAd];
}