This page covers migrations for current and previous versions.
Migrate to SDK v9
The Google Mobile Ads SDK version 9.0.0 is coming in early 2022 with a few major changes, as well as several API renames and removal of deprecated APIs. This guide outlines these changes and the best practices to bring your app up to date with our latest SDK.
Ads stop serving on iOS 10
The minimum iOS version the Google Mobile Ads SDK version 9.0.0 supports is iOS 11.
Upgrading to Google Mobile Ads SDK version 9.0.0 will not break your app on iOS 10 devices, however, no ads will be served on those devices.
Stricter enforcement of status bar controls
Starting from version 9.0.0, when you present full screen format ads, your app should ensure that the ads are able to control the presentation of the status bar. You will see an error message in the logs if you fail to do so.
Depending on the specific layout of view controllers in your app, you may not
need to make any changes to ensure this, but in some cases, you may need to set
your parent view controller's modalPresentationCapturesStatusBarAppearance
property.
Rename adDidPresentFullScreenContent: to adWillPresentFullScreenContent:
There is no behavior change. The delegate method is invoked right before the ad is about to be presented, so the new method name better reflects its functionality.
Remove location setting API on GADRequest
- (void)setLocationWithLatitude:longitude:accuracy:
has been deleted from
GADRequest
since location data is not used by Google to target ads. Use
third-party APIs to provide the information to third-party ad networks if
required.
Custom event interfaces deprecation
Custom events enable publishers using AdMob Mediation to add waterfall mediation for an ad network that isn't one of the supported ad networks.
All the custom event protocols are deprecated. Instead, use the existing
GADMediationAdapter
and
GADMediationAdEventDelegate
protocols to achieve the same functionalities. This change improves clarity and
enables you to create custom events for rewarded ads and interscroller ads which
were not previously available.
APIs
The table below lists the corresponding mediation adapter APIs to custom events APIs that should be used starting from version 9.0.0.
v8 | v9 | |
---|---|---|
GADCustomEventBanner GADCustomEventInterstitial GADCustomEventNativeAd |
GADMediationAdapter | GADMediationBannerAd GADMediationInterstitialAd GADMediationInterscrollerAd GADMediationRewardedAd GADMediationNativeAd |
delegate
|
Delegate is returned by the load completion handler of each load function
of GADMediationAdapter class
|
|
-init |
-init |
|
-requestBannerAd:parameter: |
-loadBannerForAdConfiguration: |
|
-requestInterstitialAdWith |
-loadInterstitialFor |
|
-requestNativeAdWithParameter:
|
-loadNativeAdFor |
|
N/A | -loadInterscrollerAdFor |
|
N/A | -loadRewardedAdFor |
|
-presentFromRootViewController:
|
-presentFromViewController: |
|
-handlesUserClicks |
-handlesUserClicks |
|
-handlesUserImpressions |
-handlesUserImpressions |
Delegate methods
The table below lists the corresponding mediation ad event delegate methods to custom event delegate methods that should be used starting from version 9.0.0.
v8 | v9 | |
---|---|---|
GADCustomEventBannerDelegate GADCustomEventInterstitialDelegate GADCustomEventNativeAdDelegate |
GADMediationAdEventDelegate | GADMediationAd |
-customEventBanner:didReceiveAd: -customEventInterstitialDidReceiveAd:
|
Ad load status is included in the load completion handler of
each load function in the GADMediationAdapter class
|
|
-customEventBanner:didFailAd: -customEventInterstitial:didFailAd:
|
||
-customEventBannerWasClicked: -customEventInterstitialWasClicked:
|
-reportClick |
|
-customEventBannerWill -customEventInterstitialWill
|
-willPresentFullScreenView |
|
-customEventBannerWill -customEventInterstitialWill
|
-willDismissFullScreenView |
|
-customEventBannerDid -customEventInterstitialDid
|
-didDismissFullScreenView |
|
-customEventBannerWill -customEventInterstitialWill
|
-willBackgroundApplication |
|
viewControllerFor |
-[GADMediationBannerAd view] |
Other removed/replaced methods and constants
Changes to method, constant, or property | |
---|---|
kGAD- prefixed constants
|
Removed. Use GAD- prefixed constants.
|
GADAdNetworkResponseInfo
|
credentials were removed. Use adUnitMapping
instead.
|
GADCustomNativeAd
|
mediaView in GADCustomNativeAd is deprecated.
Use mediaContent instead.
|
In-App Purchase APIs in GoogleMobileAds |
inAppPurchase APIs in GoogleMobileAds were
removed.
|
Migrate to SDK v8
Google 移动广告 SDK 8.0.0 版引入了一些重大更改以及 API 的一些重命名和删除。
全屏格式 API 更新
从 8.0.0 版开始,插页式广告和激励广告共享通用的全屏广告样式,以提高一致性。这些新的全屏广告 API 与第 7 版全屏广告 API 有两个主要区别:
静态类方法
load
。之前加载/显示全屏广告的方法如下:
- 创建一个广告对象实例并保存对它的引用。
- 分配一个处理加载和显示回调的委托。
- 加载广告。
- 检查是否使用
isReady
加载了广告。 - 展示广告。
在版本 8 中,方法略有变化。加载回调不再是委托的一部分。相反,它们作为完成处理程序传递给
load
方法:- 在广告类上调用静态加载方法并提供加载完成处理程序。
- 在加载完成回调中,保留对返回的已加载广告的引用。
- 分配一个处理显示回调的委托。
- 展示广告。
新方法提供了以下好处:
- 您永远不会引用未加载的广告。
- 您不必在加载广告对象时抓住它。
一致的广告事件。
事件类型 现有 API v8 API 加载事件 GADInterstitialDelegate
或GADRewardedAdDelegate
GADInterstitialAdLoadCompletionHandler
或GADRewardedAdLoadCompletionHandler
演讲活动 GADFullScreenContentDelegate
以前,要侦听任何广告事件,您需要将实现
GADInterstitialDelegate
协议的类注册到插页式广告的委托属性,或将实现GADRewardedAdDelegate
协议的类注册到奖励广告的委托属性,具体取决于您使用的格式。这个委托具有与广告的加载和展示生命周期相关的方法。在版本 8 中,加载和演示事件是分开的。您现在可以在显示广告之前随时注册
GADFullScreenContentDelegate
,而无需在加载广告之前设置单个委托。特定于每种格式的广告加载事件移动到加载方法中传递的单个加载完成处理程序。
插页式
加载广告
下面的代码片段向您展示了如何加载插页式广告并在广告加载成功或失败时监听事件。
v7
迅速
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADInterstitialDelegate { var interstitial: GADInterstitial! override func viewDidLoad() { super.viewDidLoad() interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/44118910") 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/44118910"]; 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
迅速
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/44118910" 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; }]; }
展示广告
v7
迅速
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
迅速
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"); } }
演示广告活动
下面的代码片段向您展示了如何处理广告展示(成功或不成功)和关闭时的回调。
v7
迅速
override func viewDidLoad() { super.viewDidLoad() interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/44118910") 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/44118910"]; 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
迅速
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/44118910" 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."); }
奖励
加载广告
v7
迅速
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
迅速
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; }
展示广告并处理奖励
奖励广告要求您在用户获得奖励时处理事件。使用GADRewardedAd
API 的第 7 版,您实现rewardedAd:userDidEarnReward:
作为GADRewardedAdDelegate
协议的一部分。对于版本 8,您实现GADUserDidEarnRewardHandler
以展示广告。
v7
迅速
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
迅速
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
设置为广告的属性。
v7
迅速
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
迅速
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."); }
旧版 GADRewardedBasedVideoAd API 移除
较新的GADRewardedAd
API 于 2019 年 3 月首次推出,18 个月以来一直是首选的奖励 API。与旧版GADRewardedBasedVideoAd
API 相比,它具有更多增强功能,包括一次加载多个奖励广告的能力。
SDK 版本 8.0.0 中删除了旧版GADRewardedBasedVideoAd
API。
智能横幅弃用,支持自适应横幅
智能横幅广告已弃用,取而代之的是自适应横幅广告。自适应横幅在设置广告宽度方面提供了卓越的性能和更大的灵活性。如果您希望继续使用全角横幅,仍然可以使用自适应横幅来完成,如以下代码片段所示:
迅速
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:
方法。每当用户离开您的应用时,无论是否由于广告交互,使用操作系统级 API 都会通知您。
请注意, willLeaveApplication
回调从未打算用作广告点击处理程序,并且依靠此回调来报告点击并不能产生准确的指标。例如,点击启动外部浏览器的 AdChoices 图标会调用回调,但不计入点击次数。
类重命名
下表列出了版本 8 中已更改或删除的特定类名称。总结:
- 所有与
GADUnifiedNativeAd
相关的类都已重命名为GADNativeAd
。 -
GADRewardBasedVideoAd
、GADNativeExpressAdView
和GADInstreamAd
已被移除。 - 所有带有
DFP
前缀的类都已替换为GAM
前缀。
v7.68.0 类 | v8.0.0 类 |
---|---|
DFP横幅视图 | GAM横幅视图 |
DFPBannerViewOptions | GAMBannerViewOptions |
DFP 插页式广告 | GAM 插页式广告 |
DFP 请求 | GAM请求 |
GADRequestError | NS错误 |
GADUnifiedNativeAdView | GADNativeAdView |
GADUnifiedNativeAd | GADNativeAd |
GADUnifiedNativeAdAssetIdentifiers | GADNativeAdAssetIdentifiers |
GADUnifiedNativeAdDelegate | GADNativeAdDelegate |
GADUnifiedNativeAdUnconfirmedClickDelegate | GADNativeAdUnconfirmedClickDelegate |
GADNativeCustomTemplateAd | GADCustomNativeAd |
GADNativeCustomTemplateAdLoaderDelegate | GADCustomNativeAdLoaderDelegate |
GADNativeAdDelegate | GADCustomNativeAdDelegate |
GADInApp购买 | 已移除 |
GAD 插页式 | GAD 插页式广告 |
GADNativeExpressAdView | 已移除 |
GADRewardBased 视频广告 | 已移除 |
GADInstreamAd | 已移除 |
GADInstreamAdView | 已移除 |
删除/替换的方法
下表列出了版本 8 中的具体更改。总结:
- 以前不推荐使用的方法和属性已被删除。
-
-willLeaveApplication:
已删除所有格式的委托方法。 - 广告网络类名称已移至
GADResponseInfo
属性。 - 测试设备标识符已移至
GADRequestConfiguration
属性。
v7.68.0 类 | v7.68.0 API | v8.0.0 API | 笔记 |
---|---|---|---|
GAD移动广告 | +configureWithApplicationID: | -startWithCompletionHandler: | 应用 ID 现在在 Info.plist 中设置。 |
+disableAutomatedInApp PurchaseReporting | -disableAutomatedInApp PurchaseReporting | ||
+disableSDK 崩溃报告 | -disableSDKCrashReporting | ||
GAD请求 | 测试设备 | GADRequestConfiguration .testdeviceidentifiers | testDeviceIdentifiers 属性适用于所有广告请求,而旧的 testDevices 属性是按请求设置的。 |
性别 | 已移除 | ||
生日 | 已移除 | ||
+sdkV版本 | GADMobileAds.sharedInstance .sdkVersion | ||
-setBirthday WithMonth:day:year: | 已移除 | ||
-setLocationWithDescription: | -setLocationWith 纬度:经度:准确度: | ||
-tagForChildDirectedTreatment: | [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment] | ||
GAD错误代码 | kGAD误差* | GAD错误* | k 前缀从所有错误代码常量中删除。 |
GAD横幅视图 | 已自动刷新 | 自动加载启用 | |
inAppPurchaseDelegate | 已移除 | ||
中介 AdView | 已移除 | ||
adNetworkClassName | responseInfo .adNetworkClassName | ||
DFP横幅视图 | -setValidAdSizesWithSizes: | -setValidAdSizes: | |
DFPBannerViewOptions | -adSizeDelegate | 已移除 | |
GADBannerViewDelegate | -adViewDidReceiveAd: | -bannerViewDidReceiveAd: | |
-adView:didFailToReceive AdWithError: | -bannerView:didFailToReceive AdWithError: | ||
-adViewWillPresentScreen: | -bannerViewWillPresentScreen: | ||
-adViewWillDismissScreen: | -bannerViewWillDismissScreen: | ||
-adViewDidDismissScreen: | -bannerViewDidDismissScreen: | ||
-adViewWillLeaveApplication: | 已移除 | ||
GADNativeCustomTemplateAd | 模板ID | GADCustomNativeAd.formatID | |
-performClickOnAssetWithKey:customClickHandler: | -performClickOnAssetWithKey: | ||
GADNativeAdImage广告加载器选项 | 首选图像方向 | GADNativeAdMediaAdOptions .mediaAspectRatio | |
GAD 插页式 | inAppPurchaseDelegate | 已移除 | |
准备好了 | 已移除 | 使用 canPresentFrom RootViewController:error: 代替。 | |
已经用过 | 已移除 | ||
-在里面 | -initWithAdUnitID: | ||
-setAdUnitID: | -initWithAdUnitID: | ||
adNetworkClassName | responseInfo .adNetworkClassName | ||
-interstitialWill LeaveApplication: | 已移除 | ||
GADUnifiedNativeAd | 视频控制器 | mediaContent.videoController | |
adNetworkClassName | responseInfo .adNetworkClassName |