1. IOS – Monetize App ...
  2. User Manual
  3. Formatos Publicitarios
  4. Banner

Banner

Prerequisites

Wrapper

For creating a wrapper, you can follow this small guide: Creating a Wrapper.

Show the Ad

In the example we are using a Test Id.

If you are not testing the app, change it for the proper ID that you got from us.


The method below will add an Ad to the provided wrapper.

        func addBanner(wrapper:UIView){
            let configurationID = ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID
            RefineryAdFactory.shared.createBanner(configurationID: configurationID, wrapper: wrapper, lifecycleCallbacks: nil)
        } 
    

Lifecycle Events

You can subscribe to these events with the same method by passing a new instance of BannerEventListener as a lifecycleCallbacksparameter to the createBanner method. Details about this object can be found in the Reference.

Here is what the implementation looks like.

First, extend from the BannerEventListener.


        class BannerEventLogger: BannerEventListener {
            override func onLayoutChange(width: Int32, height: Int32) {
                print(“onLayoutChange”,”width=\(width)”,”height=\(height)”)
            }
            
            override func onLoaded() {
                print(“onLoaded”)
            }
            
            override func onOpen() {
                print(“onOpen”)
            }
            
            override func onClick() {
                print(“onClick”)
            }
            
            override func onClose() {
                print(“onClose”)
            }
            
            override func onImpression() {
             print(“onImpression”)
            }
            
            override func onFailedToLoad(error: R89LoadError) {
                print(“onFailedToLoad”,”error=\(error)”)
            }
        }

    

Next, provide the instance of BannerEventLogger to createBanner method, via lifecycleCallbacks parameter.

        func addBanner(wrapper:UIView){
            let configurationID = ConfigBuilder.companion.BANNER_TEST_R89_CONFIG_ID
            let bannerEventLogger = BanneEventLogger()
            RefineryAdFactory.shared.createBanner(configurationID: configurationID, wrapper: wrapper, lifecycleCallbacks: bannerEventLogger)
        }
    

¿Cómo podemos ayudarte?