Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
afterInterstitial
afterInterstitial
After Interstitial Explained

Info

afterInterstitial is the event that is mandatory to pass to the Factory because is the one in charge of (No matter what) telling you, you can recover app flow. Because normally when you are about to call the show() method you prevent the user from taking any actions that could interrupt the interstitial or break app flow.

So for recovering this app flow and giving back control to the user you can use this event.

...

  • 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.

...

Code Block
languagekotlin
#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

You will receive your Your interstitialConfigId will be provided to you during onboarding process by email, you can also retrieve them from the web interface after login.

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.

...

Code Block
languagekotlin
#MainActivity.kt

private fun createInterstitial()
{
	val interstitialConfigId = 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(
		interstitialConfigId , 
		this,
		afterInterstitial = {
			Log.d("Interstitial", "After Interstitial")
		},
		lifecycleCallbacks = lifecycleEvents
	)

}
Info

You will receive your Your interstitialConfigId will be provided to you during onboarding process by email, you can also retrieve them from the web interface after login.

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.

...