iOS

Including the Nimbus adapter for iOS into your app

Setup

If using Swift Package Manager, include the NimbusMobileFuseKit package in your list of selected packages. If using Cocoapods, add the Nimbus pod to your podfile, including the NimbusMobileFuseKit subspec as follows:

pod 'NimbusSDK', subspecs: ['NimbusKit', 'NimbusMobileFuseKit']

The MobileFuse SDK will be automatically installed as a dependency when using CocoaPods or Swift Package Manager.

Configure the Nimbus SDK to include MobileFuse

First, you should ensure the Nimbus SDK is initialized before configuring MobileFuse. After initialization, add the NimbusMobileFuseRequestInterceptor and NimbusMobileFuseAdRenderer to the Nimbus SDK:

#if canImport(NimbusSDK) // CocoaPods
import NimbusSDK
#else                    // Swift Package Manager
import NimbusMobileFuseKit
#endif

func setupMobileFuseDemand() {
    if NimbusRequestManager.requestInterceptors == nil {
        NimbusRequestManager.requestInterceptors = []
    }

    NimbusRequestManager.requestInterceptors?.append(NimbusMobileFuseRequestInterceptor())
    Nimbus.shared.renderers[.forNetwork("mobilefusesdk")] = NimbusMobileFuseAdRenderer()
}

Nimbus initialization and ad requests

If you are adding MobileFuse to an existing Nimbus integration, you shouldn't need to add any of the following code. If you are setting up a fresh Nimbus integration, here are some code samples. You can also use Nimbus' documentation as a reference.

Initialize Nimbus with your publisher key and API key

Nimbus.shared.initialize(publisher: publisherKey, apiKey: apiKey)

Request and render a banner Ad

let request = NimbusRequest.forBannerAd(
  position: placement, 
  format: .banner320x50, // Can also be .mrec!
  adPosition: .footer
)

adManager.showAd(
  request: request,
  container: rootViewController.view,
  adPresentingViewController: rootViewController
)

Request and render an interstitial ad

let request = NimbusRequest.forInterstitialAd(position: placement)

adManager.showBlockingAd(
  request: request,
  closeButtonDelay: 5,
  adPresentingViewController: rootViewController
)

Request and render a rewarded ad

let request = NimbusRequest.forRewardedVideo(position: placement)

adManager.showRewardedAd(request: request, adPresentingViewController: presentationController)

Testing the integration

MobileFuse Hybrid can be tested by enabling test mode in the Nimbus SDK.

Nimbus.shared.testMode = true

Nimbus will always respond with a MobileFuse ad if the extension has been installed and placements have been configured in Nimbus. If you do not see a MobileFuse test ad, please contact your Nimbus account manager or MobileFuse account rep to verify MobileFuse has been set up for the ad sizes you are requesting.

Disabling MobileFuse test ads

Nimbus test ads can be re-enabled by removing MobileFuse from the request to Nimbus.

// Removing MobileFuse from the Nimbus request 
NimbusRequestManager.requestInterceptors?.removeAll {
    $0 is NimbusMobileFuseRequestInterceptor
}

// Or comment out the line that installs the interceptor
//NimbusRequestManager.requestInterceptors?.append(NimbusMobileFuseRequestInterceptor())

📘

Removing the NimbusMobileFuseRequestInterceptor will prevent MobileFuse from serving on all ads; Ensure the interceptor is installed in the SDK before releasing to production!