App Open Ads - cleveradssolutions/CAS-Flutter GitHub Wiki

⚡ Before you start
Make sure you have correctly Initialize CAS.



This guide is intended for publishers integrating app open ads using the CAS Android SDK.

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.

Pros compared to Interstitial ads:

  • Much faster ad loading.
  • End user-friendly interface.

Cons:

  • Only Google Ads (Admob) is supported.

Create an instance

You can use one of the following static methods to create App Open Ads:

  • A managerId is a unique ID number assigned to each of your ad placements when they're created in CAS. If you haven't created an CAS account and registered an app yet, now's a great time to do so at cleveradssolutions.com. In a real app, it is important that you use your actual CAS manager ID.
appOpenAd = CASAppOpen.create(managerId);
appOpenAd = CASAppOpen.create(manager);

Load an ad

To load an App Open ad, call the CASAppOpen object's loadAd() method. This method accepts parameter:

  • LoadAdCallback callback An object that handles events for loading an app open ad.
appOpenAd.load(LoadAdCallback(
  onAdLoaded: () {
    // Called when an app open ad has loaded.
  },
  onAdFailedToLoad: (AdError adError) {
    // Called when an app open ad has failed to load.
  },
));

Note

Attempting to load a new ad from the onAdFailedToLoad() method is strongly discouraged. If you must load an ad from onAdFailedToLoad(), limit ad load retries to avoid continuous failed ad requests in situations such as limited network connectivity.

Handle fullscreen callback events

A contentCallback field that takes an AppOpenAdListener anonymous class to handle events such as when the ad is presented, fails to present, or when it is dismissed.

appOpenAd.contentCallback = AppOpenAdListener(
  onShown: (AdImpression? adImpression) {
    // Called when ad is shown.
  },
  onShowFailed: (String? message) {
    // Called when ad fails to show.
  },
  onClicked: () {
    // Called when a click is recorded for an ad.
  },
  onImpression: (AdImpression? adImpression) {
    // Called when ad impression is registered.
  },
  onClosed: () {
    // Called when ad is dismissed.
  },
);

Note

  • When an error occurs during ad impression, executed the onShowFailed only. In this case the onClosed will not be executed, since the impression is not considered successful.
  • If a user returns to your app after having left it by clicking on an app open ad (onClicked), it makes sure they're not presented with another app open ad.

Check the ad availability

You can ask for the ad availability directly by calling the following function:

Future<bool> adLoaded = appOpenAd.isLoaded();

Show the ad

You can show ad by calling the following function:

appOpenAd.show();

Note

Once you’ve successfully call show(), you will have shown your user an App Open Ad.
In the case you want to serve another App Open Ad, you must repeat loadAd() to request an additional ad.

Cold starts and loading screens

The documentation thus far assumes that you only show app open ads when users foreground your app when it is suspended in memory. "Cold starts" occur when your app is launched but was not previously suspended in memory.

An example of a cold start is when a user opens your app for the first time. With cold starts, you won't have a previously loaded app open ad that's ready to be shown right away. The delay between when you request an ad and receive an ad back can create a situation where users are able to briefly use your app before being surprised by an out of context ad. This should be avoided because it is a bad user experience.

The preferred way to use app open ads on cold starts is to use a loading screen to load your game or app assets, and to only show the ad from the loading screen. If your app has completed loading and has sent the user to the main content of your app, do not show the ad.

Note

In order to continue loading app assets while the app open ad is being displayed, always load assets in a background thread.

Best practices

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 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 onClosed() and onShowFailed() methods.

Sample use case


🔗 Done! What’s Next?

⚠️ **GitHub.com Fallback** ⚠️