SDK 이전

이 페이지에서는 현재 및 이전 버전의 이전에 대해 설명합니다.

10에서 v11로 이전

최소 배포 대상

최소 배포 대상이 iOS 12로 늘어났습니다.

최소 Xcode 버전

지원되는 최소 Xcode 버전이 15.1로 늘어났습니다.

iOS 12 광고 게재 중단

Google 모바일 광고 SDK 버전 11.0.0은 iOS 13을 실행하는 기기에만 광고 게재 및 그 이상입니다.

GoogleAppMeasurement 종속 항목이 삭제됨

버전 11.0.0에서 GoogleAppMeasurement 일정이 삭제되었습니다. AdMob에서 사용자 측정항목 전환의 기반이 된 종속 항목은 중단되었습니다. 받는사람 AdMob에서 사용자 측정항목을 계속 수집하므로 AdMob 앱을 Firebase에 연결하고 새로운 Firebase용 Google 애널리틱스 SDK를 있습니다.

전체 화면 광고 표시 방식 변경

다양한 광고 형식에 영향을 주는 변경사항은 다음과 같습니다.

  • 앱 오프닝 광고
  • 전면 광고
  • 리워드 제공됨
  • 보상형 전면 광고

-canPresentFromRootViewController:error:의 뷰 컨트롤러 매개변수 -presentFromRootViewController:는 null을 허용합니다. nil이 전달되면 광고는 뷰 컨트롤러 계층 구조의 최상위 뷰 컨트롤러에서 표현됩니다.

메서드 삭제됨

다음 메서드는 삭제됩니다.

v11.0.0 유형 메서드 참고
GADAppOpenAd load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) 대신 load(withAdUnitID adUnitID: String, request: GADRequest?)를 사용하세요.
GADMediationBannerAdEventDelegate willBackgroundApplication() 교체품 없음.
GADMediationInterstitialAdEventDelegate willBackgroundApplication() 교체품 없음.
GADMediationNativeAdEventDelegate willBackgroundApplication() 교체품 없음.
GADMediationRewardedAdEventDelegate didRewardUser(with reward: GADAdReward) 대신 didRewardUser()를 사용하세요.
GADMediatedUnifiedNativeAdNotificationSource mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) 교체품 없음.
GADRequestConfiguration setSameAppKeyEnabled(_ enabled: Bool) 대신 setPublisherFirstPartyIDEnabled(_ enabled: Bool)를 사용하세요.
tagForUnderAge(ofConsent underAgeOfConsent: Bool) 대신 tagForUnderAgeOfConsent 속성을 사용하세요.
tag(forChildDirectedTreatment childDirectedTreatment: Bool) 대신 tagForChildDirectedTreatment 속성을 사용하세요.

삭제된 속성

다음 속성이 삭제됩니다.

v11.0.0 클래스 속성 참고
GADMediationAdConfiguration hasUserLocation 교체품 없음.
userLatitude
userLongitude
userLocationAccuracyInMeters
childDirectedTreatment 대신 GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment를 사용하세요.
GADResponseInfo adNetworkClassName 대신 loadedAdNetworkResponseInfoadNetworkClassName를 사용하세요.

GADAdFormatUnknown(GADAdFormatUnknown)이 삭제됨

GADAdFormatUnknown을(를) 대체 없이 삭제했습니다.

로깅 SDK 버전 변경사항

버전 11.0.0에서는 sdkVersion가 삭제됩니다. Google 모바일 광고 SDK 버전을 로깅하려면 다음 단계를 따르세요. versionNumber 사용 하세요.

버전 10.0.0

GADMobileAds.sharedInstance().sdkVersion

버전 11.0.0

GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)

GADAdLoader 오류 처리 변경사항

버전 11.0.0부터 GADAdLoaderdelegate 요청된 광고 유형을 준수하지 않습니다 위임 프로토콜 이전에는 광고 요청이 이루어진 후 실패합니다.

테스트 동작 변경사항

다음의 경우 업데이트된 조건을 보여주는 표를 참고하세요. 속성은 true를 반환합니다.

클래스 속성
GADMediationAdConfiguration isTestRequest
GADCustomEventRequest isTesting
v10.0.0 v11.0.0
  • 기기가 testDeviceIdentifiers에 테스트 기기로 명시적으로 선언됩니다.
  • 기기가 testDeviceIdentifiers에 테스트 기기로 명시적으로 선언됩니다.
  • 기기가 시뮬레이터입니다.
  • 기기가 Ad Manager UI에서 테스트 기기로 명시적으로 선언됩니다.

