Menu

App-Open

💡Tips

  • Before calling any ad API, make sure McSdk.initialize() has completed initialization; otherwise the call will be ignored
  • App Open ads support a load timeout mechanism, controllable via the timeout parameter to set the maximum wait time (in milliseconds) for a single load
  • Suitable for Warm Start scenarios: show an ad when the user returns from the background to the foreground, increasing ad impressions
  • It is recommended to preload the next ad in onAdDisplayedCallback / onAdHiddenCallback to ensure ads are available during warm start

dart Copy
const String _adUnitId = "your mediation unit id";

void initAppOpenAd() {
  McSdk.setAppOpenAdListener(McAppOpenAdListener(
    onAdLoadedCallback: (McAd ad) {
      // Ad loaded successfully
    },
    onAdLoadFailedCallback: (String adUnitId, McError error) {
      // Ad failed to load
      // App Open ads rely on the timeout mechanism to manage load pacing; no manual retry needed
    },
    onAdDisplayedCallback: (McAd ad) {
      // Ad displayed successfully
      // Preload next ad (recommended for warm start)
      // McSdk.loadAppOpenAd(_adUnitId);
    },
    onAdDisplayFailedCallback: (McAd ad, McError error) {
      // Ad failed to display
      // Preload next ad (recommended for warm start)
      // McSdk.loadAppOpenAd(_adUnitId);
    },
    onAdClickedCallback: (McAd ad) {
      // User clicked the ad
    },
    onAdHiddenCallback: (McAd ad) {
      // Ad closed
      // Preload next ad (recommended for warm start)
      // McSdk.loadAppOpenAd(_adUnitId);
    },
    onAdRevenuePaidCallback: (McAd ad) {
      // Ad revenue callback
    },
    onAdLoadFinishedCallback: (String adUnitId) {
      // Current load round finished (fires regardless of success or failure)
    },
    onAdLoadTimeoutCallback: (String adUnitId) {
      // Load timeout callback, fires when loading exceeds the specified timeout duration
    },
  ));

  // Initiate load request, timeout is in milliseconds
  McSdk.loadAppOpenAd(_adUnitId, timeout: 5000);
}

📌 The timeout parameter controls the maximum wait time for a single load. When exceeded, the onAdLoadTimeoutCallback callback is triggered. Pass -1 to disable timeout.

📌 For warm start scenarios, it is recommended to uncomment the preload code to automatically load the next ad after an ad is displayed or closed.


dart Copy
Future<void> showAppOpenAd() async {
  final isReady = await McSdk.isAppOpenAdReady(_adUnitId);
  if (isReady == true) {
    McSdk.showAppOpenAd(_adUnitId);
  } else {
    McSdk.loadAppOpenAd(_adUnitId);
  }
}

3. Set Custom Parameters

dart Copy
// Set Extra Parameter, only for Max
McSdk.setAppOpenAdExtraParameter(_adUnitId, "key", "value");

// Set Local Extra Parameter
McSdk.setAppOpenAdLocalExtraParameter(_adUnitId, "key", value);

// Parameters must be set before loadAppOpenAd() and apply to all subsequent load requests

Previous
Interstitial
Next
Rewarded-Video
Last modified: 2026-06-25Powered by