> 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/sdk/ios/ios-2.x.x/adfit-bizboard.md).

# Adfit Bizboard 연동 가이드

Adfit Bizboard 네이티브 연동만을 사용하고자 할 경우, 아래의 순서대로 연동을 진행하시면 됩니다.

단, SDK 설치, SSP 초기화, IDFA 설정, 로그 수준 설정 등은 [\[기본 연동가이드\]](/ssp-sdk/sdk/ios/ios-2.x.x/undefined.md)를 통해 확인 후 선 진행 하시기 바랍니다.

## 1. Adfit SDK 다운로드

[\[AdFit SDK 설치 가이드\]](https://github.com/adfit/adfit-ios-sdk/wiki/%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0) 문서에 나와 있는 순서대로 설정하여 AdFit SDK를 프로젝트에 추가합니다.

## 2. Adfit Mediation Adapter 다운로드

[\[AdFit Mediation Adapter\]](https://s3.ap-northeast-1.amazonaws.com/static.adbrix.igaworks.com/adpopcorn-ssp/sdk/AdPopcornSSPMediationAdapter/AdPopcornSSPMediationAdapter_240110.zip)를 다운로드 하신 뒤, Adfit 폴더에 포함된, AdFitAdapter.h, AdFitAdapter.m 파일을 프로젝트에 추가합니다.

{% hint style="warning" %}
최신 AdFit Mediation Adapter의 경우 Adfit 3.12.22 버전과 호환됩니다. 3.12.22 미만의 버전을 사용하고 계실 경우 업데이트 해주시기 바랍니다.
{% endhint %}

## 3. 네이티브 광고 인스턴스 생성

StoryBoard에 AdPopcornSSPNativeAd 영역 지정 후 아래와 같이 Outlet 연결합니다.

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

```swift
#import <AdPopcornSSP/AdPopcornSSPNativeAd.h>

@property (strong, nonatomic) IBOutlet AdPopcornSSPNativeAd *adPopcornSSPNativeAd;
```

{% endtab %}

{% tab title="Swift" %}

```swift
class ViewController: UIViewController, APSSPNativeAdDelegate
{	
    // AdPopcornSSPNativeAd
    var apSSPNativeAdRenderer: APSSPNativeAdRenderer!
    @IBOutlet var adPopcornSSPNativeAd: AdPopcornSSPNativeAd!
}
```

{% endtab %}
{% endtabs %}

## 4. AppKey, PlacementId, ViewController 설정

ViewController.m을 수정하여 생성한 인스턴스에 setPlacementInfoWithAppkey API를 이용하여 아래와 같이 AppKey , PlacementId , ViewController를 설정 합니다.

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

```objectivec
#import <AdPopcornSSP/AdPopcornSSPNativeAd.h>	
#import "AdFitAdapter.h"

- (void)viewDidLoad
{	
    [super viewDidLoad];	
    [_adPopcornSSPNativeAd setPlacementInfoWithAppKey:@“발급받은앱키” placementId:@“발급받은 네이티브 PlacementId” viewController:self]; 
    _adPopcornSSPNativeAd.delegate = self;
}
```

{% endtab %}

{% tab title="Swift" %}

```swift
class ViewController: UIViewController, APSSPNativeAdDelegate
{	
    // AdPopcornSSPNativeAd
    var apSSPNativeAdRenderer: APSSPNativeAdRenderer!
    @IBOutlet var adPopcornSSPNativeAd: AdPopcornSSPNativeAd!
    
    override func viewDidLoad() {
        super.viewDidLoad()
	adPopcornSSPNativeAd.setPlacementInfoWithAppKey("YOUR_APP_KEY", 
	placementId: "YOUR_PLACEMENT_Id", viewController: self)
	adPopcornSSPNativeAd.delegate = self
    }
}
```

{% endtab %}
{% endtabs %}

## 5. Adfit Bizboard Template 설정

AdFit BizBoard 영역 생성 후, AdPopcorn SSP SDK에 전달합니다.

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

```objectivec
#import <AdPopcornSSP/AdPopcornSSPNativeAd.h>	
#import "AdFitAdapter.h"

@implementation AdPopcornSSPNativeViewController	
- (void)viewDidLoad
{	
	[super viewDidLoad];	
	[_adPopcornSSPNativeAd setPlacementInfoWithAppKey:@“발급받은앱키” placementId:@“발급받은 네이티브 PlacementId” viewController:self]; 
	_adPopcornSSPNativeAd.delegate = self;

	APAdFitNativeAdRenderer *apAdFitNativeAdRenderer = [[APAdFitNativeAdRenderer alloc] init];
	BizBoardTemplate *bizBoardTemplate = [[BizBoardTemplate alloc] init];
	apAdFitNativeAdRenderer.adfitBizBoardTemplate = bizBoardTemplate;
	[_adPopcornSSPNativeAd setAdFitRenderer:apAdFitNativeAdRenderer superView:bizBoardTemplate];
}
@end
```

{% endtab %}

{% tab title="Swift" %}

```swift
class ViewController: UIViewController, APSSPNativeAdDelegate
{	
	// AdPopcornSSPNativeAd
    var apSSPNativeAdRenderer: APSSPNativeAdRenderer!
    @IBOutlet var adPopcornSSPNativeAd: AdPopcornSSPNativeAd!
    
    override func viewDidLoad() {	
        super.viewDidLoad()
	adPopcornSSPNativeAd.setPlacementInfoWithAppKey("YOUR_APP_KEY", 
	placementId: "YOUR_PLACEMENT_Id", viewController: self)
	adPopcornSSPNativeAd.delegate = self

	let apAdFitNativeAdRenderer = APAdFitNativeAdRenderer.init()
	let bizBoardTemplate = BizBoardTemplate()
	apAdFitNativeAdRenderer.adfitBizBoardTemplate = bizBoardTemplate
	adPopcornSSPNativeAd.setAdFitRenderer(apAdFitNativeAdRenderer, superView: bizBoardTemplate)
    }
}
```

{% endtab %}
{% endtabs %}

## 6. 광고 요청

네이티브 인스턴스 생성과 UI 구성 요소 배치가 완료 된 경우 , 광고 요청 <mark style="color:red;">`loadRequest`</mark> API를 호출 하여 광고를 받아 옵니다.

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

```objectivec
[_sspNativeAd loadRequest];
```

{% endtab %}

{% tab title="Swift" %}

```swift
adPopcornSSPNativeAd.loadRequest()
```

{% endtab %}
{% endtabs %}

광고 수신이 정상적으로 완료 된 경우 아래 스크린샷과 같이 광고가 노출 됩니다.

<figure><img src="https://50533756-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqmkw7pJLtjFGD5fwChbN%2Fuploads%2FFUR4EjlEAtuJbg108zIi%2Fimage.png?alt=media&amp;token=3bad8b58-e24c-4179-a1c7-55090c52b4cc" alt="" width="375"><figcaption><p>Adfit BizBoard AD</p></figcaption></figure>

## 7. AdInfoIcon 위치 커스터마이징

우측 상단의 물음표 아이콘의 경우 <mark style="color:red;">`APAdFitNativeAdRenderer`</mark>의 아래 property를 통해 위치 조정이 가능합니다.

* bizBoardInfoIconTopConstant
* bizBoardInfoIconBottomConstant
* bizBoardInfoIconLeftConstant
* bizBoardInfoIconRightConstant

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

```objectivec
#import <AdPopcornSSP/AdPopcornSSPNativeAd.h>	
#import "AdFitAdapter.h"

@implementation AdPopcornSSPNativeViewController	
- (void)viewDidLoad
{
	[super viewDidLoad];	
	[_adPopcornSSPNativeAd setPlacementInfoWithAppKey:@“발급받은앱키” placementId:@“발급받은 네이티브 PlacementId” viewController:self]; 
	_adPopcornSSPNativeAd.delegate = self;

	APAdFitNativeAdRenderer *apAdFitNativeAdRenderer = [[APAdFitNativeAdRenderer alloc] init];
	BizBoardTemplate *bizBoardTemplate = [[BizBoardTemplate alloc] init];
	apAdFitNativeAdRenderer.adfitBizBoardTemplate = bizBoardTemplate;
	apAdFitNativeAdRenderer.bizBoardInfoIconRightConstant = -16;
	[_adPopcornSSPNativeAd setAdFitRenderer:apAdFitNativeAdRenderer superView:bizBoardTemplate];
}
@end

```

{% endtab %}

{% tab title="Swift" %}

```swift
class ViewController: UIViewController, APSSPNativeAdDelegate
{	
	// AdPopcornSSPNativeAd
	var apSSPNativeAdRenderer: APSSPNativeAdRenderer!
	@IBOutlet var adPopcornSSPNativeAd: AdPopcornSSPNativeAd!

	override func viewDidLoad() {	
		super.viewDidLoad()	
		adPopcornSSPNativeAd.setPlacementInfoWithAppKey("YOUR_APP_KEY", 
			placementId: "YOUR_PLACEMENT_Id", viewController: self)
		adPopcornSSPNativeAd.delegate = self

		apAdFitNativeAdRenderer = APAdFitNativeAdRenderer.init()
		bizBoardTemplate = BizBoardTemplate()
		apAdFitNativeAdRenderer.adfitBizBoardTemplate = bizBoardTemplate
		apAdFitNativeAdRenderer.bizBoardInfoIconRightConstant = -16;
		adPopcornSSPNativeAd.setAdFitRenderer(apAdFitNativeAdRenderer, superView: bizBoardTemplate)
		adPopcornSSPNativeAd.loadRequest()
	}
}

```

{% endtab %}
{% endtabs %}

## 8. 네이티브 광고 이벤트 처리

네이티브광고에서 발생하는 이벤트에 대한 델리게이트를 제공합니다.델리게이트를 사용하기 위해서는 <mark style="color:red;">`APSSPNativeAdDelegate`</mark>를 추가하여야 합니다.

{% tabs %}
{% tab title="Objective-C" %}
\_sspNativeAd 인스턴스에 delegate를 설정하고 구현하여야 합니다.

<table><thead><tr><th width="293">delegate</th><th>설명</th></tr></thead><tbody><tr><td>APSSPNativeAdLoadSuccess</td><td>네이티브 광고 로드 성공</td></tr><tr><td>APSSPNativeAdLoadFail : error</td><td>네이티브 광고 로드 실패. <a href="/ssp-sdk/sdk/ios/ios-3.1.0+/undefined-13.md">에러코드 값</a></td></tr><tr><td>APSSPNativeAdImpression</td><td>네이티브 광고 화면 노출</td></tr><tr><td>APSSPNativeAdClicked</td><td>네이티브 광고 클릭</td></tr></tbody></table>

```objectivec
#import <AdPopcornSSP/AdPopcornSSPNativeAd.h>	
#import "AdFitAdapter.h"

@interface AdPopcornSSPNativeViewController () <APSSPNativeAdDelegate>	
{	
} 
@property (strong, nonatomic) IBOutlet AdPopcornSSPNativeAd *adPopcornSSPNativeAd; 

@end	
@implementation AdPopcornSSPNativeViewController	

- (void)viewDidLoad
{	
	[super viewDidLoad];	
	[_adPopcornSSPNativeAd setPlacementInfoWithAppKey:@"발급받은앱키" placementId:@"발급받은 네이티브 PlacementId" viewController:self]; 
	_adPopcornSSPNativeAd.delegate = self; 

	APAdFitNativeAdRenderer *apAdFitNativeAdRenderer = [[APAdFitNativeAdRenderer alloc] init];
	BizBoardTemplate *bizBoardTemplate = [[BizBoardTemplate alloc] init];
	apAdFitNativeAdRenderer.adfitBizBoardTemplate = bizBoardTemplate;
	[_adPopcornSSPNativeAd setAdFitRenderer:apAdFitNativeAdRenderer superView:bizBoardTemplate];

	[_sspNativeAd loadRequest];
} 

#pragma AdPopcornSSPNativeAdDelegate 
- (void)AdPopcornSSPLoadNativeAdFailedWithError:(AdPopcornSSPError *)error 
{ 
} 

- (void)APSSPNativeAdLoadSuccess:(AdPopcornSSPNativeAD *)native Ad 
{ 
} 

- (void)APSSPNativeAdLoadFail:(AdPopcornSSPNativeAD *)nativeAd error:(AdPopcornSSPError) error 
{ 
}

- (void)APSSPNativeAdImpression:(AdPopcornSSPNativeAd *)nativeAd 
{ 
}

- (void)APSSPNativeAdClicked:(AdPopcornSSPNativeAd *)nativeAd 
{ 
}
@end
```

{% endtab %}

{% tab title="Swift" %}
adPopcornSSPNativeAd 인스턴스에 delegate를 설정하고 구현하여야 합니다.

<table><thead><tr><th width="289">delegate</th><th>설명</th></tr></thead><tbody><tr><td>apsspNativeAdLoadSuccess</td><td>네이티브 광고 로드 성공</td></tr><tr><td>apsspNativeAdLoadFail: error</td><td>네이티브 광고 로드 실패. <a href="/ssp-sdk/sdk/ios/ios-3.1.0+/undefined-13.md">에러코드 값</a></td></tr><tr><td>apsspNativeAdImpression</td><td>네이티브 광고 화면 노출</td></tr><tr><td>apsspNativeAdClicked</td><td>네이티브 광고 클릭</td></tr></tbody></table>

```swift
class ViewController: UIViewController, APSSPNativeAdDelegate
{	
    // AdPopcornSSPNativeAd
    var apSSPNativeAdRenderer: APSSPNativeAdRenderer!
    @IBOutlet var adPopcornSSPNativeAd: AdPopcornSSPNativeAd!

    override func viewDidLoad() {	
        super.viewDidLoad()
	adPopcornSSPNativeAd.setPlacementInfoWithAppKey("YOUR_APP_KEY", 
	    placementId: "YOUR_PLACEMENT_Id", viewController: self)
	adPopcornSSPNativeAd.delegate = self

	apAdFitNativeAdRenderer = APAdFitNativeAdRenderer.init()
        bizBoardTemplate = BizBoardTemplate()
	apAdFitNativeAdRenderer.adfitBizBoardTemplate = bizBoardTemplate
	apAdFitNativeAdRenderer.bizBoardInfoIconRightConstant = -16;
	adPopcornSSPNativeAd.setAdFitRenderer(apAdFitNativeAdRenderer, superView: bizBoardTemplate)
	adPopcornSSPNativeAd.loadRequest()
    } 

    // Native Delegate
    func apsspNativeAdLoadSuccess(_ nativeAd: AdPopcornSSPNativeAd!) {
    }
    func apsspNativeAdLoadFail(_ nativeAd: AdPopcornSSPNativeAd!, error: AdPopcornSSPError!) {
    }
    func apsspNativeAdImpression(_ nativeAd: AdPopcornSSPNativeAd!) {
    }
    func apsspNativeAdClicked(_ nativeAd: AdPopcornSSPNativeAd!) {
    }
}
```

{% endtab %}
{% endtabs %}