v9에서 v10으로 이전

iOS 11 광고 게재 중단

Google 모바일 광고 SDK 버전 10.0.0은 iOS 12 이상을 실행하는 기기에만 광고를 게재합니다.

Google 모바일 광고 SDK 버전 10.0.0으로 업그레이드해도 iOS 11 및 iOS 10 기기에서 앱이 중단되지는 않지만 광고가 게재되지는 않습니다.

Ad Manager 앱 ID 요구사항

이제 모든 Ad Manager 앱의 Info.plist에 Ad Manager 앱 ID가 필요하며 ca-app-pub-################~########## 형식을 사용해야 합니다. 자세한 내용은 Info.plist 업데이트를 참고하세요.

GoogleAppMeasurement.xcframework 요구사항

이제 모든 Ad Manager 앱에 GoogleAppMeasurement.xcframework가 필요합니다. Cocoapods 또는 Swift Package Manager를 통해 Google 모바일 광고 SDK를 설치하는 경우에는 추가 작업이 필요하지 않습니다. 프레임워크를 수동으로 설치하는 경우 자세한 내용은 수동 다운로드를 참고하세요.

비트코드를 사용한 빌드 지원 중단

이제 Google 모바일 광고 SDK를 통합하려면 모바일 앱에서 비트코드를 사용 중지해야 합니다.

삭제된 유형

유형 Notes
GADGender 교체되지 않음.
GADMRewardBasedVideoAdNetworkAdapterProtocol 네트워크 선택에 표시된 모든 리워드 미디에이션 어댑터는 1년 넘게 이러한 프로토콜의 사용을 중단했습니다. 미디에이션 및 맞춤 이벤트에는 GADMediationAdapter를 사용하세요.
GADMRewardBasedVideoAdNetworkConnectorProtocol

삭제된 속성

다음 속성은 교체 없이 삭제되었습니다.

v10.0.0 클래스 속성
GADMediationAdRequest userBirthday
userGender
userHasLocation
userLatitude
userLongitude
userLocationAccuracyInMeters
userLocationDescription
GADCustomEventRequest userHasLocation
userLatitude
userLongitude
userLocationAccuracyInMeters
userLocationDescription

v8에서 v9로 이전

iOS 10 광고 게재 중단

Google 모바일 광고 SDK 버전 9.0.0에서 지원하는 최소 iOS 버전은 iOS 11입니다.

Google 모바일 광고 SDK 버전 9.0.0으로 업그레이드해도 iOS 10 기기에서 앱이 중단되지는 않지만 이러한 기기에는 광고가 게재되지 않습니다.

상태 표시줄 컨트롤 더 엄격하게 적용

버전 9.0.0부터는 앱에서 전체 화면 형식의 광고를 표시할 때 광고가 상태 표시줄의 표시 방식을 제어할 수 있는지 확인해야 합니다. 그러지 않으면 로그에 오류 메시지가 표시됩니다.

앱에서 뷰 컨트롤러의 레이아웃에 따라 이러한 변경이 필요하지 않을 수 있습니다. 광고의 rootViewController에서 childViewControllerForStatusBarHidden 속성을 설정해야 하는지 확인하세요.

adDidPresentFullScreenContent: 의 이름을 adWillPresentFullScreenContent:로 변경

동작 변경사항은 없습니다. 대리자 메서드는 광고가 표시되기 직전에 호출되므로 새 메서드 이름이 기능을 더 잘 반영합니다.

GADRequest에서 위치 설정 API 삭제

Google에서는 광고 타겟팅을 위해 위치 데이터를 사용하지 않으므로 GADRequest에서 - (void)setLocationWithLatitude:longitude:accuracy:가 삭제되었습니다. 필요한 경우 서드 파티 API를 사용하여 서드 파티 광고 네트워크에 정보를 제공하세요.

맞춤 이벤트 인터페이스 지원 중단

맞춤 이벤트를 사용하면 미디에이션을 사용하는 게시자가 Ad Manager 지원되는 광고 네트워크가 아닌 광고 네트워크에 대한 폭포식 구조 미디에이션을 추가할 수 있습니다.

