Nimbus iOS SDK Quick Start Guide

Welcome to Nimbus - ads by publishers, for publishers.

Build Setup

CocoaPods

NimbusSDK requires Cocoapods >= 1.10.0.

  1. Add NimbusSDK pod to your Podfile.
  2. Include NimbusRenderStaticKit (required if displaying static interstitial/banner (HTML) ads) and/or NimbusRenderVideoKit (required if displaying video (VAST) ads) as necessary. pod 'NimbusSDK', subspecs: [`NimbusKit`, `NimbusRenderStaticKit`, `NimbusRenderVideoKit`]
  3. Run pod install

Manual

Download the latest iOS SDK.

Drag the following packages into your project:

  • NimbusCoreKit.xcframework
  • NimbusRequestKit.xcframework
  • NimbusRenderKit.xcframework
  • NimbusRenderStaticKit.xcframework (required if displaying static interstitial/banner (HTML) ads)
  • NimbusRenderVideoKit.xcframework (required if displaying video (VAST) ads)
  • NimbusKit.xcframework

You can add these frameworks to your main app target by including it in “Frameworks, Libraries, and Embedded Content”. Please make sure to select “Embed & Sign” for these frameworks.

Additional setup if displaying video ads

Download and include IMA SDK if your app is going to display video ads.

Currently supported IMA SDK version is 3.13.0 but other versions may work.

Initialize Nimbus SDK

import NimbusKit

Nimbus.shared.initialize(publisher: [publisher key], apiKey: [api key])
// Set up renderers. Add static and/or video renderers here as needed

import NimbusRenderStaticKit
import NimbusRenderVideoKit

Nimbus.shared.renderers = [
    .forAuctionType(.static): NimbusStaticAdRenderer(),
    .forAuctionType(.video): NimbusVideoAdRenderer(),
]

Enable test mode

Enable test mode to start seeing ads right away. This is required for a first time integration.

Nimbus.shared.testMode = true

Test mode can be turned off when you are ready to test in your production environment.

Show an Ad

class MyViewController: UIViewController {
    var adManager: NimbusAdManager!
    var adController: AdController?

    override func viewDidLoad() {
        super.viewDidLoad()

        adManager = NimbusAdManager()
        adManager.delegate = self
        adManager.showAd(
          request: NimbusRequest.forInterstitialAd(position: "position"),
          container: view,
          adPresentingViewController: self
        )
    }
}

// MARK: NimbusAdManagerDelegate

extension MyViewController: NimbusAdManagerDelegate {

    func didCompleteNimbusRequest(request: NimbusRequest, ad: NimbusAd) {
        // Request completed with the given ad
    }

    func didFailNimbusRequest(request: NimbusRequest, error: NimbusError) {
        // Nimbus request failed due to an error or no bid
    }

    func didRenderAd(request: NimbusRequest, ad: NimbusAd, controller: AdController) {
        // Ad received and is ready to be shown. Optionally listen for ad events on the controller
        self.adController = controller
        self.adController.delegate = self
    }
}

// MARK: AdControllerDelegate

extension MyViewController: AdControllerDelegate {

    func didReceiveNimbusEvent(controller: AdController, event: NimbusEvent) {
        // Receive events like `loaded`, `impression`, `clicked`
    }

    /// Received an error for the ad
    func didReceiveNimbusError(controller: AdController, error: NimbusError) {
        // Errors thrown related to ad rendering
    }
}