Skip to main content

Getting started with THEOads on iOS

This guide will get you started with THEOads in your THEOplayer iOS SDK: configure the license, update dependencies and set the source description.

Prerequisites

  1. You need to have a THEOplayer license which is compatible with THEOads. This can be obtained through https://portal.theoplayer.com.
  2. You need a working THEOads signaling service.
  3. Add the THEOplayer iOS SDK to your project by following our Getting started guide. Make sure to set up a THEOads-compatible license in your app.
  4. Add the THEOads integration as a dependency in to your project:
    .package(url: "https://github.com/theoplayer/theoplayer-sdk-spm.git", from: "8.0.0")
    .product(name: "THEOplayerTheoAdsIntegration", package: "theoplayer-sdk-spm")

Integration

Create integration

To make use of the THEOads integration, create a TheoAdsIntegration with a THEOplayer instance:

import THEOplayerSDK
import THEOplayerTheoAdsIntegration

let player = THEOplayer()
let theoAdsIntegration = TheoAdsIntegration(player: player)
note

Make sure you keep a reference to your TheoAdsIntegration instance. Whenever you derefence it Theo Ads will stop working.

Set a source with ads

Then, configure a source containing a TheoAdDescription:

player.source = .init(
source: TypedSource(
src: "PATH-TO-SIGNALING-SERVER/hls/MANIFEST-URI",
type: "application/x-mpegurl",
hlsDateRange: true
),
ads: [
TheoAdDescription(
networkCode: "NETWORK-CODE",
customAssetKey: "CUSTOM-ASSET-KEY",
backdropDoubleBox: URL(string: "PATH-TO-DOUBLE-BOX-BACKDROP-IMAGE"),
backdropLShape: URL(string: "PATH-TO-L-SHAPE-BACKDROP-IMAGE")
)
]
)
note
  • The src is different as usual. For THEOads, a signaling server needs to be set up which acts as a proxy to parse the given manifest and insert the ad interstitials. More information can be found here.
  • The hlsDateRange flag needs to be set to true as the ad markers are done using EXT-X-DATERANGE tags.
  • The ads object needs to be a TheoAdDescription. Furthermore, the networkCode and customAssetKey needs to be set according to your configured Google account.

More information