모든 맞춤 이벤트 프로토콜이 지원 중단되었습니다. 대신 기존 GADMediationAdapterGADMediationAdEventDelegate 프로토콜을 사용하여 동일한 기능을 제공하세요. 이번 변경사항으로 명확성이 개선되고 이전에는 사용할 수 없었던 보상형 광고 및 전면 스크롤 광고용 맞춤 이벤트를 만들 수 있습니다.

API

아래 표에는 버전 9.0.0부터 사용해야 하는 맞춤 이벤트 API에 해당하는 미디에이션 어댑터 API가 나와 있습니다.

v8 v9
GADCustomEventBanner
GADCustomEvent전면 광고
GADCustomEventNativeAd
GADMediationAdapter GADMediationBannerAd
GADMediationInterstitialAd
GADMediationInterscrollerAd
GADMediationRewardedAd
GADMediationNativeAdNativeAd
delegate 대리자는 GADMediationAdapter 클래스에 있는 각 로드 함수의 로드 완료 핸들러에 의해 반환됩니다.
-init -init
-requestBannerAd:parameter:label:request: -loadBannerForAdConfiguration:completionHandler:
-requestInterstitialAdWithParameter:label:request: -loadInterstitialForAdConfiguration:completionHandler:
-requestNativeAdWithParameter:request:adTypes:options:rootViewController: -loadNativeAdForAdConfiguration:completionHandler:
N/A -loadInterscrollerAdForAdConfiguration:completionHandler:
N/A -loadRewardedAdForAdConfiguration:completionHandler:
-presentFromRootViewController: -presentFromViewController:
-handlesUserClicks -handlesUserClicks
-handlesUserImpressions -handlesUserImpressions

위임 메서드

아래 표에는 버전 9.0.0부터 사용해야 하는 맞춤 이벤트 대리자 메서드에 해당하는 미디에이션 광고 이벤트 대리자 메서드가 나와 있습니다.

v8 v9
GADCustomEventBannerDelegate
GADCustomEventInterstitialDelegate
GADCustomEventNativeAdDelegate
GADMediationAdEventDelegate GAD미디에이션 광고
-customEventBanner:didReceiveAd:
-customEventInterstitialDidReceiveAd:
광고 로드 상태는 GADMediationAdapter 클래스에 있는 각 로드 함수의 로드 완료 핸들러에 포함됩니다.
-customEventBanner:didFailAd:
-customEventInterstitial:didFailAd:
-customEventBannerWasClicked:
-customEventInterstitialWasClicked:
-reportClick
-customEventBannerWillPresentModal:
-customEventInterstitialWillPresentModal:
-willPresentFullScreenView
-customEventBannerWillDismissModal:
-customEventInterstitialWillDismissModal:
-willDismissFullScreenView
-customEventBannerDidDismissModal:
-customEventInterstitialDidDismissModal:
-didDismissFullScreenView
-customEventBannerWillLeaveApplication:
-customEventInterstitialWillLeaveApplication:
-willBackgroundApplication
viewControllerForPresentingModalView -[GADMediationBannerAd view]

기타 삭제되거나 대체된 메서드 및 상수

메서드, 상수 또는 속성 변경사항
kGAD- 접두사가 붙은 상수 삭제되었습니다. GAD- 접두사가 붙은 상수를 사용합니다.
GADAdNetworkResponseInfo credentials님이 삭제되었습니다. 대신 adUnitMapping를 사용하세요.
GAMRequest GAMRequestkGAMSimulatorID가 지원 중단되었습니다. 대신 GADRequestConfigurationGADSimulatorID를 사용하세요.
GADCustomNativeAd GADCustomNativeAdmediaView가 지원 중단되었습니다. 대신 mediaContent를 사용하세요.
GoogleMobileAds의 인앱 구매 API GoogleMobileAdsinAppPurchase API를 삭제했습니다.

v7에서 v8로 이전

Google 모바일 광고 SDK 버전 8.0.0은 몇 가지 주요 변경사항을 도입했을 뿐만 아니라 일부 이름 변경 및 API 삭제가 포함됩니다

전체 화면 형식 API 업데이트

