Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 6 Next »

Prerequisites

  1. https://refinery89.atlassian.net/wiki/x/A4DVSQ

  2. https://refinery89.atlassian.net/wiki/x/BgDOSQ

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 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)
        }
      ...
    }

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.

Show On Button Press

Some event takes place in your app, such as a button press, tab change opening a link, or screen transition.

If the Interstitial hasn’t Loaded yet or failed to load when you call show() method, afterInterstitial event will be called to recover app flow.

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 Event

This will increase the time it takes to show the interstitial and then recover app flow.

Because its making the Ad Request when the user takes the action. You should use the previous approach where we make the request and store the ad ID for instant showing it when the user performs the actions.

This is how we use Interstitial we use in Demos because it’s pretty good at showing that it works but nothing more

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)
        }
      ...
    }

  • No labels