> For the complete documentation index, see [llms.txt](https://ios-docs.adster.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ios-docs.adster.tech/ad-types/native-reward-ad.md). Agents can also search and read this documentation through its [MCP server](https://ios-docs.adster.tech/~gitbook/mcp).

# Native Reward Ad

To receive Native Ads, conform to the `MediationAdDelegate` protocol. Once the ad is loaded, you can populate your custom native ad view with the ad's data.

**Implementation:**

```swift
extension NativeRewardAdManager: MediationAdDelegate {
    func onNativeRewardAdLoaded(nativeRewardAd: AdsFramework.MediationNativeRewardAd) {
        nativeRewardAd.eventDelegate = self

        guard let nibObjects = Bundle.main.loadNibNamed("NativeRewardView", owner: nil, options: nil),
              let adView = nibObjects.first as? MediationNativeRewardAdView else {
            printLog("Could not load nib file for adView")
            return
        }

        (adView.headlineView as? UILabel)?.text = nativeRewardAd.headline
        (adView.bodyView as? UILabel)?.text = nativeRewardAd.body
        (adView.ctaView as? UIButton)?.setTitle(nativeRewardAd.callToAction, for: .normal)
        (adView.ctaView as? UIButton)?.isUserInteractionEnabled = false

        if let mediaView = nativeRewardAd.mediaView {
            addMediaViewToParentView(childView: mediaView, parentView: adView.mediaView)
        }

        adView.setNativeRewardAd(nativeRewardAd: nativeRewardAd)
        viewBanner.addSubview(adView)
    }

    func onAdFailedToLoad(error: AdError) {
        print("Native Reward Ad request failed with reason \(error.description)")
    }
}
```

**Reward Metadata:**

Native Reward Ads expose reward metadata through `nativeRewardAd.reward`

`nativeRewardAd.brand` falls back to `reward.brand.displayName` when the response brand is empty; `advertiser` falls back to that resolved brand. Reward, coupon and brand fields are optional: hide missing values instead of showing placeholder coupon codes.

`coupon.expiresAt` is an optional `Int64` Unix timestamp in seconds, including values received as integer strings. Convert valid values to `Date(timeIntervalSince1970: TimeInterval(expiresAt))` for display. Render `description` as text and `tnc`/`redemptionInstructions` as HTML with tappable links. Allow long reward details to scroll.

`reward.rawPayload`, `reward.coupon?.rawPayload` and `reward.brand?.rawPayload` preserve the decoded JSON, including unknown nested fields, as `[String: NativeRewardValue]`. Prefer typed properties for known fields. Native reward creatives remain image-only; native video controls do not apply.

Example:

```swift
if let reward = nativeRewardAd.reward {
    let couponCode = reward.coupon?.code
    let redemptionUrl = reward.coupon?.redemptionUrl
    let expiresAt = reward.coupon?.expiresAt
    let brandName = reward.brand?.displayName
    let brandLogo = reward.brand?.logoUrl
    let description = reward.description
    let terms = reward.tnc
    let instructions = reward.redemptionInstructions

    print("Coupon code: \(couponCode ?? "")")
}
```

**Tracking Events:**

To track impression and click events for Native Reward Ads, conform to `MediationNativeRewardAdEventDelegate`:

```swift
extension NativeRewardAdManager: MediationNativeRewardAdEventDelegate {
    func recordNativeRewardClick() {
        print("Native reward ad clicked")
    }

    func recordNativeRewardImpression() {
        print("Native reward ad impression recorded")
    }
}
```

**Manual Click and Impression Tracking:**

If you are not using `MediationNativeRewardAdView`, or if you set custom click/impression handling, call these methods manually:

```swift
nativeRewardAd.recordNativeRewardImpression()
nativeRewardAd.recordNativeRewardClick()
```

**Cleanup:**

Destroy the ad when it is no longer needed:

```swift
nativeRewardAd.destroy()
```