버전 8.0.0부터 전면 광고와 보상형 광고는 보다 일관성 있는 화면 광고 스타일을 제공합니다. 이러한 새로운 전체 화면 광고 API에는 버전 7 전체 화면 광고 API와의 주요 차이점은 다음과 같습니다.

  1. 정적 클래스 메서드 load

    이전에 전체 화면 광고를 로드/게재하는 방식은 다음과 같습니다.

    1. 광고 객체 인스턴스를 만들고 이에 대한 참조를 유지합니다.
    2. 로드를 처리하고 콜백을 표시하는 대리자를 할당합니다.
    3. 광고를 로드합니다.
    4. isReady를 사용하여 광고가 로드되었는지 확인합니다.
    5. 광고를 게재합니다.

    버전 8에서는 접근 방식이 약간 변경됩니다. 로드 콜백이 더 이상 지원 중단됨 델리게이트에 해당합니다. 대신 load 메서드에 다음과 같이 전달됩니다. 완료 핸들러:

    1. 광고 클래스에서 정적 로드 메서드를 호출하고 로드 완료 제공 처리됩니다.
    2. 로드 완료 콜백에서는 반환합니다.
    3. 콜백 표시를 처리하는 대리자를 할당합니다.
    4. 광고를 게재합니다.

    새로운 접근 방식은 다음과 같은 이점을 제공합니다.

    • 로드되지 않은 광고에 대한 참조는 없습니다.
    • 광고가 로드되는 동안 광고 객체를 유지하지 않아도 됩니다.
  2. 일관된 광고 이벤트.

    이벤트 유형 기존 API v8 API
    로드 이벤트 GADInterstitialDelegate 또는 GADRewardedAdDelegate GAMInterstitialAdLoadCompletionHandler 또는 GADRewardedAdLoadCompletionHandler
    프레젠테이션 이벤트 GADFullScreenContentDelegate

    이전에는 모든 광고 이벤트를 수신 대기하려면 는 GADInterstitialDelegate 드림 프로토콜을 전면 광고의 대리자 속성에 추가하거나 는 GADRewardedAdDelegate 형식을 보상형 광고의 대리자 속성에 직접 할당합니다. 사용할 수 있습니다. 이 동일한 대리자에는 수명 주기입니다.

    버전 8에서는 로드 이벤트와 프레젠테이션 이벤트가 별개입니다. 이제 할 수 있습니다. 등록 GADFullScreenContentDelegate 드림 광고 게재 전에 언제든지 위임을 사용해야 합니다. 각각에 고유한 광고 로드 이벤트 형식인 경우 로드 메서드에서 전달된 단일 로드 완료 핸들러로 이동합니다.

전면 광고

광고 로드

아래의 코드 스니펫은 전면 광고를 로드하고 광고 로드에 성공하거나 실패할 때 발생합니다.

버전 7

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADInterstitialDelegate {

  var interstitial: DFPInterstitial!

  override func viewDidLoad() {
    super.viewDidLoad()
    interstitial = DFPInterstitial(adUnitID: "/21775744923/example/interstitial")
    interstitial.delegate = self
    let request = GAMRequest()
    interstitial.load(request)
  }

  /// Tells the delegate an ad request succeeded.
  func interstitialDidReceiveAd(_ ad: DFPInterstitial) {
    print("Interstitial ad loaded.")
  }

  /// Tells the delegate an ad request failed.
  func interstitial(_ ad: DFPInterstitial, didFailToReceiveAdWithError error: GADRequestError) {
    print("Interstitial ad failed to load with error: \(error.localizedDescription)")
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) DFPInterstitial *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[DFPInterstitial alloc]
      initWithAdUnitID:@"/21775744923/example/interstitial"];
  self.interstitial.delegate = self;
  GAMRequest *request = [GAMRequest request];
  [self.interstitial loadRequest:request];
}

/// Tells the delegate an ad request succeeded.
- (void)interstitialDidReceiveAd:(DFPInterstitial *)ad {
  NSLog(@"Insterstitial ad loaded.");
}

/// Tells the delegate an ad request failed.
- (void)interstitial:(DFPInterstitial *)ad
    didFailToReceiveAdWithError:(GADRequestError *)error {
  NSLog(@"Interstitial ad failed to load with error: %@", [error localizedDescription]);
}

v8

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADFullScreenContentDelegate {

  var interstitial: GAMInterstitialAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    let request = GAMRequest()
    GAMInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738",
                                request: request,
                      completionHandler: { (ad, error) in
                        if let error = error {
                          print("Failed to load interstitial ad with error: \(error.localizedDescription)")
                          return
                        }
                        self.interstitial = ad
                        self.interstitial.fullScreenContentDelegate = self
                      }
    )
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GAMInterstitialAd *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  GAMRequest *request = [GAMRequest request];
  [GAMInterstitialAd loadWithAdUnitID:@"/21775744923/example/interstitial"
                              request:request
                    completionHandler:^(GAMInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]);
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

