💡Tips
- Smart Cache automatically manages parallel loading, caching, and waterfall display across multiple placements — no need to pass a Mediation Unit ID (adUnitId).
- After an ad is closed, the SDK auto-replenishes the cache; developers do not need to manually trigger a second load.
- Smart Cache has its own independent callback channel (
McSmartCacheAppOpenListener), which does not interfere with the standard app open ad callbacks.- App open ads support a
timeoutparameter to control load timeout, and anonDidAdLoadTimeouttimeout callback.- If you need manual control over loading and caching, refer to here
Before loading ads, register the independent Smart Cache app open ad callback:
McSdk.setSmartCacheAppOpenListener(McSmartCacheAppOpenListener(
onDidLoadAd: (McAd ad) {
// At least one ad is ready and can be shown
},
onDidFailToLoadAd: (McError error) {
// All placements failed to load
},
onDidDisplayAd: (McAd ad) {
// Ad displayed successfully
},
onDidHideAd: (McAd ad) {
// Ad closed, SDK auto-replenishes
},
onDidClickAd: (McAd ad) {
// Ad was clicked
},
onDidFailToDisplayAd: (McAd ad, McError error) {
// Ad failed to display
},
onDidAdLoadFinished: () {
// Current load round finished (regardless of success or failure)
},
onDidPayRevenueForAd: (McAd ad) {
// Revenue callback
},
onDidAdLoadTimeout: () {
// Load timeout callback
},
));
Call the following method to trigger Smart Cache app open ad loading. The SDK will automatically manage parallel requests and caching across multiple placements:
McSdk.smartLoadAppOpenAd();
// Set a custom timeout (in milliseconds) (example: 5 seconds)
McSdk.smartLoadAppOpenAd(timeout: 5000);
| Parameter | Type | Default | Description |
|---|---|---|---|
timeout |
int |
-1 |
Load timeout in milliseconds; -1 means not set |
Before showing, use the following method to check whether a cached ad is available:
bool? isReady = await McSdk.smartIsAppOpenAdReady();
if (isReady == true) {
// Ad is ready and can be shown
}
When the ad is ready, call the following method to show the app open ad:
McSdk.smartShowAppOpenAd();
Use the following methods to set extra parameters for fine-grained control over ad behavior:
// Set Extra Parameter (Max only)
McSdk.smartSetAppOpenAdExtraParameter("key", "value");
// Set Local Extra Parameter
McSdk.smartSetAppOpenAdLocalExtraParameter("key", value);