SDK 이전

이 페이지에서는 최신 및 이전 버전의 Google Cloud 콘솔로의 iOS용 모바일 광고 SDK입니다. 버전 11.0.0은 1월에 출시될 예정입니다. 2024년.

SDK 버전 v10에서 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에 테스트 기기로 명시적으로 선언됩니다.
  • 기기가 시뮬레이터입니다.
  • 기기가 AdMob UI에서 테스트 기기로 명시적으로 선언됩니다.

v9에서 v10으로 이전

Ads stop serving on iOS 11

Google Mobile Ads SDK version 10.0.0 serves ads only on devices running iOS 12 and higher.

Upgrading to Google Mobile Ads SDK version 10.0.0 will not break your app on iOS 11 and iOS 10 devices, however, no ads will be served on those devices.

Building with bitcode is no longer supported

Disabling bitcode in your mobile apps is now required to integrate the Google Mobile Ads SDK.

Types removed

Type Notes
GADGender No replacement.
GADMRewardBasedVideoAdNetworkAdapterProtocol All rewarded mediation adapters listed on Choose Networks have stopped using these protocols for over a year. Use GADMediationAdapter for mediation and custom events.
GADMRewardBasedVideoAdNetworkConnectorProtocol

Properties removed

The following properties are removed with no replacement.

v10.0.0 Class Property
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를 사용하여 서드 파티 광고 네트워크에 정보를 제공하세요.

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

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

모든 맞춤 이벤트 프로토콜이 지원 중단되었습니다. 대신 기존 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 Mobile Ads SDK version 8.0.0 introduces a few major changes as well as some renames and removals of APIs.

Full-screen format API updates

Starting with version 8.0.0, interstitial and rewarded ads share a generic full screen ad style for more consistency. These new full-screen ad APIs have two major distinctions from the version 7 full-screen ad APIs:

  1. Static class method load.

    The previous approach to load/show a full-screen ad is as follows:

    1. Create an ad object instance and hold a reference to it.
    2. Assign a delegate that handles load and show callbacks.
    3. Load an ad.
    4. Check if ad is loaded using isReady.
    5. Show the ad.

    In version 8, the approach changes slightly. Load callbacks are no longer part of a delegate. Instead, they're passed into the load method as a completion handler:

    1. Call a static load method on the ad class and provide a load completion handler.
    2. In the load completion callback, keep a reference to the loaded ad that's returned.
    3. Assign a delegate that handles show callbacks.
    4. Show the ad.

    The new approach provides these benefits:

    • You won't ever have a reference to an ad that is not loaded.
    • You don't have to hold onto an ad object while it's loading.
  2. Consistent ad events.

    Event type Existing API v8 API
    Load events GADInterstitialDelegate or GADRewardedAdDelegate GADInterstitialAdLoadCompletionHandler or GADRewardedAdLoadCompletionHandler
    Presentation events GADFullScreenContentDelegate

    Previously, to listen for any ad events, you would register a class that implements the GADInterstitialDelegate protocol to an interstitial's delegate property, or register a class that implements the GADRewardedAdDelegate protocol to a rewarded ad's delegate property depending on which format you're using. This same delegate had methods related to both the loading and presentation life cycle of an ad.

    With version 8, load and presentation events are separate. You can now register a GADFullScreenContentDelegate any time prior to showing an ad instead of being required to set a single delegate prior to loading the ad. Ad load events, which are specific to each format, move to a single load completion handler passed in the load method.

Interstitial

Load ad

The code snippets below show you how to load an interstitial ad and listen for events when the ad succeeds or fails to load.

v7

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADInterstitialDelegate {

  var interstitial: GADInterstitial!

  override func viewDidLoad() {
    super.viewDidLoad()
    interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
    interstitial.delegate = self
    let request = GADRequest()
    interstitial.load(request)
  }

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

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

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADInterstitial *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"];
  self.interstitial.delegate = self;
  GADRequest *request = [GADRequest request];
  [self.interstitial loadRequest:request];
}

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

/// Tells the delegate an ad request failed.
- (void)interstitial:(GADInterstitial *)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: GADInterstitialAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    let request = GADRequest()
    GADInterstitialAd.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) GADInterstitialAd *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"
                              request:request
                    completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]);
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

Display ad

v7

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");
  }
}

Presentation ad events

The code snippets below show you how to handle callbacks for when the ad presents (successfully or unsuccessfully) and when it is dismissed.

v7

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
  interstitial.delegate = self
  ...
}

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

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

/// Tells the delegate the interstitial had been animated off the screen.
func interstitialDidDismissScreen(_ ad: GADInterstitial) {
  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: GADInterstitial) {
  print("Interstitial ad will leave application.")
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:"ca-app-pub-3940256099942544/4411468910"];
  self.interstitial.delegate = self;
  ...
}

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

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

/// Tells the delegate the interstitial had been animated off the screen.
- (void)interstitialDidDismissScreen:(GADInterstitial *)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:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will leave application.");
}

v8

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADInterstitialAd.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];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"
                              request:request
                    completionHandler:^(GADInterstitialAd *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.");
}

Rewarded

Load ad

