AppOpen (Google)

Integrate AppOpen ads

App open ads are a special fullscreen ad format (created by Google) intended for publishers wishing to monetize their app loading screens (“splash 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.

Create Placement

You need to create the AppOpen placement as soon as the app becomes active in the applicationDidBecomeActive() method in your AppDelegate.

To create an instance of AppOpenAdPlacement, use the following API:

private AppOpenAdPlacement placement = AATKit.createAppOpenAdPlacement("<PLACEMENT_NAME>");

Listen to Callbacks (Optional)

Through the use of AppOpenPlacementListener, you can listen to the different placement callbacks.

placement.setListener(this);

Request Ad

After creating the placement you need to start placement auto-reloading to get an ad as soon as possible.

@Override
protected void onResume() {
    super.onResume();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityResume(this);

    // Start autoreloading the placement.
    placement.startAutoReload();
}

Request Ad (In Loading Screen)

App Open Placement is meant to monetize your App Loading screen, so the most proper place to display the Ad is in your own Loading Activity, so while the user is waiting for your App to be ready to use. If AATKit has successfully obtained an Ad you should display it before sending the user to the main content. To do so you will need your LoadingActivity to implement the AppOpenPlacementLitener interface:

private AppOpenAdPlacement placement = AATKit.createAppOpenAdPlacement("<PLACEMENT_NAME>");

@Override
protected void onResume() {
    super.onResume();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityResume(this);

    // Set placement listener to listen to the callbacks
    placement.setListener(this);
    // Start autoreloading the placement.
    placement.startAutoReload();
}

@Override
protected void onPause() {
    // [IMPORTANT] Stop placement autoreload
    placement.stopAutoReload();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityPause(this);
    super.onPause();
}

// AppOpenPlacementListener
@Override
public void onPauseForAd(@NonNull Placement placement) {
    // Ad has been displayed on the screen
}

@Override
public void onResumeAfterAd(@NonNull Placement placement) {
    // Back to the app
}

@Override
public void onHaveAd(@NonNull Placement placement) {
    // The placement has loaded a new ad
}

@Override
public void onNoAd(@NonNull Placement placement) {
    // The placement could not load a new ad
}

After the user closes the Ad you should send the user to your app's main content, you will get notified when the fullscreen ad is closed in onResumeAfterAd listener method.

Display Ad

You should display that ad at the start of the app session by calling show() method. If the AppOpen placement has a ready ad, It will present it.

placement.show();

Complete Code Example

private AppOpenAdPlacement placement = AATKit.createAppOpenAdPlacement("<PLACEMENT_NAME>");

@Override
protected void onResume() {
    super.onResume();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityResume(this);

    // Start autoreloading the placement.
    placement.startAutoReload();
    // Display loaded ad (if available)
    placement.show();
}

@Override
protected void onPause() {
    // [IMPORTANT] Stop placement autoreload
    placement.stopAutoReload();
    // [IMPORTANT] Notify AATKit about activity lifecycle
    AATKit.onActivityPause(this);
    super.onPause();
}

Loading Screen

The above code example assumes that you only show app open ads when users foreground your app after it is suspended in memory. So, if the user launches the app either for the first time since booting or after killing the application, the app will never have a ready ad.

In this case, it’s preferred to use a loading screen (that might be used to load your assets) and only show the ad from the loading screen (Only if the ad is ready and the loading screen is still active) to avoid surprising the user with an ad while using your app.

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 resumeAfterAd() callback of the AppOpenPlacementListener.

Last updated