Requisitos previos
Envoltorio
Para crear un contenedor, puedes seguir esta pequeña guía: Creando un envoltorio.
Mostrar el anuncio
En el ejemplo estamos utilizando un Test Id.
Si no estás probando la aplicación, cámbiala por el ID apropiado que te dimos.
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)
}
Eventos del ciclo de vida
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 Referencia.
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)
}