> For the complete documentation index, see [llms.txt](https://docs.digitalturbine.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digitalturbine.com/dt-exchange/sdk-configuration/integrating-the-ios-sdk/ios-ad-formats/native-ads.md).

# Native Ads

To integrate Native Ads, ensure you have integrated the DT Exchange [IASDKCore Libraries](/dt-exchange/sdk-configuration/integrating-the-ios-sdk.md#h_01h959gwafx2axgb4wwt1nxt6w). Configure the native ad spot, create an Ad Request, and then load the ad and map the assets to your native view components.

## Importing the SDK <a href="#h_01k8pcdpmzntc4v0k5941gfkna" id="h_01k8pcdpmzntc4v0k5941gfkna"></a>

Import the following `IASDKCore` module into your desired view controller:

{% code title="Objective-C" %}

```objective-c
#import <IASDKCore/IASDKCore.h>
```

{% endcode %}

## Creating the Ad Request Object <a href="#h_01k8pcdpmz6bq0t6cdv4qjkk8c" id="h_01k8pcdpmz6bq0t6cdv4qjkk8c"></a>

Initialize an `IAAdRequest` and provide the `spotID` and a timeout value:

{% code title="Objective-C" %}

```objective-c
IAAdRequest *adRequest =
[IAAdRequest build:^(id _Nonnull builder) {
    // Configure ad request if needed
	builder.spotID = @”NATIVE AD SPOT ID”;
	builder.timeout = 15;
}];
```

{% endcode %}

## Declaring Your View Controller <a href="#h_01k8pcdpmzbcymeacwq8eddzpa" id="h_01k8pcdpmzbcymeacwq8eddzpa"></a>

Declare that your view controller conforms to the `IANativeAdDelegate` Protocol:

{% code title="Objective-C" %}

```objective-c
@interface ViewController() <IANativeAdDelegate>
```

{% endcode %}

For more information, see [Unit Content Delegate Protocols](/dt-exchange/sdk-configuration/integrating-the-ios-sdk/delegate-protocols.md#unit).

## Initializing the Placement <a href="#h_01k8pcdpmzptzyy65yv5gk8t2g" id="h_01k8pcdpmzptzyy65yv5gk8t2g"></a>

Initialize the `IANativeAdSpot` (placement) and pass your `adRequest` object:

{% code title="Objective-C" %}

```objective-c
nativeAdSpot = [IANativeAdSpot build:^(IANativeAdSpot *builder) {
  builder.adRequest = adRequest;
  builder.delegate = self;
  builder.userInfo = @{
    @"placementIdentifier" : parameters.thirdPartyAdPlacementIdentifier
  };  // Optional
}];
```

{% endcode %}

## Fetching the Ad <a href="#h_01k8pcdpmzhp20am4ztbqgsff3" id="h_01k8pcdpmzhp20am4ztbqgsff3"></a>

Native Ads are available only through SDK Bidding. In SDK Bidding, DT Exchange must first generate a token for the Mediation SDK to use when sending the request to server.

### Generating the Token <a href="#h_01k8pcdpmzyfpw6sbhx5hafbjm" id="h_01k8pcdpmzyfpw6sbhx5hafbjm"></a>

The token can be generated upon SDK initialization.

{% code title="Objective-C" %}

```objective-c
NSString *biddingToken = FMPBiddingManager.sharedInstance.biddingToken;
```

{% endcode %}

Return type: `NSString *`

If an error occurs, the returned value is `nil`.

### Loading the Ad <a href="#h_01k8pcdpmz13f2vv4dqx533bcg" id="h_01k8pcdpmz13f2vv4dqx533bcg"></a>

If DT Exchange wins the auction, load the ad with the `signaldata (adm)` that was received from the server:

{% code title="Objective-C" %}

```objective-c
__weak typeof(self) weakSelf = self;
[self.nativeAdSpot
    loadAdWithMarkup:bidResponse
      withCompletion:^(IANativeAdAssets *nativeAdAssets, NSError *error) {
        if (nativeAdAssets != nil) {
          NSString *title = nativeAdAssets.adTitle;
          NSString *adDescription = nativeAdAssets.adDescription;
          NSString *callToActionText = nativeAdAssets.callToActionText;
          UIView *appIcon = nativeAdAssets.appIcon;
          UIView *mediaView = nativeAdAssets.mediaView;
          NSString *advertiserName = nativeAdAssets.advertiserName;
          NSNumber *rating = nativeAdAssets.rating;
          NSNumber *mediaAspectRatio = nativeAdAssets.mediaAspectRatio;
        } else if (error != nil) {
          NSLog(@"Error: %@", error);
        }
      }];
```

{% endcode %}

For a complete list of Native Ads asset types, see the [oRTB Specfication for Native Ads](https://gitlab.com/digitalturbine/dt-developer-portal/gitbook/-/blob/main/14_exchange_dsp/dt-exchange-openrtb-2.5-specs#object-native).

## Registering Views for Interaction <a href="#h_01k8pcdpmzj0617y2m92h6k3j7" id="h_01k8pcdpmzj0617y2m92h6k3j7"></a>

You must register the views that will respond to user interaction, such as clicks. It is recommended to use the provided ViewTag enumeration for mapping views.

{% code title="Objective-C" %}

```objective-c
@objc public enum ViewTag: Int {
    case title = 1
    case mediaView = 2 // both main image and video share this tag
    case icon = 4
    case description = 5
    case rating = 6
    case cta = 7
    case root = 8
}
```

{% endcode %}

After setting the tags on your views, register them with the ad assets:

{% code title="Objective-C" %}

```objective-c
container.tag = ViewTagRoot;
mediaViewHolder.tag = ViewTagMediaView;
iconHolder.tag = ViewTagIcon;
adTitle.tag = ViewTagTitle;
ratingLabel.tag = ViewTagLabel;
adDescription.tag = ViewTagDescription;
ctaButton.tag = ViewTagCta;

// Register Views for Interaction
[nativeAdAssets registerViewForInteraction:container
    mediaView:mediaViewHolder
    iconView:iconHolder
    clickableViews:@[
        adTitle,
        ratingLabel,
        adDescription,
        ctaButton
]];
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.digitalturbine.com/dt-exchange/sdk-configuration/integrating-the-ios-sdk/ios-ad-formats/native-ads.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
