# ADOP(Based on AdMob)

#### ADOP

{% embed url="https://developers.google.com/admob/ios/quick-start?hl=ko" %}

## 사용방법

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



### 1) 설치

{% content-ref url="" %}
[]()
{% endcontent-ref %}



### 2) 기본 Setting

**Info.plist 설정 ->** [**링크**](https://developers.google.com/admob/ios/quick-start?hl=ko#update_your_infoplist)

* AppID
* SKAdNetworkIdentifier

<details>

<summary>AppID &#x26; <strong>SKAdNetwork (2024.03.04)</strong></summary>

```html
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
<key>SKAdNetworkItems</key>
<array>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>cstr6suwn9.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4fzdc2evr5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>2fnua5tdw4.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ydx93a7ass.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>p78axxw29g.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>v72qych5uu.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ludvb6z3bs.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>cp8zw746q7.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3sh42y64q3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>c6k4g5qg8m.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>s39g8k73mm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3qy4746246.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>hs6bdukanm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>mlmmfzh3r3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>v4nxqhlyqp.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>wzmmz9fp6w.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>su67r6k2v3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>yclnxrl5pm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>7ug5zh24hu.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>gta9lk7p23.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>vutu7akeur.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>y5ghdn5j9k.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>v9wttpbfk9.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>n38lu8286q.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>47vhws6wlr.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>kbd757ywx3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>9t245vhmpl.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>a2p9lx4jpn.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>22mmun2rn5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4468km3ulz.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>2u9pt9hc89.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>8s468mfl3y.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ppxm28t8ap.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>uw77j35x4d.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>pwa73g5rt2.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>578prtvx9j.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4dzt52r2t5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>tl55sbb4fm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>e5fvkxwrpn.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>8c4e2ghe7u.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3rd42ekr43.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3qcr597p9d.skadnetwork</string>
  </dict>
</array>
```

</details>



### 3) 초기화

{% tabs %}
{% tab title="Objective-C" %}
```swift
[[GADMobileAds sharedInstance] startWithCompletionHandler:nil]; 
```
{% endtab %}

{% tab title="Swift" %}
```swift
import GoogleMobileAds

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

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

    GADMobileAds.sharedInstance().start(completionHandler: nil)

    return true
  }
}
```
{% endtab %}
{% endtabs %}



***

## Native Layout 설정

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

<figure><img src="https://50533756-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqmkw7pJLtjFGD5fwChbN%2Fuploads%2Fm3X2vO9ZTuWsmCXymR9q%2Fimage.png?alt=media&#x26;token=cfcbeae4-6493-4077-8a3e-6e76862f727e" alt=""><figcaption></figcaption></figure>

ADOP는 ViewController에 UI component 영역을 바로 생성하지 않고 xib 파일을 사용하여 view를 add합니다.

{% hint style="info" %}
UI 배치와 관련된 상세한 가이드는 아래 링크의 AdMob 가이드를 참고해 주시기 바랍니다.

[https://developers.google.com/admob/ios/native/advanced?hl=ko#code\_example](https://developers.google.com/admob/ios/native/advanced?hl=ko#code_example)
{% endhint %}

{% hint style="warning" %}
adopNativeAdVie를 AdPopcornNativeAd addsubView해 주고 layout을 잡아 주어야 광고가 보입니다.
{% endhint %}

{% tabs %}
{% tab title="Objective-C" %}
```objectivec
#import <AdPopcornSSP/AdPopcornSSPNativeAd.h>	
#import "ADOPAdapter.h"

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    GADNativeAdView *adopNativeAdView =
    [[NSBundle mainBundle] loadNibNamed:@"ADOPNativeAdView" owner:nil options:nil].firstObject;
    
    APAdopNativeAdRenderer *apAdopNativeAdRenderer = [[APAdopNativeAdRenderer alloc] init];
    apAdopNativeAdRenderer.adopNativeAdView = adopNativeAdView ;
    [_adPopcornSSPNativeAd setADOPRenderer:apAdopNativeAdRenderer superView: adopNativeAdView];
}
```
{% endtab %}

{% tab title="Swift" %}
```swift
override func viewDidLoad() 
{
    super.viewDidLoad()
    adopNativeAdView = Bundle.main.loadNibNamed("ADOPNativeAdView",
                             owner: nil,
                             options: nil)?.first as? GADNativeAdView
                             
    apAdopNativeAdRenderer = APAdopNativeAdRenderer.init()
    apAdopNativeAdRenderer.adopNativeAdView = adopNativeAdView 
    adPopcornSSPNativeAd.setADOPRenderer(apAdopNativeAdRenderer, superView: adopNativeAdView)
}
```
{% endtab %}
{% endtabs %}

ADOP 의 경우 AdPopcornSSP, FAN, FAN Native Banner와 다르게 xib 파일을 이용하여 직접 View를 생성한 뒤, 해당 xib파일을 읽어와 renderer에 전달해 주어야 함.

<mark style="color:red;">`APAdopNativeAdRenderer`</mark>에 GADNativeAdView와 superView를 세팅 후, <mark style="color:red;">`setADOPRenderer:superView:`</mark> API를 통해 render와 adopNativeAdView를 sdk에 최종적으로 전달합니다.