디스플레이 광고

버전 7

Swift

func showInterstitial() {
  ...
  if interstitial.isReady {
    interstitial.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
}

Objective-C

- (void)showInterstitial: {
  ...
  if (self.interstitial.isReady) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

v8

Swift

func showInterstitial() {
  ...
  if let ad = interstitial {
    ad.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
}

Objective-C

- (void)showInterstitial: {
  ...
  if (self.interstitial) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

프레젠테이션 광고 이벤트

아래의 코드 스니펫은 광고가 표시 (성공 또는 실패)와 해제될 때를 나타냅니다.

버전 7

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  interstitial = DFPInterstitial(adUnitID: "/21775744923/example/interstitial")
  interstitial.delegate = self
  ...
}

/// Tells the delegate that an interstitial will be presented.
func interstitialWillPresentScreen(_ ad: DFPInterstitial) {
  print("Interstitial ad will be presented.")
}

/// Tells the delegate the interstitial is to be animated off the screen.
func interstitialWillDismissScreen(_ ad: DFPInterstitial) {
  print("Interstitial ad will be dismissed.")
}

/// Tells the delegate the interstitial had been animated off the screen.
func interstitialDidDismissScreen(_ ad: DFPInterstitial) {
  print("Interstitial ad dismissed.")
}

/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
///
/// This is not a reliable callback for an ad click event and is removed in
/// version 8. If you wish to listen to an ad causing a user to leave the app,
/// use applicationWillResignActive: or sceneWillResignActive: instead.
func interstitialWillLeaveApplication(_ ad: DFPInterstitial) {
  print("Interstitial ad will leave application.")
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[DFPInterstitial alloc] initWithAdUnitID:"/21775744923/example/interstitial"];
  self.interstitial.delegate = self;
  ...
}

/// Tells the delegate that an interstitial will be presented.
- (void)interstitialWillPresentScreen:(DFPInterstitial *)ad {
  NSLog(@"Interstitial ad will be presented.");
}

/// Tells the delegate the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(DFPInterstitial *)ad {
  NSLog(@"Interstitial ad will be dismissed.");
}

/// Tells the delegate the interstitial had been animated off the screen.
- (void)interstitialDidDismissScreen:(DFPInterstitial *)ad {
  NSLog(@"Interstitial ad dismissed.");
}

/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
///
/// This is not a reliable callback for an ad click event and is removed in
/// version 8. If you wish to listen to an ad causing a user to leave the app,
/// use applicationWillResignActive: or sceneWillResignActive: instead.
- (void)interstitialWillLeaveApplication:(DFPInterstitial *)ad {
  NSLog(@"Interstitial ad will leave application.");
}

v8

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GAMRequest()
  GAMInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738",
                              request: request,
                    completionHandler: { (ad, error) in
                      if let error = error {
                        print(error.localizedDescription)
                        return
                      }
                      self.interstitial = ad
                      self.interstitial.fullScreenContentDelegate = self
                    }
  )
}

func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did present full screen content.")
}

func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
  print("Ad failed to present full screen content with error \(error.localizedDescription).")
}

