# GAM(GoogleAdManager)



#### GoogleAdManager

{% embed url="https://developers.google.com/ad-manager/mobile-ads-sdk/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/ad-manager/mobile-ads-sdk/ios/quick-start?hl=ko#update_your_infoplist)

* AppID
* SKAdNetworkIdentifier

<details>

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

<pre class="language-html"><code class="lang-html"><strong>&#x3C;&#x3C;key>GADApplicationIdentifier&#x3C;/key>
</strong>&#x3C;!-- Sample Ad Manager app ID: ca-app-pub-3940256099942544~1458002511 -->
&#x3C;string>SAMPLE_APP_ID&#x3C;/string>
&#x3C;key>SKAdNetworkItems&#x3C;/key>
&#x3C;array>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>cstr6suwn9.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>4fzdc2evr5.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>2fnua5tdw4.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>ydx93a7ass.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>p78axxw29g.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>v72qych5uu.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>ludvb6z3bs.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>cp8zw746q7.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>3sh42y64q3.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>c6k4g5qg8m.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>s39g8k73mm.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>3qy4746246.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>f38h382jlk.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>hs6bdukanm.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>mlmmfzh3r3.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>v4nxqhlyqp.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>wzmmz9fp6w.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>su67r6k2v3.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>yclnxrl5pm.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>t38b2kh725.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>7ug5zh24hu.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>gta9lk7p23.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>vutu7akeur.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>y5ghdn5j9k.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>v9wttpbfk9.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>n38lu8286q.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>47vhws6wlr.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>kbd757ywx3.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>9t245vhmpl.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>a2p9lx4jpn.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>22mmun2rn5.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>44jx6755aq.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>k674qkevps.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>4468km3ulz.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>2u9pt9hc89.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>8s468mfl3y.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>klf5c3l5u5.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>ppxm28t8ap.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>kbmxgpxpgc.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>uw77j35x4d.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>578prtvx9j.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>4dzt52r2t5.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>tl55sbb4fm.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>c3frkrj4fj.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>e5fvkxwrpn.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>8c4e2ghe7u.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>3rd42ekr43.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>97r2b46745.skadnetwork&#x3C;/string>
  &#x3C;/dict>
  &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>3qcr597p9d.skadnetwork&#x3C;/string>
  &#x3C;/dict>
&#x3C;/array>>
</code></pre>

</details>



### 3) 초기화

&#x20;**->** [**링크**](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/quick-start?hl=ko#initialize_the_mobile_ads_sdk)

{% tabs %}
{% tab title="Objective-C" %}
```swift
#import "GoogleMobileAds/GoogleMobileAds.h"

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


-(void)setupAdMob {
    [[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>

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

([샘플 프로젝트의 AdPopocornMediationAdapter > admob> native sample view 참고](https://adpopcornssp.gitbook.io/ssp-sdk/ios/undefined-10))

{% 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" %}
adMobNativeView를 AdPopcornNativeAd addsubView해 주고 layout을 잡아 주어야 광고가 보입니다.
{% endhint %}

{% tabs %}
{% tab title="undefined" %}
```objectivec
#import <AdPopcornSSP/AdPopcornSSPNativeAd.h>	
#import "AdMobAdapter.h"

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

{% tab title="Swift" %}
```swift
override func viewDidLoad() 
{
    super.viewDidLoad()
    admobNativeAdView = Bundle.main.loadNibNamed("GADNativeAdView",
                             owner: nil,
                             options: nil)?.first as? GADNativeAdView
                             
    apAdMobNativeAdRenderer= APAdMobNativeAdRenderer.init()
    apAdMobNativeAdRenderer.admobNativeAdView = admobNativeAdView
    adPopcornSSPNativeAd.setAdMobRenderer(apAdMobNativeAdRenderer, superView: admobNativeAdView)
}
```
{% endtab %}
{% endtabs %}

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

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



