Versions Compared

Key

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

...

Code Block
languageswift
    class MainViewController: UiViewControlelr {
      var interstitialId:Int32 = -1;
      ...
      override func viewDidLoad() {
        super.viewDidLoad()
        ...
          let interstitialAdIdinterstitialConfigId = 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 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.

Note

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.

Code Block
languageswift
class MainViewController: UiViewControlelr {
      ...
      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)
        }
      ...
    }