หน้านี้ครอบคลุมการย้ายข้อมูลสำหรับ Google Mobile Ads SDK เวอร์ชันปัจจุบันและเวอร์ชันก่อนหน้าสำหรับ iOS เราคาดว่าจะเปิดตัวเวอร์ชัน 13.0.0 ในเดือนกุมภาพันธ์ 2026
ย้ายข้อมูลจาก v12 ไปยัง v13
เพิ่มเป้าหมายการติดตั้งใช้งานขั้นต่ำ
เป้าหมายการติดตั้งใช้งานขั้นต่ำเพิ่มขึ้นเป็น iOS 13
การเปลี่ยนแปลง API ขนาดแบนเนอร์แบบปรับขนาดได้ที่ยึดตำแหน่งไว้
เวอร์ชัน 13.0.0 เลิกใช้งาน API ขนาดแบนเนอร์แบบปรับขนาดได้ที่ยึดตำแหน่งไว้ที่มีอยู่ และเปิดตัว API ขนาดสำหรับโฆษณาแบนเนอร์แบบปรับขนาดได้ที่ยึดตำแหน่งไว้ขนาดใหญ่ Google Mobile Ads SDK สามารถแสดงดีมานด์วิดีโอในโฆษณาแบนเนอร์ได้โดยใช้ API ขนาดแบนเนอร์แบบปรับขนาดได้ที่ยึดตำแหน่งไว้ขนาดใหญ่ใหม่
ตารางต่อไปนี้แสดงรายละเอียด API การปรับขนาดที่เลิกใช้งานแล้วและ API ที่จะมาแทนที่
| v12 (เลิกใช้งานแล้ว) | v13 (การแทนที่) |
|---|---|
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargeLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargePortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
การรองรับการเกิดขึ้นพร้อมกันของ Swift 6 อย่างต่อเนื่อง
เวอร์ชัน 13.0.0 ยังคงเพิ่มการรองรับการเกิดขึ้นพร้อมกันที่เข้มงวดของ Swift 6
เพิ่มการบังคับใช้ประเภทที่เข้มงวดมากขึ้นสำหรับอาร์เรย์ neighboringContentURLStrings
ตั้งแต่เวอร์ชัน 13.0.0 เป็นต้นไป Google Mobile Ads SDK จะแสดงข้อยกเว้นหากตรวจพบออบเจ็กต์ที่ไม่ใช่ประเภท String ในอาร์เรย์ neighboringContentURLStrings
ย้ายข้อมูลจาก v11 ไปยัง v12
อัปเกรดเป็น Xcode 16.0
เวอร์ชัน Xcode ขั้นต่ำที่รองรับเพิ่มขึ้นเป็น 16.0
การรองรับการตั้งชื่อ Swift
เวอร์ชัน 12.0.0 มีการเปลี่ยนแปลงเพื่อให้เป็นไปตามรูปแบบการตั้งชื่อในหลักเกณฑ์การออกแบบ API ของ Swift การเปลี่ยนแปลงเหล่านี้ส่งผลต่อ Swift เท่านั้น ไม่มีการเปลี่ยนแปลงการตั้งชื่อใน Objective-C API
การเปลี่ยนแปลงคำนำหน้าคลาส
การเปลี่ยนแปลงต่อไปนี้เกิดขึ้นกับคำนำหน้าคลาส
- นำคำนำหน้า
GADออกจากชื่อของทุกประเภท - เปลี่ยนชื่อคำนำหน้า
GAMเป็นAdManagerแล้ว - เปลี่ยนชื่อคำนำหน้า
GADMเป็นMediationแล้ว
แก้ไขข้อผิดพลาด
วิธีที่ดีที่สุดในการแก้ไขข้อผิดพลาดที่เกิดจากการเปลี่ยนแปลงเหล่านี้คือทำการแก้ไขด้วย Fix-It
แก้ไขความขัดแย้งในการตั้งชื่อ
หากต้องการแก้ไขความขัดแย้งในการตั้งชื่อ ให้ใช้เนมสเปซที่โมดูลระบุไว้ เช่น GADRequest เปลี่ยนชื่อเป็น Request แล้ว เนมสเปซตัวอย่างต่อไปนี้
Google Mobile Ads SDK Request คลาส:
import GoogleMobileAds
...
var request: GoogleMobileAds.Request?
รายการการเปลี่ยนแปลง Swift โดยละเอียด
ตารางต่อไปนี้แสดงการเปลี่ยนแปลงที่เกิดขึ้นกับ Swift API
| เวอร์ชัน 11 | เวอร์ชัน 12 |
|---|---|
GADAdapterInitializationState |
AdapterInitializationState |
GADAdChoicesPosition |
AdChoicesPosition |
GADAdChoicesView |
AdChoicesView |
GADAdFormat |
AdFormat |
GADAdLoader |
AdLoader |
GADAdLoaderAdType |
AdLoaderAdType |
GADAdLoaderDelegate |
AdLoaderDelegate |
GADAdMetadataDelegate |
AdMetadataDelegate |
GADAdMetadataProvider |
AdMetadataProvider |
GADAdNetworkExtras |
AdNetworkExtras |
GADAdNetworkResponseInfo |
AdNetworkResponseInfo |
GADAdReward |
AdReward |
GADAdSize |
AdSize |
GADAdSizeDelegate |
AdSizeDelegate |
GADAdValue |
AdValue |
GADAdValuePrecision |
AdValuePrecision |
GADAppEventDelegate |
AppEventDelegate |
GADAppOpenAd |
AppOpenAd |
GADAppOpenSignalRequest |
AppOpenSignalRequest |
GADAudioVideoManager |
AudioVideoManager |
GADAudioVideoManagerDelegate |
AudioVideoManagerDelegate |
GADBannerSignalRequest |
BannerSignalRequest |
GADBannerView |
BannerView |
GADBannerViewDelegate |
BannerViewDelegate |
GADCustomEventExtras |
CustomEventExtras |
GADCustomEventRequest |
CustomEventRequest |
GADCustomNativeAd |
CustomNativeAd |
GADCustomNativeAdLoaderDelegate |
CustomNativeAdLoaderDelegate |
GADCustomNativeAdDelegate |
CustomNativeAdDelegate |
GADDebugOptionsViewControllerDelegate |
DebugOptionsViewControllerDelegate |
GADDebugOptionsViewController |
DebugOptionsViewController |
GADDisplayAdMeasurement |
DisplayAdMeasurement |
GADExtras |
Extras |
GADFullScreenPresentingAd |
FullScreenPresentingAd |
GADFullScreenContentDelegate |
FullScreenContentDelegate |
GADAdapterStatus |
AdapterStatus |
GADInitializationStatus |
InitializationStatus |
GADInterstitialAd |
InterstitialAd |
GADInterstitialSignalRequest |
InterstitialSignalRequest |
GADMediaAspectRatio |
MediaAspectRatio |
GADMediaContent |
MediaContent |
GADMediaView |
MediaView |
GADMobileAds |
MobileAds |
GADMultipleAdsAdLoaderOptions |
MultipleAdsAdLoaderOptions |
GADMuteThisAdReason |
MuteThisAdReason |
GADNativeAd |
NativeAd |
GADNativeAdLoaderDelegate |
NativeAdLoaderDelegate |
GADNativeAdView |
NativeAdView |
GADNativeAdCustomClickGestureOptions |
NativeAdCustomClickGestureOptions |
GADNativeAdDelegate |
NativeAdDelegate |
GADNativeAdImage |
NativeAdImage |
GADNativeAdImageAdLoaderOptions |
NativeAdImageAdLoaderOptions |
GADNativeAdInlineBehavior |
NativeAdInlineBehavior |
GADNativeAdInlineBehaviorOptions |
NativeAdInlineBehaviorOptions |
GADNativeAdMediaAdLoaderOptions |
NativeAdMediaAdLoaderOptions |
GADNativeAdUnconfirmedClickDelegate |
NativeAdUnconfirmedClickDelegate |
GADNativeAdViewAdOptions |
NativeAdViewAdOptions |
GADNativeMuteThisAdLoaderOptions |
NativeMuteThisAdLoaderOptions |
GADNativeSignalRequest |
NativeSignalRequest |
GADPresentationError |
PresentationError |
GADPublisherPrivacyPersonalizationState |
PublisherPrivacyPersonalizationState |
GADQueryInfo |
QueryInfo |
GADRequest |
Request |
GADRequestError |
RequestError |
GADRequestConfiguration |
RequestConfiguration |
GADResponseInfo |
ResponseInfo |
GADRewardedAd |
RewardedAd |
GADRewardedSignalRequest |
RewardedSignalRequest |
GADRewardedInterstitialAd |
RewardedInterstitialAd |
GADRewardedInterstitialSignalRequest |
RewardedInterstitialSignalRequest |
GADSearchBannerView |
SearchBannerView |
GADServerSideVerificationOptions |
ServerSideVerificationOptions |
GADSignal |
Signal |
GADSignalRequest |
SignalRequest |
GADVersionNumber |
VersionNumber |
GADVideoController |
VideoController |
GADVideoControllerDelegate |
VideoControllerDelegate |
| Ad Manager | |
GAMBannerAdLoaderDelegate |
AdManagerBannerAdLoaderDelegate |
GAMBannerView |
AdManagerBannerView |
GAMBannerViewOptions |
AdManagerBannerViewOptions |
GAMInterstitialAd |
AdManagerInterstitialAd |
GAMRequest |
AdManagerRequest |
| สื่อกลาง | |
GADMAdNetworkAdapter |
MediationAdNetworkAdapter |
GADMAdNetworkConnector |
MediationAdNetworkConnector |
GADMBannerAnimationType |
MediationBannerAnimationType |
GADMediatedUnifiedNativeAd |
MediationUnifiedNativeAd |
GADMediatedUnifiedNativeAdNotificationSource |
MediationUnifiedNativeAdNotificationSource |
GADMediationAd |
MediationAd |
GADMediationAdConfiguration |
MediationAdConfiguration |
GADMediationAdEventDelegate |
MediationAdEventDelegate |
GADMediationAdRequest |
MediationAdRequest |
GADMediationAdapter |
MediationAdapter |
GADMediationAppOpenAd |
MediationAppOpenAd |
GADMediationAppOpenAdEventDelegate |
MediationAppOpenAdEventDelegate |
GADMediationBannerAd |
MediationBannerAd |
GADMediationBannerAdConfiguration |
MediationBannerAdConfiguration |
GADMediationBannerAdEventDelegate |
MediationBannerAdEventDelegate |
GADMediationCredentials |
MediationCredentials |
GADMediationInterstitialAd |
MediationInterstitialAd |
GADMediationInterstitialAdConfiguration |
MediationInterstitialAdConfiguration |
GADMediationInterstitialAdEventDelegate |
MediationInterstitialAdEventDelegate |
GADMediationNativeAd |
MediationNativeAd |
GADMediationNativeAdConfiguration |
MediationNativeAdConfiguration |
GADMediationNativeAdEventDelegate |
MediationNativeAdEventDelegate |
GADMediationRewardedAd |
MediationRewardedAd |
GADMediationRewardedAdConfiguration |
MediationRewardedAdConfiguration |
GADMediationRewardedAdEventDelegate |
MediationRewardedAdEventDelegate |
GADMediationServerConfiguration |
MediationServerConfiguration |
| การเสนอราคาแบบเรียลไทม์ | |
GADRTBAdapter |
RTBAdapter |
GADRTBMediationSignalsConfiguration |
RTBMediationSignalsConfiguration |
GADRTBRequestParameters |
RTBRequestParameters |
ค่าคงที่
| เวอร์ชัน 11 | เวอร์ชัน 12 |
|---|---|
GADAdLoaderAdType.gamBanner |
AdLoaderAdType.adManagerBanner |
GADAdSizeBanner |
AdSizeBanner |
GADAdSizeFluid |
AdSizeFluid |
GADAdSizeFullBanner |
AdSizeFullBanner |
GADAdSizeInvalid |
AdSizeInvalid |
GADAdSizeLargeBanner |
AdSizeLargeBanner |
GADAdSizeLeaderboard |
AdSizeLeaderboard |
GADAdSizeMediumRectangle |
AdSizeMediumRectangle |
GADAdSizeSkyscraper |
AdSizeSkyscraper |
GoogleMobileAdsVersionString |
GoogleMobileAdsVersion |
พร็อพเพอร์ตี้
| ประเภท | เวอร์ชัน 11 | เวอร์ชัน 12 |
|---|---|---|
| GADAdLoader | loading |
isLoading |
| GADAudioVideoManager | audioSessionApplicationManaged |
isAudioSessionApplicationManaged |
| GADBannerView | autoloadEnabled |
isAutoloadEnabled |
| GADMobileAds | sharedInstance |
shared |
applicationMuted |
isApplicationMuted |
|
| GADMuteThisAdReason | reasonDescription |
reason |
| GADNativeAd | customMuteThisAdAvailable |
isCustomMuteThisAdAvailable |
| GADNativeAdCustomClickGestureOptions | tapsAllowed |
areTapsAllowed |
| GADNativeAdImageAdLoaderOptions | imageLoadingDisabled |
isImageLoadingDisabled |
| GADNativeMuteThisAdLoaderOptions | customMuteThisAdRequested |
isCustomMuteThisAdRequested |
| GADNativeSignalRequest | imageLoadingDisabled |
isImageLoadingDisabled |
customMuteThisAdRequested |
isCustomMuteThisAdRequested |
|
| GADRequest | neighboringContentURLStrings |
neighboringContentURLs |
| GADResponseInfo | extrasDictionary |
extras |
| GADServerSideVerificationOptions | customRewardString |
customRewardText |
| GADSignal | signalString |
signal |
| GADSignalRequest | neighboringContentURLStrings |
neighboringContentURLs |
| GADVideoController | customControlsRequested |
areCustomControlsRequested |
clickToExpandEnabled |
isClickToExpandEnabled |
|
| GADVideoOptions | startMuted |
shouldStartMuted |
customControlsRequested |
areCustomControlsRequested |
|
clickToExpandRequested |
isClickToExpandRequested |
ฟังก์ชัน
| ประเภท | เวอร์ชัน 11 | เวอร์ชัน 12 |
|---|---|---|
| GADAdSize | GADPortraitInlineAdaptiveBannerAdSizeWithWidth(_:) |
portraitInlineAdaptiveBanner(width:) |
GADLandscapeInlineAdaptiveBannerAdSizeWithWidth(_:) |
landscapeInlineAdaptiveBanner(width:) |
|
GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(_:) |
currentOrientationInlineAdaptiveBanner(width:) |
|
GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(_:, _:) |
inlineAdaptiveBanner(width:maxHeight:) |
|
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(_:) |
portraitAnchoredAdaptiveBanner(width:) |
|
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(_:) |
landscapeAnchoredAdaptiveBanner(width:) |
|
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(_:) |
currentOrientationAnchoredAdaptiveBanner(width:) |
|
GADAdSizeFromCGSize(_:) |
adSizeFor(cgSize:) |
|
GADAdSizeFullWidthPortraitWithHeight(_:) |
fullWidthPortrait(height:) |
|
GADAdSizeFullWidthLandscapeWithHeight(_:) |
fullWidthLandscape(height:) |
|
GADAdSizeEqualToSize(_:, _:) |
isAdSizeEqualToSize(size1:size2:) |
|
IsGADAdSizeValid(_:) |
isAdSizeValid(size:) |
|
GADAdSizeIsFluid(_:) |
isAdSizeFluid(size:) |
|
CGSizeFromGADAdSize(_:) |
cgSize(for:) |
|
NSStringFromGADAdSize(_:) |
string(for:) |
|
NSValueFromGADAdSize(_:) |
nsValue(for:) |
|
GADAdSizeFromNSValue(_:) |
adSizeFor(nsValue:) |
|
GADClosestValidSizeForAdSizes(_:_:) |
closestValidSizeForAdSizes(original:possibleAdSizes:) |
|
| GADAppEventDelegate | adView(_:didReceiveAppEvent:withInfo:) |
adView(_:didReceiveAppEvent:with:) |
interstitialAd(_:didReceiveAppEvent:withInfo:) |
adView(_:didReceiveAppEvent:with:) |
|
| GADAppOpenAd | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:) |
present(from:) |
|
| GADBannerView | load(withAdResponseString:) |
load(with:) |
| GADInterstitial | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:) |
present(from:) |
|
| GADRewardedAd | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:userDidEarnRewardHandler:) |
present(from:userDidEarnRewardHandler:) |
|
| GADRewardedInterstitialAd | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:userDidEarnRewardHandler:) |
present(from:userDidEarnRewardHandler:) |
|
| GADVersionNumber | GADGetStringFromVersionNumber(_ version: GADVersionNumber) |
string(for:) |
| สื่อกลาง | ||
| GADMAdNetworkAdapter | getBannerWith(_:) |
getBanner(with:) |
presentInterstitial(fromRootViewController:) |
presentInterstitial(from:) |
|
getNativeAd(withAdTypes:options:) |
getNativeAd(with:options:) |
|
| GADMediatedUnifiedNativeAd | didRecordClickOnAsset(withName:view:viewController:) |
didRecordClickOnAsset(with:view:viewController:) |
| GADMediationAdapter | setUpWith(_:completionHandler:) |
setUp(with:completionHandler:) |
| GADMediationAdSize | present(fromRootViewController:) |
present(from:) |
| GADMediationAppOpenAd | present(fromRootViewController:) |
present(from:) |
| GADMediationInterstitialAd | present(fromRootViewController:) |
present(from:) |
| GADMediationRewardedAd | present(fromRootViewController:) |
present(from:) |
| GAMInterstitialAd | load(withAdManagerAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
ตั้งค่าพารามิเตอร์การกำหนดเป้าหมายเอง
หากต้องการตั้งค่าการกำหนดเป้าหมายเองในคำขอโฆษณา ให้ใช้ customTargeting
การเปลี่ยนแปลง API เพื่อควบคุมสถานะการปิดเสียงวิดีโอ
พร็อพเพอร์ตี้ isMuted และเมธอด setMute: ใน GADVideoController ถูกแทนที่ด้วยพร็อพเพอร์ตี้ muted
การเปลี่ยนแปลงโฆษณาแบบปรับขนาดได้ที่แทรกในบรรทัด
โฆษณาแบบปรับขนาดได้ในบรรทัดจะไม่ใช้พื้นที่ในเฟรมในตอนแรกเพื่อเพิ่มประสิทธิภาพการใช้พื้นที่ การเรียกใช้ CGSizeFromGADAdSize(_:) ด้วยขนาดโฆษณาแบบปรับขนาดได้ในบรรทัดจะแสดงผลความสูงเป็น 0 จนกว่า Google Mobile Ads SDK จะแสดงโฆษณา
นำ Custom Search Ads ออกแล้ว
ระบบจะนำคลาสต่อไปนี้ออกโดยไม่มีการแทนที่
GADDynamicHeightSearchBannerViewGADDynamicHeightSearchRequestGADSearchBannerView
การเปลี่ยนแปลงรหัสข้อผิดพลาด
รหัสข้อผิดพลาดต่อไปนี้มีการเปลี่ยนแปลง
| ชั้นเรียน | หมายเหตุ |
|---|---|
GADErrorMediationNoFill |
ขณะนี้ข้อผิดพลาดจะแสดงเป็น GADErrorNoFill |
GADErrorReceivedInvalidResponse |
ถูกแทนที่ด้วย GADErrorReceivedInvalidAdString แล้ว |
นำ GADSimulatorID ออกแล้ว
นำ GADSimulatorID ออกแล้ว เครื่องจำลองจะอยู่ในโหมดทดสอบโดยค่าเริ่มต้นอยู่แล้ว
การเปลี่ยนแปลงการกำหนดเป้าหมายเอง
ตอนนี้พจนานุกรม customTargeting ใน GADRequest ใช้ Any แทน String เป็นประเภทค่า ซึ่งจะช่วยให้คุณส่งค่าตัวเลขไปยัง API ได้
การเปลี่ยนแปลงพารามิเตอร์เพิ่มเติม
- การส่งคีย์ไปยัง
additionalParametersจะไม่ใช้การกำหนดเป้าหมายเองกับคำขอโฆษณา Ad Manager อีกต่อไป หากต้องการใช้การกำหนดเป้าหมายเอง โปรดดูการกำหนดเป้าหมายเอง
- ระบบไม่รองรับการส่งคีย์
max_ad_content_ratingไปยังadditionalParametersอีกต่อไป หากต้องการตั้งค่าการจัดประเภทเนื้อหาโฆษณาสูงสุด โปรดดูการกรองเนื้อหาโฆษณา
ย้ายข้อมูลจาก v10 ไปยัง v11
เป้าหมายการติดตั้งใช้งานขั้นต่ำ
เป้าหมายการติดตั้งใช้งานขั้นต่ำเพิ่มขึ้นเป็น iOS 12
เวอร์ชัน Xcode ขั้นต่ำ
เวอร์ชัน Xcode ขั้นต่ำที่รองรับเพิ่มขึ้นเป็น 15.1
โฆษณาหยุดแสดงใน iOS 12
Google Mobile Ads SDK เวอร์ชัน 11.0.0 จะแสดงโฆษณาในอุปกรณ์ที่ใช้ iOS 13 ขึ้นไปเท่านั้น
นำทรัพยากร Dependency ของ GoogleAppMeasurement ออกแล้ว
ในเวอร์ชัน 11.0.0 เราได้นำทรัพยากร Dependency ใน GoogleAppMeasurement ออกแล้ว การขึ้นต่อกันนี้ซึ่งขับเคลื่อนปุ่มสลับเมตริกผู้ใช้ใน AdMob จะปิดให้บริการในช่วงต้นปี 2024 หากต้องการเก็บรวบรวมเมตริกผู้ใช้ใน AdMob ต่อไป ให้ลิงก์แอป AdMob กับ Firebase และผสานรวม SDK ของ Google Analytics สำหรับ Firebase เข้ากับแอป
การเปลี่ยนแปลงการนำเสนอโฆษณาแบบเต็มหน้าจอ
การเปลี่ยนแปลงต่อไปนี้ส่งผลต่อโฆษณารูปแบบต่างๆ
- โฆษณาเปิดแอป
- โฆษณาคั่นระหว่างหน้า
- ได้รับรางวัลแล้ว
- โฆษณาคั่นระหว่างหน้าที่มีการให้รางวัล
พารามิเตอร์ตัวควบคุมมุมมองใน -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 | โปรดใช้ adNetworkClassName จาก loadedAdNetworkResponseInfo แทน |
นำ GADAdFormatUnknown ออกแล้ว
นำ GADAdFormatUnknown ออกโดยไม่มีการแทนที่
การเปลี่ยนแปลงการบันทึกเวอร์ชัน SDK
เวอร์ชัน 11.0.0 จะนำ sdkVersion ออก หากต้องการบันทึกเวอร์ชัน Google Mobile Ads SDK ให้ใช้ versionNumber แทน
เวอร์ชัน 10.0.0
GADMobileAds.sharedInstance().sdkVersion
เวอร์ชัน 11.0.0
GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)
การเปลี่ยนแปลงการจัดการข้อผิดพลาด GADAdLoader
ตั้งแต่เวอร์ชัน 11.0.0 เป็นต้นไป GADAdLoader จะไม่ส่งคำขอโฆษณาหาก delegate ไม่เป็นไปตามโปรโตคอลตัวแทนของประเภทโฆษณาที่ขอ ก่อนหน้านี้ การแสดงผลล้มเหลวหลังจากสร้างคำขอโฆษณา
การเปลี่ยนแปลงลักษณะการทำงานของการทดสอบ
ดูตารางที่แสดงเงื่อนไขที่อัปเดตเมื่อพร็อพเพอร์ตี้ต่อไปนี้แสดงผลเป็น true
| ชั้นเรียน | พร็อพเพอร์ตี้ |
|---|---|
| GADMediationAdConfiguration | isTestRequest |
| GADCustomEventRequest | isTesting |
| v10.0.0 | v11.0.0 |
|
|
ย้ายข้อมูลจาก v9 ไปยัง v10
โฆษณาหยุดแสดงใน iOS 11
Google Mobile Ads SDK เวอร์ชัน 10.0.0 จะแสดงโฆษณาในอุปกรณ์ที่ใช้ iOS 12 ขึ้นไปเท่านั้น
การอัปเกรดเป็น Google Mobile Ads SDK เวอร์ชัน 10.0.0 จะไม่ทำให้แอปในอุปกรณ์ iOS 11 และ iOS 10 เสียหาย แต่จะไม่มีการแสดงโฆษณาในอุปกรณ์เหล่านั้น
ข้อกำหนดของรหัสแอป Ad Manager
ตอนนี้คุณต้องระบุรหัสแอป Ad Manager ใน Info.plist สำหรับแอป Ad Manager ทั้งหมด และต้องใช้รูปแบบ ca-app-pub-################~########## ดูรายละเอียดเพิ่มเติมได้ที่อัปเดต Info.plist
ข้อกำหนดของ GoogleAppMeasurement.xcframework
ตอนนี้แอป Ad Manager ทั้งหมดต้องใช้ GoogleAppMeasurement.xcframework หากคุณติดตั้ง Google Mobile Ads SDK ผ่าน Cocoapods หรือ Swift Package Manager คุณไม่จำเป็นต้องดำเนินการใดๆ เพิ่มเติม หากคุณติดตั้งเฟรมเวิร์กด้วยตนเอง โปรดดูรายละเอียดเพิ่มเติมที่หัวข้อการดาวน์โหลดด้วยตนเอง
ระบบไม่รองรับการสร้างด้วยบิตโค้ดอีกต่อไป
ตอนนี้คุณต้องปิดใช้บิตโค้ดในแอปบนอุปกรณ์เคลื่อนที่เพื่อผสานรวม Google Mobile Ads SDK
ประเภทที่นำออก
| ประเภท | หมายเหตุ |
|---|---|
| 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
เวอร์ชัน iOS ขั้นต่ำที่ Google Mobile Ads SDK เวอร์ชัน 9.0.0 รองรับคือ iOS 11
การอัปเกรดเป็น Google Mobile Ads SDK เวอร์ชัน 9.0.0 จะไม่ทำให้แอปของคุณหยุดทำงานในอุปกรณ์ iOS 10 แต่จะไม่มีการแสดงโฆษณาในอุปกรณ์เหล่านั้น
การบังคับใช้การควบคุมแถบสถานะที่เข้มงวดยิ่งขึ้น
ตั้งแต่เวอร์ชัน 9.0.0 เป็นต้นไป เมื่อคุณแสดงโฆษณาในรูปแบบเต็มหน้าจอ แอปควรตรวจสอบว่าโฆษณาสามารถควบคุมการแสดงแถบสถานะได้ คุณจะเห็นข้อความแสดงข้อผิดพลาดในบันทึกหากดำเนินการไม่สำเร็จ
คุณอาจไม่จำเป็นต้องทำการเปลี่ยนแปลงใดๆ เพื่อให้แน่ใจว่าสิ่งนี้จะเกิดขึ้น ทั้งนี้ขึ้นอยู่กับเลย์เอาต์เฉพาะของตัวควบคุมมุมมองในแอป พิจารณาว่าคุณต้องตั้งค่าพร็อพเพอร์ตี้ childViewControllerForStatusBarHidden ใน rootViewController ของโฆษณาหรือไม่
เปลี่ยนชื่อ adDidPresentFullScreenContent: เป็น adWillPresentFullScreenContent:
ลักษณะการทำงานจะไม่เปลี่ยนแปลง ระบบจะเรียกใช้เมธอดผู้รับมอบสิทธิ์ก่อนที่โฆษณาจะแสดง ดังนั้นชื่อเมธอดใหม่จึงแสดงฟังก์ชันการทำงานได้ดีกว่า
นำ API การตั้งค่าตำแหน่งใน GADRequest ออก
ระบบได้ลบ - (void)setLocationWithLatitude:longitude:accuracy: ออกจาก GADRequest เนื่องจาก Google ไม่ได้ใช้ข้อมูลตำแหน่งเพื่อกำหนดเป้าหมายโฆษณา ใช้ API ของบุคคลที่สามเพื่อส่งข้อมูลไปยังเครือข่ายโฆษณาของบุคคลที่สาม หากจำเป็น
การเลิกใช้งานอินเทอร์เฟซเหตุการณ์ที่กำหนดเอง
เหตุการณ์ที่กำหนดเองช่วยให้ผู้เผยแพร่โฆษณาที่ใช้สื่อกลาง Ad Manager สามารถเพิ่มการแสดงโฆษณาสื่อกลางตามลำดับขั้น (Waterfall Mediation) สำหรับเครือข่ายโฆษณาที่ไม่ได้อยู่ในเครือข่ายโฆษณาที่รองรับ
โปรโตคอลเหตุการณ์ที่กำหนดเองทั้งหมดเลิกใช้งานแล้ว แต่ให้ใช้โปรโตคอล GADMediationAdapter และ GADMediationAdEventDelegate ที่มีอยู่เพื่อให้ได้ฟังก์ชันการทำงานเดียวกันแทน การเปลี่ยนแปลงนี้จะช่วยเพิ่มความชัดเจนและช่วยให้คุณสร้างเหตุการณ์ที่กำหนดเองสำหรับโฆษณาที่มีการให้รางวัลและโฆษณา Interscroller ซึ่งก่อนหน้านี้ไม่พร้อมใช้งาน
API
ตารางด้านล่างแสดงรายการ API ของอะแดปเตอร์สื่อกลางที่สอดคล้องกับ API เหตุการณ์ที่กำหนดเองซึ่งควรใช้ตั้งแต่เวอร์ชัน 9.0.0 เป็นต้นไป
| v8 | v9 | |
|---|---|---|
| GADCustomEventBanner GADCustomEventInterstitial GADCustomEventNativeAd |
GADMediationAdapter | GADMediationBannerAd GADMediationInterstitialAd GADMediationInterscrollerAd GADMediationRewardedAd GADMediationNativeAd |
delegate
|
ตัวแทนจะแสดงผลโดยแฮนเดิลการโหลดเสร็จสมบูรณ์ของฟังก์ชันการโหลดแต่ละรายการของคลาส GADMediationAdapter
|
|
-init |
-init |
|
-requestBannerAd:parameter: |
-loadBannerForAdConfiguration: |
|
-requestInterstitialAdWith |
-loadInterstitialFor |
|
-requestNativeAdWithParameter:
|
-loadNativeAdFor |
|
| ไม่มี | -loadInterscrollerAdFor |
|
| ไม่มี | -loadRewardedAdFor |
|
-presentFromRootViewController:
|
-presentFromViewController: |
|
-handlesUserClicks |
-handlesUserClicks |
|
-handlesUserImpressions |
-handlesUserImpressions |
|
วิธีการมอบสิทธิ์
ตารางด้านล่างแสดงรายการเมธอดผู้รับมอบสิทธิ์เหตุการณ์โฆษณาสื่อกลางที่สอดคล้องกันกับเมธอดผู้รับมอบสิทธิ์เหตุการณ์ที่กำหนดเองซึ่งควรใช้ตั้งแต่เวอร์ชัน 9.0.0 เป็นต้นไป
| v8 | v9 | |
|---|---|---|
| GADCustomEventBannerDelegate GADCustomEventInterstitialDelegate GADCustomEventNativeAdDelegate |
GADMediationAdEventDelegate | GADMediationAd |
-customEventBanner:didReceiveAd:-customEventInterstitialDidReceiveAd:
|
สถานะการโหลดโฆษณาจะรวมอยู่ในแฮนเดิลการโหลดเสร็จสมบูรณ์ของฟังก์ชันการโหลดแต่ละรายการในคลาส GADMediationAdapter
|
|
-customEventBanner:didFailAd:-customEventInterstitial:didFailAd:
|
||
-customEventBannerWasClicked:-customEventInterstitialWasClicked:
|
-reportClick |
|
-customEventBannerWill-customEventInterstitialWill
|
-willPresentFullScreenView |
|
-customEventBannerWill-customEventInterstitialWill
|
-willDismissFullScreenView |
|
-customEventBannerDid-customEventInterstitialDid
|
-didDismissFullScreenView |
|
-customEventBannerWill-customEventInterstitialWill
|
-willBackgroundApplication |
|
viewControllerFor |
-[GADMediationBannerAd view] |
|
เมธอดและค่าคงที่อื่นๆ ที่ถูกนำออก/แทนที่
| การเปลี่ยนแปลงเมธอด ค่าคงที่ หรือพร็อพเพอร์ตี้ | |
|---|---|
ค่าคงที่ที่มีคำนำหน้า kGAD- รายการ
|
นำออกแล้ว ใช้ค่าคงที่ที่มีคำนำหน้า GAD-
|
GADAdNetworkResponseInfo
|
นำ credentials ออกแล้ว โปรดใช้ adUnitMapping แทน
|
GAMRequest
|
kGAMSimulatorID ใน GAMRequest เลิกใช้งานแล้ว
โปรดใช้ GADSimulatorID ใน GADRequestConfiguration แทน
|
GADCustomNativeAd
|
mediaView ใน GADCustomNativeAd เลิกใช้งานแล้ว
โปรดใช้ mediaContent แทน
|
API การซื้อในแอปใน GoogleMobileAds |
นำ API inAppPurchase รายการใน GoogleMobileAds ออกแล้ว
|
ย้ายข้อมูลจาก v7 ไปยัง v8
Google Mobile Ads SDK เวอร์ชัน 8.0.0 มีการเปลี่ยนแปลงที่สำคัญบางอย่าง รวมถึงการเปลี่ยนชื่อและการนำ API บางรายการออก
การอัปเดต API รูปแบบเต็มหน้าจอ
ตั้งแต่เวอร์ชัน 8.0.0 เป็นต้นไป โฆษณาคั่นระหว่างหน้าและโฆษณาที่มีการให้รางวัลจะใช้สไตล์โฆษณาแบบเต็มหน้าจอทั่วไปเพื่อความสอดคล้องกันมากขึ้น API โฆษณาแบบเต็มหน้าจอใหม่เหล่านี้มีความแตกต่างที่สำคัญ 2 ประการจาก API โฆษณาแบบเต็มหน้าจอเวอร์ชัน 7 ดังนี้
เมธอดคลาสแบบคงที่
loadแนวทางก่อนหน้านี้ในการโหลด/แสดงโฆษณาแบบเต็มหน้าจอมีดังนี้
- สร้างอินสแตนซ์ออบเจ็กต์โฆษณาและเก็บข้อมูลอ้างอิงไว้
- กำหนดผู้รับมอบสิทธิ์ที่จัดการ Callback การโหลดและการแสดง
- โหลดโฆษณา
- ตรวจสอบว่าโหลดโฆษณาแล้วหรือไม่โดยใช้
isReady - แสดงโฆษณา
ในเวอร์ชัน 8 วิธีการจะเปลี่ยนไปเล็กน้อย Load callback ไม่ได้เป็นส่วนหนึ่งของตัวแทนอีกต่อไป แต่จะส่งไปยังเมธอด
loadเป็นตัวแฮนเดิลการดำเนินการเสร็จสมบูรณ์แทน ดังนี้- เรียกใช้เมธอดการโหลดแบบคงที่ในคลาสโฆษณาและระบุตัวแฮนเดิลการโหลดเสร็จสมบูรณ์
- ใน Callback การโหลดเสร็จสมบูรณ์ ให้อ้างอิงโฆษณาที่โหลดซึ่งแสดงผลไว้
- กำหนดผู้รับมอบสิทธิ์ที่จัดการ Callback ของการแสดง
- แสดงโฆษณา
แนวทางใหม่นี้มีประโยชน์ดังนี้
- คุณจะไม่มีการอ้างอิงถึงโฆษณาที่ไม่ได้โหลด
- คุณไม่จำเป็นต้องเก็บออบเจ็กต์โฆษณาไว้ขณะที่กำลังโหลด
เหตุการณ์โฆษณาที่สอดคล้องกัน
ประเภทของกิจกรรม API ที่มีอยู่ v8 API เหตุการณ์การโหลด GADInterstitialDelegateหรือGADRewardedAdDelegateGAMInterstitialAdLoadCompletionHandlerหรือGADRewardedAdLoadCompletionHandlerเหตุการณ์การนำเสนอ GADFullScreenContentDelegateก่อนหน้านี้ หากต้องการรอเหตุการณ์โฆษณา คุณจะต้องลงทะเบียนคลาสที่ใช้โปรโตคอล
GADInterstitialDelegateกับพร็อพเพอร์ตี้ผู้รับมอบสิทธิ์ของโฆษณาคั่นระหว่างหน้า หรือลงทะเบียนคลาสที่ใช้โปรโตคอลGADRewardedAdDelegateกับพร็อพเพอร์ตี้ผู้รับมอบสิทธิ์ของโฆษณาที่มีการให้รางวัล ทั้งนี้ขึ้นอยู่กับรูปแบบที่คุณใช้ ผู้รับมอบสิทธิ์รายเดียวกันนี้มีเมธอดที่เกี่ยวข้องกับทั้งวงจรการโหลดและการนำเสนอของโฆษณาในเวอร์ชัน 8 เหตุการณ์การโหลดและการนำเสนอจะแยกกัน ตอนนี้คุณสามารถลงทะเบียน
GADFullScreenContentDelegateได้ทุกเมื่อก่อนแสดงโฆษณา แทนที่จะต้องตั้งค่าผู้รับมอบสิทธิ์รายเดียวก่อนโหลดโฆษณา เหตุการณ์การโหลดโฆษณาซึ่งเจาะจงสำหรับแต่ละรูปแบบจะย้ายไปยังตัวแฮนเดิลการโหลดเสร็จสมบูรณ์รายการเดียวที่ส่งผ่านในเมธอดการโหลด
โฆษณาคั่นระหว่างหน้า
โหลดโฆษณา
ข้อมูลโค้ดด้านล่างแสดงวิธีโหลดโฆษณาคั่นระหว่างหน้าและฟังเหตุการณ์เมื่อโฆษณาโหลดสําเร็จหรือไม่สําเร็จ
v7
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; }]; }
โฆษณาแบบดิสเพลย์
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"); } }
เหตุการณ์โฆษณาแบบนำเสนอ
ข้อมูลโค้ดด้านล่างแสดงวิธีจัดการ Callback เมื่อโฆษณาแสดง (สําเร็จหรือไม่สําเร็จ) และเมื่อปิดโฆษณา
v7
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."); }
ได้รับรางวัลแล้ว
โหลดโฆษณา
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(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; }
แสดงโฆษณา Display และจัดการรางวัล
โฆษณาที่มีการให้รางวัลกำหนดให้คุณต้องจัดการเหตุการณ์เมื่อผู้ใช้ได้รับรางวัล ใน GADRewardedAd API เวอร์ชัน 7 คุณจะใช้ rewardedAd:userDidEarnReward: เป็นส่วนหนึ่งของโปรโตคอล GADRewardedAdDelegate
สำหรับเวอร์ชัน 8 คุณต้องใช้ GADUserDidEarnRewardHandler เพื่อแสดงโฆษณา
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"); } }
เหตุการณ์โฆษณาแบบนำเสนอ
เมื่อใช้ GADRewardedAd API คุณจะส่ง GADRewardedAdDelegate ไปยังเมธอดที่แสดงโฆษณา เมื่อใช้ GADRewardedAd API คุณจะตั้งค่า GADFullscreenContentDelegate เป็นพร็อพเพอร์ตี้ในโฆษณาก่อนที่จะแสดงโฆษณา
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 = 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 เดิมออก
API GADRewardedAd ที่ใหม่กว่าเปิดตัวครั้งแรกเมื่อเดือนมีนาคม 2019 และเป็น API ที่มีโฆษณาที่มีการให้รางวัลที่แนะนำมานานกว่า 18 เดือน ซึ่งมีการปรับปรุงมากกว่า API GADRewardedBasedVideoAd เดิม รวมถึงความสามารถในการโหลดโฆษณาที่มีการให้รางวัลมากกว่า 1 รายการต่อครั้ง
ระบบจะนำ GADRewardedBasedVideoAd API เดิมออกใน SDK เวอร์ชัน 8.0.0
การเลิกใช้งานแบนเนอร์อัจฉริยะเพื่อเปลี่ยนไปใช้แบนเนอร์แบบปรับขนาดได้
เราเลิกใช้งานโฆษณาแบนเนอร์อัจฉริยะแล้ว และเปลี่ยนไปใช้โฆษณาแบนเนอร์แบบปรับขนาดได้แทน แบนเนอร์แบบปรับขนาดได้ให้ประสิทธิภาพที่เหนือกว่าและมีความยืดหยุ่นมากขึ้นในการตั้งค่าความกว้างของโฆษณา หากต้องการใช้แบนเนอร์แบบเต็มความกว้างต่อไป คุณยังคงใช้แบนเนอร์แบบปรับขนาดได้ตามที่แสดงในข้อมูลโค้ดต่อไปนี้
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
การนำ Callback ของแอปพลิเคชันที่ไม่ได้ใช้งานออก
เราได้นำ Callback willLeaveApplication สำหรับรูปแบบโฆษณาทุกรูปแบบออกแล้ว เพื่อใช้เมธอด applicationDidEnterBackground: และ sceneDidEnterBackground: แทน การใช้ API ระดับระบบปฏิบัติการจะแจ้งให้คุณทราบเมื่อผู้ใช้ออกจากแอป ไม่ว่าจะเกิดจากการโต้ตอบกับโฆษณาหรือไม่ก็ตาม
โปรดทราบว่า Callback willLeaveApplication ไม่ได้มีไว้เพื่อเป็นเครื่องจัดการการคลิกโฆษณา และการใช้ Callback นี้เพื่อรายงานการคลิกไม่ได้สร้างเมตริกที่ถูกต้อง ตัวอย่างเช่น การคลิกไอคอนตัวเลือกโฆษณาที่เปิดเบราว์เซอร์ภายนอกจะเรียกใช้ Callback แต่ไม่นับเป็นการคลิก
การเปลี่ยนชื่อชั้นเรียน
ตารางด้านล่างแสดงชื่อคลาสที่เฉพาะเจาะจงซึ่งมีการเปลี่ยนแปลงหรือถูกนำออกในเวอร์ชัน 8 สรุป
- ชั้นเรียนทั้งหมดที่เกี่ยวข้องกับ
GADUnifiedNativeAdเปลี่ยนชื่อเป็นGADNativeAdแล้ว - นำ
GADRewardBasedVideoAd,GADNativeExpressAdViewและGADInstreamAdออกแล้ว - คลาสทั้งหมดที่มีคำนำหน้า
DFPถูกแทนที่ด้วยคำนำหน้าGAMแล้ว
| v7.68.0 Class | คลาส 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 Class | v7.68.0 API | v8.0.0 API | หมายเหตุ |
|---|---|---|---|
| GADMobileAds | +configureWithApplicationID: | -startWithCompletionHandler: | ตอนนี้รหัสแอปได้รับการตั้งค่าใน Info.plist แล้ว |
| +disableAutomatedInApp |
-disableAutomatedInApp |
||
| +disableSDKCrashReporting | -disableSDKCrashReporting | ||
| GADRequest | testDevices | GADRequestConfiguration |
พร็อพเพอร์ตี้ testDeviceIdentifiers จะใช้กับคำขอโฆษณาทั้งหมด ส่วนพร็อพเพอร์ตี้ testDevices เดิมจะตั้งค่าตามคำขอ |
| gender | นำออกแล้ว | ||
| วันเกิด | นำออกแล้ว | ||
| +sdkVersion | GADMobileAds.sharedInstance |
||
| -setBirthday |
นำออกแล้ว | ||
| -setLocationWithDescription: | -setLocationWith |
||
| -tagForChildDirectedTreatment: | [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment] | ||
| GADErrorCode | kGADError* | GADError* | ระบบจะตัดคำนำหน้า k ออกจากค่าคงที่ของรหัสข้อผิดพลาดทั้งหมด
|
| GADBannerView | hasAutoRefreshed | autoloadEnabled | |
| inAppPurchaseDelegate | นำออกแล้ว | ||
| mediatedAdView | นำออกแล้ว | ||
| adNetworkClassName | responseInfo |
||
| DFPBannerView | -setValidAdSizesWithSizes: | -setValidAdSizes: | |
| DFPBannerViewOptions | -adSizeDelegate | นำออกแล้ว | |
| GADBannerViewDelegate | -adViewDidReceiveAd: | -bannerViewDidReceiveAd: | |
| -adView:didFailToReceive |
-bannerView:didFailToReceive |
||
| -adViewWillPresentScreen: | -bannerViewWillPresentScreen: | ||
| -adViewWillDismissScreen: | -bannerViewWillDismissScreen: | ||
| -adViewDidDismissScreen: | -bannerViewDidDismissScreen: | ||
| -adViewWillLeaveApplication: | นำออกแล้ว | ||
| GADNativeCustomTemplateAd | templateID | GADCustomNativeAd.formatID | |
| -performClickOnAssetWithKey: |
-performClickOnAssetWithKey: | ||
| GADNativeAdImageAd |
preferredImageOrientation | GADNativeAdMediaAdOptions |
|
| GADInterstitial | inAppPurchaseDelegate | นำออกแล้ว | |
| isReady | นำออกแล้ว | โปรดใช้ canPresentFrom |
|
| hasBeenUsed | นำออกแล้ว | ||
| -init | -initWithAdUnitID: | ||
| -setAdUnitID: | -initWithAdUnitID: | ||
| adNetworkClassName | responseInfo |
||
| -interstitialWill |
นำออกแล้ว | ||
| GADUnifiedNativeAd | videoController | mediaContent.videoController | |
| adNetworkClassName | responseInfo |