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
- You need to have a THEOplayer license which is compatible with THEOads. This can be obtained through https://portal.theoplayer.com.
- You need a working THEOads signaling service.
- 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.
- Add the THEOads integration as a dependency in to your project:
- Swift Package Manager
- Cocoapods
.package(url: "https://github.com/theoplayer/theoplayer-sdk-spm.git", from: "8.0.0")
.product(name: "THEOplayerTheoAdsIntegration", package: "theoplayer-sdk-spm")pod 'THEOplayer-Integration-TheoAds', '~> 8.0'
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 totrue
as the ad markers are done usingEXT-X-DATERANGE
tags. - The
ads
object needs to be aTheoAdDescription
. Furthermore, thenetworkCode
andcustomAssetKey
needs to be set according to your configured Google account.