v7

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(GADRequest()) { 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;
  GADRequest *request = [GADRequest 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 = GADRequest()
  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];

  GADRequest *request = [GADRequest 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;
}

Display ad and handle reward

Rewarded ads require you to handle the event when a user earns a reward. With version 7 of the GADRewardedAd API, you implement rewardedAd:userDidEarnReward: as part of the GADRewardedAdDelegate protocol. For version 8, you implement the GADUserDidEarnRewardHandler in order to present the ad.

v7

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");
  }
}

Presentation ad events

With the GADRewardedAd API you pass a GADRewardedAdDelegate to the method that presents the ad. With the GADRewardedAd API, you set a GADFullscreenContentDelegate as a property on the ad prior to presenting the ad.

v7

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 = GADRequest()
  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];

  GADRequest *request = [GADRequest 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.");
}

Legacy GADRewardedBasedVideoAd API removal

The newer GADRewardedAd API was first introduced back in March 2019 and has been the preferred rewarded API for over 18 months. It has had more enhancements compared to the legacy GADRewardedBasedVideoAd API, including the ability to load more than one rewarded ad at a time.

The legacy GADRewardedBasedVideoAd API is removed in SDK version 8.0.0.

Smart banner deprecation in favor of adaptive banner

Smart banner ads are deprecated in favor of adaptive banner ads. Adaptive banners provide superior performance and more flexibility in setting ad width. If you prefer to continue using full-width banners, that can still be done using adaptive banner, as shown in the following code snippet:

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

Leave application callback removal

The willLeaveApplication callback for all ad formats has been removed in favor of the applicationDidEnterBackground: and sceneDidEnterBackground: methods. Using OS-level APIs notify you whenever users leave your app, regardless of whether or not it is due to an ad interaction.

Note that the willLeaveApplication callback was never intended to be an ad click handler, and relying on this callback to report clicks did not produce an accurate metric. For example, a click on the AdChoices icon that launched an external browser invoked the callback but did not count a click.

Class renames

The table below lists specific class names that have changed or been removed in version 8. In summary:

  • All classes related to GADUnifiedNativeAd have been renamed to GADNativeAd.
  • GADRewardBasedVideoAd, GADNativeExpressAdView, and GADInstreamAd have been removed.
  • All classes with the DFP prefix have been replaced with a GAM prefix.
v7.68.0 Class v8.0.0 Class
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 Removed
GADInterstitial GADInterstitialAd
GADNativeExpressAdView Removed
GADRewardBasedVideoAd Removed
GADInstreamAd Removed
GADInstreamAdView Removed

Methods removed/replaced

The table below lists the specific changes in version 8. In summary:

  • Previously deprecated methods and properties have been removed.
  • -willLeaveApplication: delegate methods have been removed for all formats.
  • The ad network class name has moved to the GADResponseInfo property.
  • The test device identifier has moved to the GADRequestConfiguration property.
v7.68.0 Class v7.68.0 API v8.0.0 API Notes
GADMobileAds +configureWithApplicationID: -startWithCompletionHandler: The app ID is now set in Info.plist.
+disableAutomatedInAppPurchaseReporting -disableAutomatedInAppPurchaseReporting
+disableSDKCrashReporting -disableSDKCrashReporting
GADRequest testDevices GADRequestConfiguration.testdeviceidentifiers The testDeviceIdentifiers property applies to all ad requests, while the old testDevices property was set per-request.
gender Removed
birthday Removed
+sdkVersion GADMobileAds.sharedInstance.sdkVersion
-setBirthdayWithMonth:day:year: Removed
-setLocationWithDescription: -setLocationWithLatitude:longitude:accuracy:
-tagForChildDirectedTreatment: [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment]
GADErrorCode kGADError* GADError* The k prefix is dropped from all error code constants.
GADBannerView hasAutoRefreshed autoloadEnabled
inAppPurchaseDelegate Removed
mediatedAdView Removed
adNetworkClassName responseInfo.adNetworkClassName
DFPBannerView -setValidAdSizesWithSizes: -setValidAdSizes:
DFPBannerViewOptions -adSizeDelegate Removed
GADBannerViewDelegate -adViewDidReceiveAd: -bannerViewDidReceiveAd:
-adView:didFailToReceiveAdWithError: -bannerView:didFailToReceiveAdWithError:
-adViewWillPresentScreen: -bannerViewWillPresentScreen:
-adViewWillDismissScreen: -bannerViewWillDismissScreen:
-adViewDidDismissScreen: -bannerViewDidDismissScreen:
-adViewWillLeaveApplication: Removed
GADNativeCustomTemplateAd templateID GADCustomNativeAd.formatID
-performClickOnAssetWithKey:customClickHandler: -performClickOnAssetWithKey:
GADNativeAdImageAdLoaderOptions preferredImageOrientation GADNativeAdMediaAdOptions.mediaAspectRatio
GADInterstitial inAppPurchaseDelegate Removed
isReady Removed Use canPresentFromRootViewController:error: instead.
hasBeenUsed Removed
-init -initWithAdUnitID:
-setAdUnitID: -initWithAdUnitID:
adNetworkClassName responseInfo.adNetworkClassName
-interstitialWillLeaveApplication: Removed
GADUnifiedNativeAd videoController mediaContent.videoController
adNetworkClassName responseInfo.adNetworkClassName