AdPlayerTag APIs - iOS
Obtaining AdPlayerTag Instance
Instances of AdPlayerTag
can be obtained in one of two ways:
Obtaining them right after the initialization (this is the earliest point at which the instance is available)
AdPlayer.initializePublisher(publisher) { result in
switch result {
case .success(let tag):
// tag instance available here
case .failure(let error):
// tag initialization failed
}
}
2. Requesting them from AdPlayer
AdPlayer.getTagWhenReady(tagId: tagId) { result in
switch result {
case .success(let tag):
// tag instance available here
case .failure(let error):
// tag initialization failed
}
}
3. In order to perform an action only if a tag is ready now and otherwise skip it, you may request the tag now if present using the following API
guard let tag = AdPlayer.getTagNowOrNil(tagId: tagId) else {
return
}
A common use for this API is when launching interstitial ads.
Controls
The AdPlayerTag
allows you to control the player programmatically.
To pause the player, call
AdPlayerTag.pause()
To resume playback, call
AdPlayerTag.resume()
AdPlayerTag.skipAd()
skips an ad if one is playing and skippableAdPlayerTag.playingState.state == .playing:
detects whether or not the player is playing
Configurations
While most of the configurations are available on the dashboard, the AdPlayerTag
provides some configurations to the player that can be changed in code. The configurations should be provided as part of the initialization process.
Some of the configurations also appear as assignable fields on the AdPlayerTag
and can be changed at any time while others can be provided only at initialization and cannot be changed later.