# SDK - Native

### Quick Start

> **Prerequisite:** Complete the [SDK Installation](/ios/install-sdk.md) first. Minimum iOS deployment target: 14. Minimum SDK version required: 1.2.1.

Native Campaigns lets you display a scrollable list of campaigns directly in your app's UI. The SDK provides a default layout — you just drop it in and call `load()`.

<figure><img src="/files/M3ncHfDPiMZSsoQfmi9T" alt="" width="341"><figcaption></figcaption></figure>

***

### **1. Set the Ad Unit ID**

After `configure`, set the ad unit ID for native campaigns:

```swift
MCOfferwallSDK.shared.configure(apiKey: "YOUR_API_KEY")
MCOfferwallSDK.shared.setUserId(userId: "YOUR_USER_ID")
MCOfferwallSDK.shared.setAdunitId("YOUR_AD_UNIT_ID")
```

> Get your Ad unit ID from the [Developer Portal](https://dashboard.maf.ad/).

### **2. Add the View to Your Screen**

`MCNativeAdView` is a plain `UIView` — add it anywhere you can add a subview.

{% tabs %}
{% tab title="SwiftUI" %}
Wrap `MCNativeAdView` with `UIViewRepresentable`:

```swift
import SwiftUI
import MyChipsSdk

struct MCNativeAdViewRepresentable: UIViewRepresentable {
    func makeUIView(context: Context) -> MCNativeAdView {
        let adView = MCNativeAdView()
        adView.load()
        return adView
    }

    func updateUIView(_ uiView: MCNativeAdView, context: Context) {}
}
```

Then use it in your view:

```swift
struct CampaignsView: View {
    var body: some View {
        MCNativeAdViewRepresentable()
            .frame(height: 260)
    }
}
```

{% endtab %}

{% tab title="UIKit" %}

```swift
import UIKit
import MyChipsSdk

class CampaignsViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        let adView = MCNativeAdView()
        adView.translatesAutoresizingMaskIntoConstraints = false
        view.addSubview(adView)

        NSLayoutConstraint.activate([
            adView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 16),
            adView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
            adView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            adView.heightAnchor.constraint(equalToConstant: 260)
        ])

        adView.load()
    }
}
```

{% endtab %}
{% endtabs %}

**That's it.** The SDK handles everything:

* Fetches campaigns from the API
* Shows a loading skeleton while fetching
* Displays campaigns in a horizontal scrollable list
* Tracks impressions automatically
* Opens the campaign detail page on click

***

### 3. (Optional) Open Campaign Details In-App

By default, tapping a campaign opens the detail page in Safari. To keep users inside your app using an in-app WebView:

```swift
MCOfferwallSDK.shared.setOpenInApp(true)
```

When `openInApp` is `true`, the SDK presents an `MCWebViewController` from the nearest `UIViewController` in the responder chain. You can also set a title for the in-app WebView:

```swift
MCOfferwallSDK.shared.setToolbarTitle("My Rewards")
```

> **Tip:** For tighter control over which view controller is used to present the WebView, set `adView.presentingController = self` on your containing `UIViewController`.

### 4. What Happens Behind the Scenes

When you call `adView.load()`, the SDK:

1. Shows a **pulsing skeleton placeholder** that matches the layout direction
2. Calls the API to fetch campaigns
3. Replaces the skeleton with the **campaign list**
4. **Fires impression pixels** automatically when each campaign becomes visible
5. **Opens the campaign detail page** (in Safari or an in-app WebView) when the user taps a campaign

No manual tracking or click handling is needed.

***

### **Next Steps**

* Want to customize the look and feel with small effort? See [Customizations →](/ios/sdk-native/sdk-native-customizations.md)
* Need a completely different card design? See [Custom Layouts →](/ios/sdk-native/sdk-native-custom-layout.md)
* Need the full data reference? See [Data Reference →](/ios/sdk-native/sdk-native-data-reference.md)


---

# Agent Instructions: 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:

```
GET https://docs.mychips.io/ios/sdk-native.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
