Featured Alert Integration

Featured Alert ads provide an alternative to full screen interstitial, you can preload an alert ad and show it during the normal flow in your app. You can use the InstalFeaturedAlert object and its associated listeners to fetch and display interstitial ads in your app.

Prerequisites

Before integrating featured alert ads in your app, you’ll need to go through the steps in our Getting Started Guide to integrate the SDK into your project.

To have a banner you need to create an AdUnit setting the 'Dimensions' property to 'Mobile Native'.

Choosing mobile adunit dimension

The Instal SDK provides a custom class, InstalFeaturedAlert, that handles fetching and displaying featured alert ads. To ensure a smooth experience, you should prefetch the content as soon as your Activity is created, then display it whether you want.

In the Activity or in the Fragment in which you want to show the ad, declare a InstalFeaturedAlert instance variable:

private InstalFeaturedAlert featuredAlert;

InstalFeaturedAlert provides a listener interface, FeaturedAlertListener, which you’ll use to stay informed about ad lifecycle events.

In your Activity’s onCreate() method, instantiate the InstalFeaturedAlert using the context and the Ad Unit ID you created in the Getting Started.

interstitial = new InstalFeaturedAlert(this, "YOUR_ADUNIT_ID");

If you want to listen to interstitial events you can register a FeaturedAlertListener:

featuredAlert.setListener(new FeaturedAlertListener() {
    @Override public void onFeaturedAlertLoaded(InstalFeaturedAlert interstitial) {
    }

    @Override public void onFeaturedAlertFailed(InstalFeaturedAlert interstitial, NativeErrorCode errorCode) {
    }

    @Override public void onFeaturedAlertShown(InstalFeaturedAlert interstitial) {
    }

    @Override public void onFeaturedAlertClicked(InstalFeaturedAlert interstitial) {
    }

    @Override public void onFeaturedAlertDismissed(InstalFeaturedAlert interstitial) {
    }
});

Now you’re ready to display a featured alert. Displaying the ad takes two steps:

  1. load the featured alert ad (usually in onCreate method) using load method
  2. when you want to display the ad you can invoke show method

You can use isReady method to check if the featured alert is ready and can be shown. Lastly, remember to call destroy() in your Activity or Fragment onDestroy method.

A complete Activity code looks like this (showFeaturedAlert methdo is binded to the click on a button):

public class FeaturedAlertActivity extends Activity {

    private InstalFeaturedAlert featuredAlert;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_featured_alert);
        featuredAlert = new InstalFeaturedAlert(this, "506");
        featuredAlert.load();
    }

    private void showToast(String s) {
        Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
    }

    @Override protected void onDestroy() {
        super.onDestroy();
        featuredAlert.destroy();
    }

    public void showFeaturedAlert(View view) {
        featuredAlert.show();
    }
}