App Open
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)
}
}
}
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)
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()
}
}
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 onAppOpenRevenuePaid(ad: AppOpenAd,
data: RevenueData) {
// Invoked when the ad has generated revenue
}
override fun onAppOpenShown(ad: AppOpenAd) {
// Invoked when the ad has been shown
}
}
Última actualización