SDK Documentation
HomeBlogSign up
English
English
  • 🏠Homepage
  • 🧪Test Ad Units
  • Privacy
    • ✅Google Data Safety
  • Android SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
    • 🛠️ProGuard
  • iOS SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Revenue reporting
    • 🙍User consent
    • 🔓Privacy
  • Unity SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • Flutter SDK
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Native (Google)
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • React Native
    • ⌨️SDK integration
      • App Open
      • Banner
      • Interstitial
      • Rewarded
      • Targeting
      • Revenue reporting
    • 🙎User consent
    • 🔓Privacy
  • Web SDK
    • ⌨️SDK integration
Con tecnología de GitBook
En esta página
  • Integration
  • Adaptive banners
  • Anchored
  • Inline
  • Delegate setup
  1. iOS SDK
  2. SDK integration

Banner

Banner ads are rectangular image or text ads that occupy a space inside the application layout. They stay on screen while the users interact with the app and can automatically refresh after a certain period of time. If you are new in mobile advertising, they are an excellent choice to start.

Integration

To integrate a banner, it is needed to add a WABannerAd class component to the app interface.

Then, an ad load should be requested just as shown in the example below:

import UIKit
import WortiseSDK

class ViewController: UIViewController {
    @IBOutlet
    weak var bannerAd: WABannerAd!

    override func viewDidLoad() {
        super.viewDidLoad()
        ...
        bannerAd.adUnitId = "Wortise Ad Unit ID"
        bannerAd.adSize = WAAdSize.height50
        bannerAd.rootViewController = self
        // Optional: value in seconds to auto-refresh the ad
        bannerAd.autoRefreshTime = 60.0
        bannerAd.loadAd()
    }
}

Adaptive banners

Adaptive banners are a new banner format where the size of the ads is adapted according to the device and the app user-interface, in order to maximize performance.

Currently there is support for two kind of adaptive banners:

Anchored

This kind of banner is designed to replace the traditional 320x50 banners and be positioned at the top or bottom of the screen.

To make use of this format, the following code must be used to configure an adaptive size:

// It is needed to specify the banner width
let adSize = WAAdSize.getAnchoredAdaptiveBannerAdSize(width: width)
bannerAd.adSize = adSize

Alternatively, this other option can be implemented to let the SDK calculate the banner width, where the WABannerAd instance itself or the UIView that will contain it should be passed:

In this option, it is highly recommended that the UIView passed to the method is already added to the app’s layout, so that the SDK can correctly calculate all the dimensions.

let adSize = WAAdSize.getAnchoredAdaptiveBannerAdSize(container: view)
bannerAd.adSize = adSize

Inline

This other kind of banner, in comparison to the anchored, is designed to have a variable height and be positioned inside a scrolling content.

In this case, the following code must be used to configure a proper adaptive size:

let maxHeight = 200

// It is needed to specify the banner width. The maximum height is an
// optional parameter
let adSize = WAAdSize.getInlineAdaptiveBannerAdSize(width: width,
                                                    maxHeight: maxHeight)
bannerAd.adSize = adSize

Alternatively, this other option can be implemented to let the SDK calculate the banner width, where the WABannerAd instance itself or the UIView that will contain it should be passed:

In this option, it is highly recommended that the UIView passed to the method is already added to the app’s layout, so that the SDK can correctly calculate all the dimensions.

let maxHeight = 200

let adSize = AdSize.getInlineAdaptiveBannerAdSize(container: view,
                                                  maxHeight: maxHeight)
bannerAd.adSize = adSize

Delegate setup

A listener can be set to any WABannerAd instance to receive the events that happen during its lifecycle. For this, it is needed to implement the WABannerDelegate interface as shown in the example below:

extension ViewController : WABannerDelegate {
    
    func didClick(bannerAd: WABannerAd) {
        // Invoked when the ad has been clicked
    }
    
    func didFailToLoad(bannerAd: WABannerAd, error: WAAdError) {
        // Invoked when the ad could not be loaded
        // (because of an error or no fill)
    }

    func didImpress(bannerAd: WABannerAd) {
        // Invoked when the ad has generated an impression
    }

    func didLoad(bannerAd: WABannerAd) {
        // Invoked when the ad has been loaded
    }
    
    func didPayRevenue(bannerAd: WABannerAd, data: WARevenuedata) {
        // Invoked when the ad has generated revenue
    }
}

Once the interface is implemented, the delegate is assigned to the ad instance:

bannerAd.delegate = self
AnteriorApp OpenSiguienteInterstitial

Última actualización hace 3 días

⌨️