> For the complete documentation index, see [llms.txt](https://adpopcornssp.gitbook.io/ssp-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adpopcornssp.gitbook.io/ssp-sdk/undefined-1/ap/ap-ios/ios-2.x.x/mintegral.md).

# Mintegral

#### Mintegral

{% embed url="<https://github.com/Mintegral-official/MintegralAdSDK-iOS-new?tab=readme-ov-file>" %}

## 사용방법

{% hint style="warning" %}
**2) 초기 셋팅,  3) 초기화 진행은 위 링크에 들어가서 직접 설정하시는 것을 권장드립니다**
{% endhint %}

### 1) 설치

{% content-ref url="/pages/IP2R7MXm9WlEBdvJxfnZ" %}
[iOS 2.x.x (구버전)](/ssp-sdk/undefined-1/ap/ap-ios/ios-2.x.x.md)
{% endcontent-ref %}

### 2) 초기화

**->** [**링크**](https://dev.mintegral.com/doc/index.html?file=sdk-m_sdk-ios\&lang=en#sdkinitialization) (해당 링크는 Mintegral 로그인을 해야 확인할 수 있습니다.)

{% tabs %}
{% tab title="Objective-C" %}

```objectivec


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [self setupMintegral];
    return YES;
}


-(void)setupMintegral {
    MTGSDK *sdk = [MTGSDK sharedInstance];
    [sdk setAppID:@"your appID" ApiKey:@"your appKey"];
}
```

{% endtab %}

{% tab title="Swift" %}

```swift
import MTGSDK

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    setupMintegral()
    ...
    return true
}

func setupMintegral() {
    MTGSDK.sharedInstance().setAppID("appID", apiKey: "appKey")
}
```

{% endtab %}
{% endtabs %}

## Native Layout 설정

{% hint style="warning" %}
**Adapter 내부에 들어있는 Xib 파일을 project에 꼭 넣어주세요.**
{% endhint %}

스토리보드에 UIView 생성 후 Custom Class을 AdPopcornSSPNativeAd 설정

<figure><img src="/files/ubRUjRCOh0tABLNm4RDc" alt=""><figcaption></figcaption></figure>

AdPopcornSSPNativeAd 영역 안에 미디에이션 업체의 실제 광고 영역 추가 및 viewcontroller에 outlet 연결합니다.

<figure><img src="/files/m6lbySspZ1JdYkP9kLd1" alt=""><figcaption></figcaption></figure>

storyboard에서 생성한 UI view를 APMintegralNativeAdRenderer 를 사용하여 sdk에 전달한다.

{% tabs %}
{% tab title="Objective-C" %}

<pre class="language-objectivec"><code class="lang-objectivec">#import &#x3C;AdPopcornSSP/AdPopcornSSPNativeAd.h>	
#import "Mintegral.h"

<strong>- (void)viewDidLoad {
</strong>  [super viewDidLoad];
  // Do any additional setup after loading the view.
  APMintegralNativeAdRenderer *apMintegralNativeAdRenderer = [[APMintegralNativeAdRenderer alloc] init];
  apMintegralNativeAdRenderer.adUIView = _mintegralNativeAdView;
  apMintegralNativeAdRenderer.iconImageView = _mintegralAdIconView;
  apMintegralNativeAdRenderer.appNameLabel = _mintegralAdTitleView;
  apMintegralNativeAdRenderer.appDescLabel = _mintegralAdDescView;
  apMintegralNativeAdRenderer.adCallButton = _mintegralAdCTAView;
  apMintegralNativeAdRenderer.mMediaView = _mintegralMediaView;
  [_adPopcornSSPNativeAd setMintegralNativeRenderer:apMintegralNativeAdRenderer superView:_mintegralNativeAdView];
}
</code></pre>

{% endtab %}

{% tab title="Swift" %}

```swift
override func viewDidLoad() 
{
    super.viewDidLoad()
    apMintegralNativeAdRenderer = APMintegralNativeAdRenderer.init()
    apMintegralNativeAdRenderer.adUIView = _mintegralNativeAdView
    apMintegralNativeAdRenderer.iconImageView = _mintegralAdIconView
    apMintegralNativeAdRenderer.appNameLabel = _mintegralAdTitleView
    apMintegralNativeAdRenderer.appDescLabel = _mintegralAdDescView
    apMintegralNativeAdRenderer.adCallButton = _mintegralAdCTAView
    apMintegralNativeAdRenderer.mMediaView = _mintegralMediaView
    adPopcornSSPNativeAd.setMintegralNativeRenderer(apMintegralNativeAdRenderer, superView: _mintegralNativeAdView)
}
```

{% endtab %}
{% endtabs %}

APMintegralNativeAdRenderer 를 생성한 뒤, 애드팝콘 Mintegral 네이티브 광고에서 지원하는 title, desc, icon, cta, mediaView를 전달하여 준다. 단, <mark style="color:red;">이 5개의 component들은 하나의 UIView 영역 안에 포함</mark>되어 있어야 하며, 해당 superview는 <mark style="color:blue;">`adUIView`</mark> 에 반드시 전달해 주어야 합니다.

<mark style="color:red;">`APMintegralNativeAdRenderer`</mark>에 각 component를 연결시켜 준 후, 아래 API를 통해서, <mark style="color:red;">`setMintegralNativeRenderer:superView:`</mark> API를 통해 render와 namNativeAdView 를 sdk에 최종적으로 전달합니다.
