Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Initialization

  1. Initialize the SDK. Call SDK initialization as soon as possible, preferably in application:didFinishLaunchingWithOptions: method:

Code Block
languageswift
AdPlayer.initSdk(
    storeURL: URL(string: ...)!) // app store url
)
Warning

Calling any of the AdPlayer APIs before initialization will result in errors!

Before this method is called, the SDK will not perform any operations and will not use any resources (memory, cpu, network etc.).

  1. Initialize the player tags. Best to be called right after initialize. In case the tags belong to more than one publisher, this method must be called once per publisher.

Code Block
languageswift
let tagConfig1 = AdPlayerTagConfiguration(tagId: tag1Id)
// configure your tag here

let tagConfig2 = AdPlayerTagConfiguration(tagId: tag2Id)
// configure your tag here

let publisher = AdPlayerPublisherConfiguration(publisherId: publisherId, tagConfig1, tagConfig2)

AdPlayer.initializePublisher(publisher)

At least one AdPlayerTagConfiguration must be provided in the constructor of AdPlayerPublisherConfiguration (a publisher configuration cannot be instantiated without tags).

All the player tags of this publisher that are expected to be presented in the application must be provided in the constructor of AdPlayerPublisherConfiguration.

Warning

A player tag that won’t be initialized successfully won’t be presented and won’t function!

Note

A player tag should be initialized only once.

Preparing the UI placement(s) of your player tag(s)

Warning

A player tag may be displayed only in one placement view controller. Displaying the same tag in multiple placement views is not supported and may lead to unexpected behavior.

...

Code Block
languageswift
// ViewController.viewDidLoad
let placement = AdPlayerPlacementView(tagId: tagId)
placement.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(placement)
NSLayoutConstraint.activate([
    placement.leadingAnchor.constraint(equalTo: view.leadingAnchor),
    placement.trailingAnchor.constraint(equalTo: view.trailingAnchor),
    placement.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor)
])

Placement Sizing

Note

By default, the SDK will set the placement’s height for you.
To override this behavior - set and implement “layoutDelegate“

...