디스플레이 유형 맞춤 네이티브 광고 형식 및 Open Measurement

다음과 같은 맞춤 네이티브 광고 형식과 함께 Open Measurement를 사용하려는 경우 동영상 애셋이 포함되지 않은 경우 공개 Measurement API를 직접 만들 수 있습니다. 디스플레이 유형 맞춤 네이티브 광고의 개방형 측정 형식은 버전 7.43.0 이상에서만 지원됩니다. 커스텀 동영상 애셋과 함께 네이티브 광고 형식을 사용하는 경우 Google 모바일 광고 SDK는 할 수 있습니다.

기본 요건

광고 로드

광고를 로드하는 것은 Open Measurement를 사용하든 사용하지 않든 동일합니다. 이 이 경우 간단한 ViewController를 사용하여 GADNativeCustomFormatAd:

@interface OpenMeasurementNativeCustomFormatAdViewController ()
    <GADNativeCustomFormatAdLoaderDelegate> {
  IBOutlet UIView *_parentView;
  GADAdLoader *_adLoader;
  GADNativeCustomFormatAd *_customTemplateAd;
  MySimpleNativeAdView *_simpleNativeAdView;
}

@end

@implementation OpenMeasurementNativeCustomFormatAdViewController

- (void) viewDidLoad {
  [super viewDidLoad];

  _adLoader = [[GADAdLoader alloc] initWithAdUnitID:@"your ad unit ID"
                                 rootViewController:self
                                            adTypes:@[ kGADAdLoaderAdTypeNativeCustomFormat ]
                                            options:nil];
  _adLoader.delegate = self;
  [self loadAd];
}

- (void) loadAd {
  GAMRequest *request = [GAMRequest request];
  [_adLoader loadRequest:request];
}
...
@end

보기 등록 및 측정 시작

GADNativeCustomFormatAd를 표시하려면 맞춤 광고를 등록해야 합니다. displayAdMeasurement.view를 사용하여 GADNativeTemplateAd로 뷰 속성

또한 광고 측정을 시작하도록 SDK에 명시적으로 지시해야 합니다. 이렇게 하려면 앱의 displayAdMeasurement 속성에서 startWithError: 메서드를 호출합니다. GADNativeCustomFormatAd입니다. startWithError:는 기본 후속 호출이 효과가 없습니다.

@implementation OpenMeasurementNativeCustomFormatAdViewController
...
#pragma mark - GADNativeCustomFormatAdLoaderDelegate

- (void) adLoader:(GADAdLoader *) adLoader
    didReceiveNativeCustomFormatAd:(GADNativeCustomFormatAd *)nativeCustomFormatAd {
  NSLog(@"Received custom native ad: %@", nativeCustomFormatAd);

  _customTemplateAd = nativeCustomFormatAd;

  // Put the custom native ad on screen.
  _simpleNativeAdView =
    [[NSBundle mainBundle] loadNibNamed:@"SimpleCustomNativeAdView"
                                  owner:nil
                                options:nil]
    .firstObject;
  [_parentView addSubview:_simpleNativeAdView];
  [_simpleNativeAdView populateWithCustomNativeAd:_customTemplateAd];

  // Set the top-level native ad view on the GADNativeCustomFormatAd so the
  // Google Mobile Ads SDK can track viewability for that view.
  _customTemplateAd.displayAdMeasurement.view = _simpleNativeAdView;
  // Begin measuring your impressions and clicks.
  NSError *error = nil;
  [_customTemplateAd.displayAdMeasurement startWithError:&error];

  if (error) {
    NSLog(@"Failed to start the display measurement.");
  }
}
...
@end

그러면 끝입니다. 앱을 출시하면 인증 자격을 갖춰야 하지만 IAB 인증 절차에 따라 다릅니다.