Table of Contents | ||
---|---|---|
|
Prerequisites
You can show interstitial in many different places but we are going to discuss not where but how to show it. But first let’s explain a crucial concept.
Anchor | ||||
---|---|---|---|---|
|
Info |
---|
So for recovering this app flow and giving back control to the user you can use this event. |
Load & Show the Ad
Consider To reiterate, this is not passed as a separated object like the other Events because is mandatory to handle what happens after an Interstitial is closed. This is invoked in the SDK when:
Everything went right and the user just closed the full screen ad.
The ad hasn't loaded yet and you tried to show it.
The ad has been Invalidated and you tried to show it. Gets invalidated when:
Fails to load.
Already shown.
Too Long without showing it.
The ad failed to show.
Load → wait → Show on Event
This way is much more efficient since the show is immediate as the user performs the action.
So consider a scenario where a button click triggers an Interstitial and, subsequently, the NewActivity
is launched from MainActivity.
Load
Load then wait for the user to take an action on your app
Code Block | ||
---|---|---|
| ||
#MainActivity.kt->onCreate() val interstitialConfigId = ConfigBuilder.INTERSTITIAL_TEST_R89_CONFIG_ID val activityToShowOver = this var interstitialId = RefineryAdFactory.createInterstitial( interstitialConfigId, activityToShowOver, afterInterstitial = { // Here you could load the next activity or fragment. Basically recover app flow Log.d("Interstitial", "After Interstitial") //Example val newActivityIntent = Intent(this, NewActivity::class.java) startActivity(newActivityIntent) }) |
Info |
---|
Your They can be many or none depending on your requests, if you need one or more please request them to your account manager or technical account manager. |
Show On Button Press
First some Some event takes place in you app, such as a button press, tab change or opening a link, screen transition.
Note |
---|
If the Interstitial hasn’t Loaded yet or failed to load when you call |
Code Block | ||
---|---|---|
| ||
#MainActivity.kt->onCreate() //Example of a button press findViewById<Button>(<YOUR_BUTTON_ID>).setOnClickListener { RefineryAdFactory.show(interstitialId) } |
Load & Show on
...
Event
Warning |
---|
This will increase the time it takes to show the interstitial and then recover app flow. |
...
Code Block | ||
---|---|---|
| ||
#MainActivity.kt private fun createInterstitial() { val interstitialAdIdinterstitialConfigId = ConfigBuilder.INTERSTITIAL_TEST_R89_CONFIG_ID val lifecycleEvents = object : InterstitialEventListener { /* * We need to call show on the onLoaded event and on the OnFailedToLoad event, * this is to show the ad in both cases so the afterInterstitial event is called */ override fun onLoaded() { RefineryAdFactory.show(interstitialId) } override fun onFailedToLoad(error: R89LoadError) { RefineryAdFactory.show(interstitialId) } .... } interstitialId = RefineryAdFactory.createInterstitial( interstitialAdIdinterstitialConfigId , this, afterInterstitial = { Log.d("Interstitial", "After Interstitial") }, lifecycleCallbacks = lifecycleEvents ) } |
Info |
---|
Your They can be many or none depending on your requests, if you need one or more please request them to your account manager or technical account manager. |
Lifecycle Events
You can subscribe to these events with the same method but passing a new object as a parameter. Details about this object can be found in the Reference.
OnClose is not present because we have an after interstitial event that is mandatory to pass as a parameter and holds the same functionality that OnClose with special cases.
...
This is not passed as a separated object like the other Events because is mandatory to handle what happens after an Interstitial is closed. This is invoked in the SDK when:
...
Everything went right and the user just closed the full screen ad.
...
The ad hasn't loaded yet and you tried to show it.
...
The ad has been Invalidated and you tried to show it. Gets invalidated when:
Fails to load.
Already shown.
Too Long without showing it.
...
.