Prerequisites
You can show interstitials 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.
After Interstitial Explained
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.
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
class MainViewController: UiViewControlelr { var interstitialId:Int32 = -1; ... override func viewDidLoad() { super.viewDidLoad() ... let interstitialAdId = ConfigBuilder.companion.INTERSTITIAL_TEST_R89_CONFIG_ID interstitialId = RefineryAdFactory.shared.createInterstitial( configurationID: interstitialAdId, uiViewController: self, afterInterstitial: { // Here you could present the next view controller. Basically recover app flow // Example self.present(NewViewController(), animated: true) },lifecycleCallbacks: nil) } ... }