> ## Documentation Index
> Fetch the complete documentation index at: https://docs.contentignite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Banner Ads

> Setting up Banner ads

The SDK supports Banner Ads via the `CIBannerView` `UIView`. With the following parameters:

### Required

* `placementID: String`: Unique ID for this Ad Placement provided by Content Ignite.
* `pageUrl: String?`: This is used for targeting for example if the ad is displayed inline within an article or section of the app which has an equivalent URL on the web.

### Optional

* `delegate: CIBannerViewDelegate`: This protocol allows you to respond to events related to the banner ad.
* `targeting: [String: [String]]`: Pass custom key-value pairs to ad requests.
* `publisher: (() -> UIView)?`: Closure to allow you to provide a fallback to your existing Ad implementation for this particular placement. This gives publishers full control over the use of the SDK and the rate at which this fallback is used can be controlled directly through the Fusion platform.

An example is shown below:

```swift theme={null}
import CIMobileSDK_UIKit

let targeting = ["segment" : ["health","fitness"]]

let banner = CIBannerView(
    placementID: "<PLACEMENT-ID>", 
    pageUrl: "https://publisher.com/sport",
    targeting: targeting,
    delegate: self
) {
    // Publisher fallback implementation
}
view.addSubview(banner)
        
banner.translatesAutoresizingMaskIntoConstraints = false

let margins = view.layoutMarginsGuide

NSLayoutConstraint.activate([
    banner.centerXAnchor.constraint(equalTo: view.centerXAnchor),
    banner.bottomAnchor.constraint(equalTo: margins.bottomAnchor)
])

Task { await banner.load() }
```

## Handling ad events

To listen and respond to events from a Banner ad, use the `CIBannerViewDelegate` protocol:

```swift theme={null}
extension BannerViewController: CIBannerViewDelegate {

    public func bannerLoaded() {
        print("Banner ad loaded.")
    }
    
    public func bannerLoadFailed(error: Error) {
        print("Banner ad failed to load: \(error.localizedDescription)")
    }
    
    public func bannerClicked() {
        print("Banner ad clicked.")
    }
    
    public func bannerImpression() {
        print("Banner ad impression.")
    }

}
```

See the full examples: [SPM](https://gitlab.com/content-ignite/content-ignite-mobile-sdk-ios-uikit/-/tree/main/Demos/CIMobileSDK-UIKit-SPM?ref_type=heads) | [CocoaPods](https://gitlab.com/content-ignite/content-ignite-mobile-sdk-ios-uikit/-/tree/main/Demos/CIMobileSDK-UIKit-CocoaPods?ref_type=heads).