func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did dismiss full screen content.")
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  GAMRequest *request = [GAMRequest request];
  [GAMInterstitialAd loadWithAdUnitID:@"/21775744923/example/interstitial"
                              request:request
                    completionHandler:^(GAMInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"interstitial:didFailToReceiveAdWithError: %@", [error localizedDescription])
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

- (void)adDidPresentFullScreenContent:(id)ad {
  NSLog(@"Ad did present full screen content.");
}

- (void)ad:(id)ad didFailToPresentFullScreenContentWithError:(NSError *)error {
  NSLog(@"Ad failed to present full screen content with error %@.", [error localizedDescription]);
}

- (void)adDidDismissFullScreenContent:(id)ad {
  NSLog(@"Ad did dismiss full screen content.");
}

리워드 제공됨

광고 로드

버전 7

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADRewardedAdDelegate {
  /// The rewarded ad.
  var rewardedAd: GADRewardedAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
    rewardedAd.delegate = self
    rewardedAd?.load(GAMRequest()) { error in
      if let error = error {
        print("Rewarded ad failed to load with error: \(error.localizedDescription)")
      } else {
        print("Rewarded ad loaded.")
      }
    }
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  self.rewardedAd = [[GADRewardedAd alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"];
  self.rewardedAd.delegate = self;
  GAMRequest *request = [GAMRequest request];
  [self.rewardedAd loadRequest:request completionHandler:^(GADRequestError * _Nullable error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
    } else {
      NSLog(@"Rewarded ad loaded.");
    }
  }];
}

v8

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADFullScreenContentDelegate {
  /// The rewarded ad.
  var rewardedAd: GADRewardedAd?

  override func viewDidLoad() {
  super.viewDidLoad()
  let request = GAMRequest()
  GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136",
                          request: request, completionHandler: { (ad, error) in
                            if let error = error {
                              print("Rewarded ad failed to load with error: \(error.localizedDescription)")
                              return
                            }
                            self.rewardedAd = ad
                            self.rewardedAd?.fullScreenContentDelegate = self
                          }
  )
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  GAMRequest *request = [GAMRequest request];
  [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"
                          request:request
                completionHandler:^(GADRewardedAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
      return;
    }
    self.rewardedAd = ad;
    NSLog(@"Rewarded ad loaded.");
    self.rewardedAd.fullScreenContentDelegate = self;
}

디스플레이 광고 및 보상 처리

보상형 광고를 사용하려면 사용자가 리워드를 받을 때 이벤트를 처리해야 합니다. 다음으로 바꿉니다. GADRewardedAd API 버전 7에서 rewardedAd:userDidEarnReward:: GADRewardedAdDelegate 프로토콜의 일부. 버전 8의 경우 다음을 위해 GADUserDidEarnRewardHandler를 구현합니다. 없습니다.

버전 7

Swift

func showRewardedAd() {
  ...
  if rewardedAd.isReady {
    rewardedAd.present(fromRootViewController: self delegate:self)
  } else {
    print("Ad wasn't ready")
  }
}

/// Tells the delegate that the user earned a reward.
func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarnReward: GADAdReward) {
  // TODO: Reward the user.
}

Objective-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd.isReady) {
    [self.rewardedAd presentFromRootViewController:self delegate:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

/// Tells the delegate that the user earned a reward.
- (void)rewardedAd:(GADRewardedAd *)rewardedAd userDidEarnReward:(GADAdReward *)reward {
  // TODO: Reward the user.
}

v8

Swift

func showRewardedAd() {
  ...
  if let ad = rewardedAd {
      ad.present(fromRootViewController: self,
               userDidEarnRewardHandler: {
                 let reward = ad.adReward
                 // TODO: Reward the user.
               }
      )
  } else {
    print("Ad wasn't ready")
  }
}

Objective-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd) {
    [self.rewardedAd presentFromRootViewController:self
                          userDidEarnRewardHandler:^ {
      GADAdReward *reward = self.rewardedAd.adReward;
      // TODO: Reward the user.
    }];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

프레젠테이션 광고 이벤트

GADRewardedAd API를 사용하여 GADRewardedAdDelegate를 메서드에 전달합니다. 입니다. GADRewardedAd API를 사용하여 광고를 표시하기 전에 광고 속성으로 GADFullscreenContentDelegate 있습니다.

버전 7

Swift

func showRewardedAd() {
  ...
  if rewardedAd.isReady {
    rewardedAd.present(fromRootViewController: self delegate:self)
  } else {
    print("Ad wasn't ready")
  }
}

/// Tells the delegate that the rewarded ad was presented.
func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) {
  print("Rewarded ad presented.")
}
/// Tells the delegate that the rewarded ad was dismissed.
func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) {
  print("Rewarded ad dismissed.")
}
/// Tells the delegate that the rewarded ad failed to present.
func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) {
  print("Rewarded ad failed to present with error: \(error.localizedDescription).")
}

Objective-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd.isReady) {
    [self.rewardedAd presentFromRootViewController:self delegate:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

/// Tells the delegate that the rewarded ad was presented.
- (void)rewardedAdDidPresent:(GADRewardedAd *)rewardedAd {
  NSLog(@"Rewarded ad presented.");
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)rewardedAd:(GADRewardedAd *)rewardedAd didFailToPresentWithError:(NSError *)error {
  NSLog(@"Rewarded ad failed to present with error: %@",
        [error localizedDescription]);
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)rewardedAdDidDismiss:(GADRewardedAd *)rewardedAd {
  NSLog(@"Rewarded ad dismissed.");
}

v8

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GAMRequest()
  GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136",
                          request: request, completionHandler: { (ad, error) in
                            if let error = error {
                              print(error.localizedDescription)
                              return
                            }
                            self.rewardedAd = ad
                            self.rewardedAd?.fullScreenContentDelegate = self
                          }
  )
}

