Native Ads

This guide shows how to integrate native ads of RTBSDK into your app.

Create RTBNativeAdLoader

First, create an instance of RTBNativeAdLoader , passing context instance and implementation of RTBNativeAdLoadDelegate

val loader = RTBNativeAdLoader(context, loadListener)

Request Ad

To load an ad, you will need to pass an instance of RTBNativeAdRequestConfiguration with placementID and the bundleId. Please contact our support to get the needed IDs.

val request = RTBNativeAdRequestConfiguration(placementId, bundleId)
request.sellerId = "<SELLERID>" // Optional
loader.load(request)

Optional - set user targeting

You can pass user targeting data to each request, allowing ads to be more relevant to your audience. Each field in RTBUserTargeting is optional.

request.userTargeting = RTBUserTargeting(userID = "<USER_ID>", gender = RTBGender.MALE, keywords = listOf("keyword1", "keyword2"), yearOfBirth = 1990)
// yearOfBirth must be a 4-digit number, otherwise it will be ignored

Retrieve Native Ad Assets

Once the ad is loaded and the method nativeAdDidReceiveAd is called, you can get the needed native ad assets and assemble your view.

(Optional) Use InteractionDelegate

If you are interested in native ad interaction events like clicks, you can pass optional RTBNativeAdInteractionDelegate to native ad instance

Track Native Ad

To make sure impression reporting and click handling is handled, call trackImpression method on native ad instance, passing the view used for rendering it.

Complete Code Example

Last updated