Versions Compared

Key

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

The wrapper is an empty UIView that can be created and linked from the XCode’s UI builder or be created programmatically in the view controller.

Link

...

in the XCode’s UI builder.

Here is a short example that demonstrates the wrapper usage by creating it in the XCode’s UI Builder.

...

The adContainer adWrapper is linked with the AdViewController, and provided to the RefineryAdFactory.shared.createBanner(:wrapper,...) method as a wrapper parameter.

Code Block
languageswift
class AdViewController: UIViewController {
    
    @IBOutlet var adContaineradWrapper:UIView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let configurationID = ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID...
        // Passing the adContaineradWrapper wrapper to the SDK, so it can display a banner ad in it.
        RefineryAdFactory.shared.createBanner(wrapper:
adContainer,                              wrapper: adWrapper, 
                configurationID: configurationID,
           ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID,
                                  lifecycleCallbacks: nil)
    }
}

Now the ad will be placed inside the adContainer.

Create

...

programmatically in the UIViewController

Here is the equivalent example that demonstrates how to create a wrapper programmatically and display an ad in it.

Code Block
languageswift
class AdViewController: UIViewController {
    
    let adContainer:UIView = {
        let viewadWrapper = UIView()
    
   view.translatesAutoresizingMaskIntoConstraints = false
        return view
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Add and center the adContaineradWrapper in it's parent
        view.addSubview(adContainer)
        NSLayoutConstraint.activate([
           adContainer.centerXAnchor.constraint(equalTo:
view.centerXAnchor),
           adContainer.centerYAnchor.constraint(equalTo: view.centerYAnchor),         ])
         // Passing the adContaineradWrapper wrapper to the SDK, so it can display a banner ad in it.
        RefineryAdFactory.shared.createBanner(wrapper:
adContainer,                          wrapper: adWrapper, 
                    configurationID: ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID,
                               
              lifecycleCallbacks: nil)
    }
}

Now the adContainer adWrapper has been created programmatically. It is added and centered in its parent. In the next step, the instance of adContainer adWrapper is provided to the RefineryAdFactory.shared.createBanner via wrapper argument(:wrapper,...), so the SDK will display the ad in it.