App Open Ads

This guide explains how to integrate app open ads into a Flutter app.

App open ads are a special ad format intended for publishers wishing to monetize their app load screens. App open ads can be closed at any time, and are designed to be shown when your users bring your app to the foreground. App open ads automatically show a small branding area so users know they're in your app.

AppOpen Ad management in Dart code is handled through the CASAppOpen class, which extends the shared AdScreenInstance class used for all fullscreen ads. The AdScreenInstance class, inherits from the base AdInstance class, which is common for all CAS ad formats. The AdScreenInstance is displayed as an Overlay on top of all app content and is positioned statically; therefore, it cannot be added to the Flutter widget tree.

CAS provides an option to enable autoReload to simplify your app logic. Before using the ad, you should decide whether to enable autoReload, or manually manage each ad loading cycle in your code.

When autoReload is enabled, a new ad will be automatically loaded after each display, and loading failures will trigger automatic retry attempts.

final bool isAutoReloadEnabled = true;

Manual load mode (autoReload: false ) is useful when you only need to show a single ad per app screen, and the screens change frequently.

Below is a diagram showing the ad lifecycle and how autoReload (isAutoload) affects it.

Diagram

Create Ad instance

The following example creates and loads an app open ad:

class AppScreenState extends State<AppScreen> {
  late CASAppOpen _appOpenAd;
  
  @override
  void initState() {
    super.initState();
    
    _appOpenAd = CASAppOpen.createAndLoad( 
      autoReload: isAutoReloadEnabled, 
      onAdLoaded: (AdScreenInstance ad) { 
        // Called when an ad is successfully loaded. 
        print('$ad loaded');  
      },  
      onAdFailedToLoad: (AdInstance ad, AdError error) { 
        // Called when an ad load failed. 
        print('$ad failed to load: ${error.message}.'); 
      }, 
    ); 
  }
}

Ad content may take some time to load after creating an ad instance. To ensure the ad displays instantly when needed, create the ad instance in advance. Use the onAdLoaded callback to be notified when the ad is ready for display.

CAS provides functionality to create and preload multiple ad instances in advance, ensuring uninterrupted sequential ad delivery. Mediation ads are loaded in order for each created instance.

Ad content callbacks

CASAppOpen has several optional callbacks for the ad lifecycle. These callbacks can be set either as arguments in the createAndLoad() function or later via the properties of the ad instance.

_appOpenAd.onAdFailedToShow = (AdInstance ad, AdError error) { 
  // Called when the ad failed to show full screen content. 
  print('$ad failed to show: ${error.message}.');  
  // TODO: dismissAppLoadingScreen();
};  
_appOpenAd.onAdShowed = (AdScreenInstance ad) {  
  // Called when the ad showed the full screen content.
  print('$ad showed');  
  // TODO: showAppLoadingScreen();
};  
_appOpenAd.onAdImpression = (AdInstance ad, AdContentInfo contentInfo) { 
  // Called when an impression occurs on the ad. 
  print('$ad impression');  
};  
_appOpenAd.onAdClicked = (AdInstance ad) {  
  // Called when a click is recorded for an ad.
  print('$ad clicked');  
};  
_appOpenAd.onAdDismissed = (AdScreenInstance ad) { 
  // Called when the ad dismissed full screen content. 
  print('$ad dismissed');  
  // TODO: dismissAppLoadingScreen();
};
  • Read more about AdContentInfo structure in Impression Level Data.
  • When an error occurs during ad impression, executed the onAdFailedToShow only. In this case the onAdDismissed will not be executed, since the impression is not considered successful.

Show Ad

App open ads help you monetize your app's loading screen, when the app first launches and during app switches, but it's important to keep best practices in mind so that your users enjoy using your app. It's best to:

  • Show your first app open ad after your users have used your app a few times.
  • Show app open ads during times when your users would otherwise be waiting for your app to load.
  • If a user returns to your app after having left it by clicking on an app open ad, it makes sure they're not presented with another app open ad.

You can choose when to show the ad by calling show():

_appOpenAd.show()

If the ad is not ready at that moment, the onAdFailedToShow callback will be triggered with a reason provided in the AdError.

You have the option to check isLoaded if it's required by your app's logic.

bool isAdLoaded = await _appOpenAd.isLoaded();

Auto Show mode

CAS provides the option to automatically show a loaded ad when the user returns to the app. To enable this behavior, set the autoShow argument to true.

_appOpenAd = CASAppOpen.createAndLoad(
  autoShow: true, 
  ...
)

Release ad resource

Be sure to release ad resources if you’re no longer going to use the ad instance.

  @override
  void dispose() {
    _appOpenAd.dispose();
    super.dispose();
  }

It may be useful to store the ad instance in static memory for reuse across multiple screens. This way, you don't need to call dispose() and can show the already loaded ad without delay.

Manual reload Ad

When you want to manually control ad loading, use the load() function on the created ad instance to retry loading with the same configuration.

_appOpenAd.load();

Mute Ad sounds

Indicates if the application’s audio is muted. Affects initial mute state for fullscreen ads. Use this method only if your application has its own volume controls (e.g., custom music or sound effect muting).

CASMobileAds.setAdSoundsMuted(true);

Not muted by default.

Cold starts and Loading screens

There is a delay between when you request an ad and when you receive an ad to show. If you do not design your app well, the user may briefly see your app and then be surprised by an out-of-context ad. Prevent this bad user experience. You can handle cold starts by showing a loading screen before any app content, and then showing the ad after the loading screen. If your app shows any app content after the loading screen, do not show the ad.

Best Practices

  • When an app open ad is not yet loaded (i.e. on cold start), load it first. Load any other ad formats later so that you avoid loading them in parallel with the app open ad. Loading multiple ad formats in parallel is not good for the device’s resources or for ad demand SDKs.
  • If you have a loading screen under the app open ad, and your loading screen completes loading before the ad is dismissed, you may want to dismiss your loading screen in the onAdDismissed and onAdFailedToShow callbacks.
  • Wait a variable number of days after initial install to show on cold start.
  • Only show an ad if the user backgrounds the app for a certain amount of time (i.e. 30 seconds).
  • If you show a cold start ad, do not show soft launch app open ads or interstitials for a certain amount of time.
  • Include a call-out to the user that tells them they will see an ad in the Splash/Loading screen. For example: “Watch an ad from their sponsor while the app loads.”

Complete example