Login
Welcome
Login

Migrating from v4 to v5


In this article, the PID 84242 will be used, you can find more PIDs on this article

In the v5 of the SDK, we've introduced a new class called InReadAdPlacement which is responsible for configuring the ad placement and then make the call to our ad server.

Settings

In v4 integration, all settings needed for an ad request is placed under AdSettings class.

In v5, the setup will be done in two different places, the first one is done during the ad placement configuration, the other one for the ad request.

Below, an example of the new placement and request settings.

let placementSettings = TeadsAdPlacementSettings { settings in
        settings.setUsPrivacy("1YNN")
}

let requestSettings = TeadsAdRequestSettings { settings in
        settings.pageSlotUrl("http://teads.com")
}

Placement

Unlike the v4 integration we don't have to instantiate the TeadsInReadAdView, it will be served by the placement once an ad is received.
The first step is to create our TeadsInReadAdPlacement with the optional TeadsAdPlacementSettings created.

let placementSettings = TeadsAdPlacementSettings { settings in
        settings.setUsPrivacy("1YNN")
}

val adPlacement = TeadsSDK.createInReadPlacement(pid: 84242, settings: placementSettings, delegate: self) //replace with the right placement id

Request an ad

Now we can request an ad. We just have to call the requestAd method from our placement with the settings and a listener.

let requestSettings = TeadsAdRequestSettings { settings in
        settings.pageSlotUrl("http://teads.com")
}

adPlacement.requestAd(requestSettings: requestSettings)

Display an ad

When an ad is received, we just have to add the provided TeadsInReadAdView in the view parent.

⚠️ Note that the view needs to be at the top of the view parent to avoid potential overlay.

@IBOutlet weak var teadsAdView: TeadsInReadAdView!
@IBOutlet weak var teadsAdHeightConstraint: NSLayoutConstraint! // height contraint of teadsAdView

func didReceiveAd(ad: TeadsInReadAd, adRatio: TeadsAdRatio) {
        teadsAdView.bind(ad)
        ad.delegate = self
        teadsAdHeightConstraint.constant = adRatio.calculateHeight(for: teadsAdView.frame.width)
    }

AdOpportunityTrackerView

The AdOpportunityTrackerView is a view that you will need to add to your slot view.
Its function is to monitor the inventory.

Once the AdOpportunityTrackerView is visible, it will be automatically removed.

func adOpportunityTrackerView(trackerView: TeadsAdOpportunityTrackerView) {
        teadsAdView.addSubview(trackerView)
}

Validate your integration

In order to validate that your integration is well done you can use our validation tool.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.