Ads

The Google IMA SDK provides the tools to integrate and manage video ads in your app. PRESTOPlay SDK simplifies displaying ads by providing an interface to the Google IMA SDK, making it easy to incorporate and control ads in your application.

Integrate

Include the GoogleAds-IMA-iOS-SDK library in your project. Here is an example using Cococapods:

pod 'GoogleAds-IMA-iOS-SDK'

Register the IMA plugin to PRESTOPlay SDK:

import CastlabsIMA

...

PRESTOPlay.shared.register([IMAPlugin()])

Scheduling Ads

In your view controller, you can schedule ads as follows:

override func viewDidAppear(_ animated: Bool) {
    ...
    let ads = PRESTOPlaySDK.shared.ads(for: player)
    let url = URL(string: "https://players.castlabs.com/ads/vmap?ad=1,start&ad=00:01:15&ad=1,end")!
    ads?.requestAds(withUrl: url, onView: view, viewController: self)
}

Note: Since the Google IMA SDK requires the ad container to be in the the view hierarchy, the requestAds() method should be called within the viewDidAppear() event.

Please check our examples/IMADemo for complete implementation.