Table of Contents | ||
---|---|---|
|
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.
Anchor | ||||
---|---|---|---|---|
|
...
interstitial explained
Info |
---|
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 actionacts.
So consider a scenario where a button click triggers an Interstitial and, subsequently, the NewActivity
NewViewController
is launched or presented from MainActivitythe MainViewController.
Load
Load then wait for the user to take an action on your app
Code Block | ||
---|---|---|
| ||
class MainViewController: UiViewControlelr {
var interstitialId:Int32 = -1;
...
override func viewDidLoad() {
super.viewDidLoad()
...
let interstitialConfigId = 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)
}
...
} |
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
Some event takes place in your app, such as a button press, tab change opening a link, or screen transition.
Note |
---|
If the Interstitial hasn’t Loaded yet or failed to load when you call |
Code Block | ||
---|---|---|
| ||
class MainViewController: UiViewControlelr { var interstitialId:Int32 = -1; ... override func viewDidLoad() { super.viewDidLoad() ... interstitialId = RefineryAdFactory.shared.createInterstitial(...) ... // Set up an action on uiButton to display loaded interstitial with it's interstitialId. uiButton.addAction(UIAction(handler: {_ in RefineryAdFactory.shared.show(index: interstitialId) }), for: .touchUpInside) } ... } |
Load &
...
show on
...
the event
Warning |
---|
This will increase the time it takes to show the interstitial and then recover app flow. Because its making the Ad Request ad request when the user takes the action. You should use the previous approach where we make the request and store the ad ID Id for instant showing it when the user performs the actions. This is how we use Interstitial we use in Demos demos because it’s pretty good at showing that it works but nothing more. |
Code Block | ||
---|---|---|
| ||
class MainViewController: UiViewController { ... override func viewDidLoad() { super.viewDidLoad() ... // Set up an action on uiButton to display loaded interstitial with it's interstitialId. uiButton.addAction(UIAction(handler: {_ in createInterstitial() }), for: .touchUpInside) } ... } |
Code Block | ||
---|---|---|
| ||
class MainViewController: UiViewControlelr { override func viewDidLoad() { ... } ... func createInterstitial(){ let interstitialConfigId = ConfigBuilder.companion.INTERSTITIAL_TEST_R89_CONFIG_ID interstitialId = RefineryAdFactory.shared.createInterstitial( configurationID: interstitialConfigId, uiViewController: self, afterInterstitial: { // Here the navigation flow continus self.present(NewViewController(), animated: true) }, lifecycleCallbacks: InterstitialEventListenerDelegate(viewController: self)) } } class InterstitialEventListenerDelegate : InterstitialEventListener { let viewController:LunchScreenViewController init(viewController: LunchScreenViewController) { self.viewController = viewController } // 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 func onLoaded() { RefineryAdFactory.shared.show(index: viewController.interstitialId) } override func onFailedToLoad(error: R89LoadError) { RefineryAdFactory.shared.show(index: viewController.interstitialId) } ... } |
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 to RefineryAdFactory.shared.createInterstitial(:afterInterstitial)
and holds the same functionality as OnClose
with special cases.