The app open ads are a special format which main purpose is to allow the monetization of the app load screens.
These ads can be closed anytime and are meant to be shown when the app moves to foreground.
Integration
This ad format can be only integrated through code, by implementing any of the two possible ways of integration that are described below.
Manual
In this kind of integration, it is needed to create an instance of the AppOpenAd class and use the loadAd() and showAd() methods to make the ad load and show on demand. The publisher is the responsible of deciding when the ad must be shown and implement the required logic.
Below you can find a simple integration example:
class MainActivity : Activity() {
private var appOpenAd: AppOpenAd? = null
override fun onCreate(savedInstanceState: Bundle?) {
...
appOpenAd = AppOpenAd(this, "Wortise Ad Unit ID").also {
it.loadAd()
}
}
override fun onDestroy() {
...
appOpenAd?.destroy()
}
fun showAppOpen() {
if (appOpenAd?.isAvailable == true) {
appOpenAd?.showAd(this)
}
}
}
public class MainActivity extends Activity {
private AppOpenAd mAppOpenAd;
@Override
public void onCreate(Bundle savedInstanceState) {
...
mAppOpenAd = new AppOpenAd(this, "Wortise Ad Unit ID");
mAppOpenAd.loadAd();
}
@Override
public void onDestroy() {
...
mAppOpenAd.destroy();
}
public void showAppOpen() {
if (mAppOpenAd.isAvailable()) {
mAppOpenAd.showAd(this);
}
}
}
Also, the AppOpenAd class offers the following additional methods to configure its behaviour:
// Sets if a new ad must be loaded after closing the previous one
appOpenAd.autoReload = true
// Shows an ad immediately if available. Otherwise, requests the load of a
// new ad
appOpenAd.tryToShowAd(activity)
// Sets if a new ad must be loaded after closing the previous one
mAppOpenAd.setAutoReload(true);
// Shows an ad immediately if available. Otherwise, requests the load of a
// new ad
mAppOpenAd.tryToShowAd(activity);
Via Manager
The SDK provides a standard implementation of App Open to facilitate the integration of this ad format.
To perform this kind of integration, it is needed that the app extends the Application class and, inside it, creates an instance of AppOpenManager, just as shown in the example below:
class MyApplication : Application() {
private val appOpenManager by lazy {
AppOpenManager(this, "Wortise Ad Unit ID")
}
override fun onCreate() {
...
appOpenManager.loadAd()
}
}
public class MyApplication extends Application {
private AppOpenManager mAppOpenManager;
@Override
public void onCreate() {
...
mAppOpenManager = new AppOpenManager(this, "Wortise Ad Unit ID");
mAppOpenManager.loadAd();
}
}
With this simple integration, the app will show ads every time there is a transition from background to foreground.
Also, the AppOpenManager class offers the same methods as AppOpenAd to configure its behavior and show ads on demand.
Listener configuration
Like occurs with other formats, a listener can be set to receive the events that happen during the ad lifecycle. For this, it is needed to implement the AppOpenAd.Listener interface just as shown in the example below:
appOpenAd.listener = object : AppOpenAd.Listener() {
override fun onAppOpenClicked(ad: AppOpenAd) {
// Invoked when the ad has been clicked
}
override fun onAppOpenDismissed(ad: AppOpenAd) {
// Invoked when the ad has been dismissed
}
override fun onAppOpenFailedToLoad(ad: AppOpenAd, error: AdError) {
// Invoked when the ad could not be loaded
// (because of an error or no fill)
}
override fun onAppOpenFailedToShow(ad: AppOpenAd, error: AdError) {
// Invoked when the ad could not be shown
}
override fun onAppOpenImpression(ad: AppOpenAd) {
// Invoked when the ad has generated an impression
}
override fun onAppOpenLoaded(ad: AppOpenAd) {
// Invoked when the ad has been loaded
}
override fun onAppOpenShown(ad: AppOpenAd) {
// Invoked when the ad has been shown
}
}
mAppOpenAd.setListener(new AppOpenAd.Listener() {
@Override
public void onAppOpenClicked(@NonNull AppOpenAd ad) {
// Invoked when the ad has been clicked
}
@Override
public void onAppOpenDismissed(@NonNull AppOpenAd ad) {
// Invoked when the ad has been dismissed
}
@Override
public void onAppOpenFailedToLoad(@NonNull AppOpenAd ad,
@NonNull AdError error) {
// Invoked when the ad could not be loaded
// (because of an error or no fill)
}
@Override
public void onAppOpenFailedToShow(@NonNull AppOpenAd ad,
@NonNull AdError error) {
// Invoked when the ad could not be shown
}
@Override
public void onAppOpenImpression(@NonNull AppOpenAd ad) {
// Invoked when the ad has generated an impression
}
@Override
public void onAppOpenLoaded(@NonNull AppOpenAd ad) {
// Invoked when the ad has been loaded
}
@Override
public void onAppOpenShown(@NonNull AppOpenAd ad) {
// Invoked when the ad has been shown
}
});