/// Tells the delegate that the rewarded ad was presented.
func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Rewarded ad presented.")
}
/// Tells the delegate that the rewarded ad was dismissed.
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Rewarded ad dismissed.")
}
/// Tells the delegate that the rewarded ad failed to present.
func ad(_ ad: GADFullScreenPresentingAd,
    didFailToPresentFullScreenContentWithError error: Error) {
  print("Rewarded ad failed to present with error: \(error.localizedDescription).")
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];

  GAMRequest *request = [GAMRequest request];
  [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"
                          request:request
                completionHandler:^(GADRewardedAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
      return;
    }
    self.rewardedAd = ad;
    NSLog(@"Rewarded ad loaded.");
    self.rewardedAd.fullScreenContentDelegate = self;
}

/// Tells the delegate that the rewarded ad was presented.
- (void)adDidPresentFullScreenContent:(id)ad {
  NSLog(@"Rewarded ad presented.");
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)ad:(id)ad
    didFailToPresentFullScreenContentWithError:(NSError *)error {
  NSLog(@"Rewarded ad failed to present with error: %@",
       [error localizedDescription]);
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)adDidDismissFullScreenContent:(id)ad {
  NSLog(@"Rewarded ad dismissed.");
}

기존 GADRewardedBasedVideoAd API 삭제

최신 GADRewardedAd 드림 API는 2019년 3월에 처음 도입되었으며 API를 사용할 수 있습니다. 기존에 비해 더 개선되었습니다. 둘 이상의 로드 기능을 포함하는 GADRewardedBasedVideoAd API 한 번에 게재해야 합니다.

SDK 버전 8.0.0에서 기존 GADRewardedBasedVideoAd API가 삭제되었습니다.

스마트 배너가 지원 중단되고 적응형 배너로 대체됨

스마트 배너 광고가 지원 중단됨 적응형 배너를 선호함 있습니다. 적응형 배너는 광고 너비를 설정합니다. 전체 너비 배너를 계속 사용하려면 다음 코드 스니펫에서와 같이 적응형 배너를 계속 사용해야 합니다.

Swift

class ViewController: UIViewController {

  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    // Note: The safe area is not known until viewWillAppear.
    let adSize = getFullWidthAdaptiveAdSize()
  }

  func getFullWidthAdaptiveAdSize() -> GADAdSize {
    // Here safe area is taken into account, hence the view frame is used after the
    // view has been laid out.
    let frame = { () -> CGRect in
      if #available(iOS 11.0, *) {
        return view.frame.inset(by: view.safeAreaInsets)
      } else {
        return view.frame
      }
    }()
    return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width)
  }
}

Objective-C

@implementation ViewController

- (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  // Note: The safe area is not known until viewWillAppear.
  GADAdSize adSize = [self getFullWidthAdaptiveAdSize];
}

- (GADAdSize)getFullWidthAdaptiveAdSize {
  CGRect frame = self.view.frame;
  // Here safe area is taken into account, hence the view frame is used after
  // the view has been laid out.
  if (@available(iOS 11.0, *)) {
    frame = UIEdgeInsetsInsetRect(self.view.frame, self.view.safeAreaInsets);
  }
  return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width);
}

@end

애플리케이션 나가기 콜백 삭제

모든 광고 형식의 willLeaveApplication 콜백은 삭제되어 applicationDidEnterBackground:sceneDidEnterBackground: 메서드를 참조하세요. OS 수준 API를 사용하면 어떤 이유로든 사용자가 앱을 나갈 때마다 알림을 받을 수 있습니다. 광고 상호작용 때문인지 아닌지를 확인할 수 있습니다.

willLeaveApplication 콜백은 이 이벤트에 이 콜백을 사용하여 클릭을 보고해도 정확하게 측정할 수 있습니다 예를 들어 AdChoices를 클릭하면 콜백을 호출했으나 이벤트를 계산하지 않은 외부 브라우저를 실행한 아이콘 클릭합니다.

수업 이름 변경

아래 표에는 버전 8 요약:

  • GADUnifiedNativeAd와 관련된 모든 클래스의 이름이 다음으로 변경되었습니다. GADNativeAd입니다.
  • GADRewardBasedVideoAd, GADNativeExpressAdView, GADInstreamAd이(가) 있습니다. 삭제되었습니다.
  • DFP 접두사가 있는 모든 클래스가 GAM 접두사로 대체되었습니다.
v7.68.0 클래스 v8.0.0 클래스
DFPBannerView GAMBannerView
DFPBannerViewOptions GAMBannerViewOptions
DFPInterstitial GAMInterstitialAd
DFPRequest GAMRequest
GADRequestError NSError
GADUnifiedNativeAdView GADNativeAdView
GADUnifiedNativeAd GADNativeAd
GADUnifiedNativeAdAssetIdentifiers GADNativeAdAssetIdentifiers
GADUnifiedNativeAdDelegate GADNativeAdDelegate
GADUnifiedNativeAdUnconfirmedClickDelegate GADNativeAdUnconfirmedClickDelegate
GADNativeCustomTemplateAd GADCustomNativeAd
GADNativeCustomTemplateAdLoaderDelegate GADCustomNativeAdLoaderDelegate
GADNativeAdDelegate GADCustomNativeAdDelegate
GADInAppPurchase 삭제됨
GADInterstitial GADInterstitialAd
GADNativeExpressAdView 삭제됨
GADRewardBasedVideoAd 삭제됨
GADInstreamAd 삭제됨
GADInstreamAdView 삭제됨

삭제/대체된 메서드

아래 표에는 버전 8의 구체적인 변경사항이 나열되어 있습니다. 요약:

  • 이전에 지원 중단된 메서드와 속성이 삭제되었습니다.
  • 모든 형식에서 -willLeaveApplication: 대리자 메서드가 삭제되었습니다.
  • 광고 네트워크 클래스 이름이 GADResponseInfo 속성으로 이동했습니다.
  • 테스트 기기 식별자가 GADRequestConfiguration로 이동되었습니다. 속성
v7.68.0 클래스 v7.68.0 API v8.0.0 API 참고
GADMobileAds +configureWithApplicationID: -startWithCompletionHandler: 이제 앱 ID가 Info.plist에 설정됩니다.
+disableAutomatedInAppPurchaseReporting -disableAutomatedInAppPurchaseReporting
+disableSDKCrashReporting -disableSDKCrashReporting
GADRequest testDevices GADRequestConfiguration.testdeviceidentifiers testDeviceIdentifiers 속성은 모든 광고 요청에 적용되지만 이전 testDevices 속성이 요청에 따라 설정되었습니다.
gender 삭제됨
생일 삭제됨
+sdkVersion GADMobileAds.sharedInstance.sdkVersion
-setBirthdayWithMonth:day:year: 삭제됨
-setLocationWithDescription: -setLocationWithLatitude:longitude:accuracy:
-tagForChildDirectedTreatment: [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment]
GADErrorCode kGADError* GADError* k 접두사가 모든 오류 코드 상수에서 삭제됩니다.
GADBannerView hasAutoRefreshed autoloadEnabled
inAppPurchaseDelegate 삭제됨
mediatedAdView 삭제됨
adNetworkClassName responseInfo.adNetworkClassName
DFPBannerView -setValidAdSizesWithSizes: -setValidAdSizes:
DFPBannerViewOptions -adSizeDelegate 삭제됨
GADBannerViewDelegate -adViewDidReceiveAd: -bannerViewDidReceiveAd:
-adView:didFailToReceiveAdWithError: -bannerView:didFailToReceiveAdWithError:
-adViewWillPresentScreen: -bannerViewWillPresentScreen:
-adViewWillDismissScreen: -bannerViewWillDismissScreen:
-adViewDidDismissScreen: -bannerViewDidDismissScreen:
-adViewWillLeaveApplication: 삭제됨
GADNativeCustomTemplateAd templateID GADCustomNativeAd.formatID
-performClickOnAssetWithKey:customClickHandler: -performClickOnAssetWithKey:
GADNativeAdImageAdLoaderOptions preferredImageOrientation GADNativeAdMediaAdOptions.mediaAspectRatio
GADInterstitial inAppPurchaseDelegate 삭제됨
isReady 삭제됨 canPresentFromRootViewController:error: 를 대신 사용하세요.
hasBeenUsed 삭제됨
-init -initWithAdUnitID:
-setAdUnitID: -initWithAdUnitID:
adNetworkClassName responseInfo.adNetworkClassName
-interstitialWillLeaveApplication: 삭제됨
GADUnifiedNativeAd videoController mediaContent.videoController
adNetworkClassName responseInfo.adNetworkClassName