หน้านี้ครอบคลุมการย้ายข้อมูลสำหรับ SDK โฆษณาในอุปกรณ์เคลื่อนที่ของ Google สำหรับ iOS เวอร์ชันปัจจุบันและเวอร์ชันก่อนหน้า คาดว่าจะเปิดตัวเวอร์ชัน 12.0.0 ในเดือนกุมภาพันธ์ 2025
ย้ายข้อมูลจาก SDK เวอร์ชัน v11 เป็น v12
อัปเกรดเป็น Xcode 16.0
เวอร์ชัน Xcode ขั้นต่ำที่รองรับเพิ่มขึ้นเป็น 16.0
การสนับสนุนการตั้งชื่อ Swift
เวอร์ชัน 12.0.0 มีการเปลี่ยนแปลงเพื่อให้เป็นไปตามหลักเกณฑ์การตั้งชื่อใน API Design Guidelines ของ Swift การเปลี่ยนแปลงเหล่านี้ส่งผลต่อ Swift เท่านั้น ไม่มีการเปลี่ยนแปลงการตั้งชื่อใน Objective-C API
การเปลี่ยนแปลงคำนำหน้าของชั้นเรียน
มีการเปลี่ยนแปลงคำนำหน้าของชั้นเรียนดังนี้
- นำคำนำหน้า
GAD
ออกจากชื่อของทุกประเภท - เปลี่ยนชื่อคำนำหน้า
GAM
เป็นAdManager
- เปลี่ยนชื่อคำนำหน้า
GADM
เป็นMediation
แก้ไขข้อผิดพลาด
วิธีที่ดีที่สุดในการแก้ไขข้อผิดพลาดที่เกิดจากการเปลี่ยนแปลงเหล่านี้คือทำการแก้ไขด้วยฟีเจอร์แก้ไข
แก้ไขความขัดแย้งในการตั้งชื่อ
หากต้องการแก้ไขการตั้งชื่อที่ขัดแย้งกัน ให้ใช้เนมสเปซที่โมดูลระบุ เช่น ตอนนี้ GADRequest
เปลี่ยนชื่อเป็น Request
แล้ว ตัวอย่าง Namespace ต่อไปนี้
คลาส SDK โฆษณาในอุปกรณ์เคลื่อนที่ของ Google 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:) |
การเปลี่ยนแปลง API ในการควบคุมสถานะปิดเสียงวิดีโอ
พร็อพเพอร์ตี้ isMuted
และเมธอด setMute:
ใน GADVideoController
จะถูกแทนที่ด้วยพร็อพเพอร์ตี้ muted
การเปลี่ยนแปลงโฆษณาแบบปรับขนาดได้ที่แทรกในบรรทัด
โฆษณาแบบปรับได้ในบรรทัดจะไม่มีพื้นที่ในเฟรมในตอนแรกเพื่อเพิ่มประสิทธิภาพการใช้พื้นที่
การเรียกใช้ CGSizeFromGADAdSize(_:)
ที่มีขนาดโฆษณาที่ปรับให้เข้ากับพื้นที่โฆษณาแบบอินไลน์จะแสดงผลความสูงเป็น 0
จนกว่า SDK โฆษณาในอุปกรณ์เคลื่อนที่ของ Google จะแสดงโฆษณา
นำโฆษณาที่กำหนดเองในเครือข่ายการค้นหาออกแล้ว
ระบบจะนำคลาสต่อไปนี้ออกโดยไม่มีการแทนที่
GADDynamicHeightSearchBannerView
GADDynamicHeightSearchRequest
GADSearchBannerView
การเปลี่ยนแปลงรหัสข้อผิดพลาด
รหัสข้อผิดพลาดต่อไปนี้มีการเปลี่ยนแปลง
ระดับ | หมายเหตุ |
---|---|
GADErrorMediationNoFill |
ตอนนี้ข้อผิดพลาดจะแสดงเป็น GADErrorNoFill |
GADErrorReceivedInvalidResponse |
ถูกแทนที่ด้วย GADErrorReceivedInvalidAdString แล้ว |
นำ GADSimulatorID ออกแล้ว
นำ GADSimulatorID
ออกแล้ว โดยค่าเริ่มต้น โปรแกรมจำลองจะอยู่ในโหมดทดสอบอยู่แล้ว
การเปลี่ยนแปลงการกำหนดเป้าหมายเอง
ขณะนี้customTargeting
ใน GADRequest
ใช้ Any
แทน
String
เป็นประเภทค่า ซึ่งช่วยให้คุณส่งค่าตัวเลขไปยัง API ได้
การเปลี่ยนแปลงพารามิเตอร์เสริม
- ระบบไม่รองรับการส่งคีย์
max_ad_content_rating
ไปยังadditionalParameters
อีกต่อไป หากต้องการกำหนดการจัดประเภทเนื้อหาโฆษณาสูงสุด โปรดดูการกรองเนื้อหาโฆษณา
ย้ายข้อมูลจาก v10 ไปยัง v11
เป้าหมายการทำให้ใช้งานได้ขั้นต่ำ
เราได้เพิ่มเป้าหมายการทำให้ใช้งานได้ขั้นต่ำเป็น iOS 12
เวอร์ชัน Xcode ขั้นต่ำ
เราได้เพิ่มเวอร์ชัน Xcode ขั้นต่ำที่รองรับเป็น 15.1
โฆษณาหยุดแสดงใน iOS 12
SDK โฆษณาในอุปกรณ์เคลื่อนที่ของ Google เวอร์ชัน 11.0.0 จะแสดงโฆษณาในอุปกรณ์ที่ใช้ iOS 13 ขึ้นไปเท่านั้น
นำการขึ้นต่อกันของ GoogleAppMeasurement ออก
ในเวอร์ชัน 11.0.0 เราได้นำการขึ้นต่อกันของ
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
SDK โฆษณาในอุปกรณ์เคลื่อนที่ของ Google เวอร์ชัน 10.0.0 จะแสดงโฆษณาในอุปกรณ์ที่ใช้ iOS 12 ขึ้นไปเท่านั้น
การอัปเกรดเป็น Google Mobile Ads SDK เวอร์ชัน 10.0.0 จะไม่ทำให้แอปในอุปกรณ์ iOS 11 และ iOS 10 ใช้งานไม่ได้ แต่จะไม่มีการแสดงโฆษณาในอุปกรณ์เหล่านั้น
ระบบไม่รองรับการสร้างด้วยบิตโค้ดอีกต่อไป
ตอนนี้คุณต้องปิดใช้ Bitcode ในแอปบนอุปกรณ์เคลื่อนที่เพื่อผสานรวม 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 ของบุคคลที่สามเพื่อระบุข้อมูลให้กับเครือข่ายโฆษณาบุคคลที่สามหาก
จำเป็น
การเลิกใช้งานอินเทอร์เฟซเหตุการณ์ที่กำหนดเอง
เหตุการณ์ที่กำหนดเองช่วยให้ผู้เผยแพร่โฆษณาที่ใช้ สื่อกลาง AdMob เพิ่มการแสดงโฆษณาสื่อกลางตามลำดับขั้นสำหรับเครือข่ายโฆษณาที่ ไม่ใช่เครือข่ายโฆษณาที่รองรับได้
เราเลิกใช้งานโปรโตคอลเหตุการณ์ที่กำหนดเองทั้งหมดแล้ว แต่ให้ใช้โปรโตคอลที่มีอยู่
GADMediationAdapter
และ
GADMediationAdEventDelegate
แทนเพื่อใช้ฟังก์ชันการทำงานเดียวกัน การเปลี่ยนแปลงนี้ช่วยเพิ่มความชัดเจนและ
ช่วยให้คุณสร้างเหตุการณ์ที่กําหนดเองสําหรับโฆษณาที่มีการให้รางวัลและโฆษณา Interscroller ซึ่ง
ก่อนหน้านี้ยังไม่มีให้ใช้งาน
API
ตารางด้านล่างแสดงรายการ API ของ AdMob Mediation Adapter ที่สอดคล้องกับ API เหตุการณ์ที่กำหนดเอง ซึ่งควรใช้ตั้งแต่เวอร์ชัน 9.0.0 เป็นต้นไป
v8 | v9 | |
---|---|---|
GADCustomEventBanner GADCustomEventInterstitial GADCustomEventNativeAd |
GADMediationAdapter | GADMediationBannerAd GADMediationInterstitialAd GADMediationInterscrollerAd GADMediationRewardedAd GADMediationNativeAd |
delegate
|
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
แทน
|
GADCustomNativeAd
|
mediaView ใน GADCustomNativeAd เลิกใช้งานแล้ว
โปรดใช้ mediaContent แทน
|
API การซื้อในแอปใน GoogleMobileAds |
ระบบได้นำ inAppPurchase API ใน GoogleMobileAds ออกแล้ว
|
ย้ายข้อมูลจาก v7 ไปยัง v8
SDK โฆษณาในอุปกรณ์เคลื่อนที่ของ Google เวอร์ชัน 8.0.0 มีการเปลี่ยนแปลงที่สำคัญ รวมไปถึง การเปลี่ยนชื่อ API และการนำ API ออก
การอัปเดต API รูปแบบเต็มหน้าจอ
ตั้งแต่เวอร์ชัน 8.0.0 เป็นต้นไป โฆษณาคั่นกลางและโฆษณาที่มีการให้รางวัลจะใช้รูปแบบโฆษณาแบบเต็มหน้าจอทั่วไปเพื่อความสอดคล้องกันมากขึ้น API โฆษณาแบบเต็มหน้าจอใหม่เหล่านี้มีความแตกต่างที่สำคัญ 2 ประการจาก API โฆษณาแบบเต็มหน้าจอเวอร์ชัน 7 ดังนี้
เมธอดของคลาสแบบคงที่
load
แนวทางก่อนหน้านี้ในการโหลด/แสดงโฆษณาแบบเต็มหน้าจอมีดังนี้
- สร้างอินสแตนซ์ออบเจ็กต์โฆษณาและเก็บข้อมูลอ้างอิงไว้
- กำหนดผู้รับมอบสิทธิ์ที่จัดการการเรียกกลับของการโหลดและการแสดง
- โหลดโฆษณา
- ตรวจสอบว่าโหลดโฆษณาแล้วหรือยังโดยใช้
isReady
- แสดงโฆษณา
ในเวอร์ชัน 8 วิธีการจะเปลี่ยนไปเล็กน้อย การเรียกกลับของการโหลดไม่ได้เป็นส่วนหนึ่งของตัวแทนอีกต่อไป แต่จะส่งไปยังเมธอด
load
เป็นตัวแฮนเดิลการดำเนินการให้เสร็จสมบูรณ์แทน- เรียกใช้เมธอดโหลดแบบคงที่ในคลาสโฆษณาและระบุตัวแฮนเดิลการโหลดเสร็จสมบูรณ์
- ใน Callback การโหลดเสร็จสมบูรณ์ ให้เก็บการอ้างอิงถึงโฆษณาที่โหลดแล้วซึ่ง ส่งคืน
- มอบหมายผู้รับมอบสิทธิ์ที่จัดการการเรียกกลับของรายการ
- แสดงโฆษณา
แนวทางใหม่นี้มีประโยชน์ดังนี้
- คุณจะไม่เห็นการอ้างอิงถึงโฆษณาที่ไม่ได้โหลด
- คุณไม่จำเป็นต้องเก็บออบเจ็กต์โฆษณาไว้ขณะที่กำลังโหลด
เหตุการณ์โฆษณาที่สอดคล้องกัน
ประเภทของกิจกรรม API ที่มีอยู่ v8 API เหตุการณ์การโหลด GADInterstitialDelegate
หรือGADRewardedAdDelegate
GADInterstitialAdLoadCompletionHandler
หรือGADRewardedAdLoadCompletionHandler
กิจกรรมการนำเสนอ GADFullScreenContentDelegate
ก่อนหน้านี้ หากต้องการรอเหตุการณ์โฆษณา คุณจะต้องลงทะเบียนคลาสที่ ใช้โปรโตคอล
GADInterstitialDelegate
กับพร็อพเพอร์ตี้ delegate ของโฆษณาคั่นระหว่างหน้า หรือลงทะเบียนคลาสที่ ใช้โปรโตคอลGADRewardedAdDelegate
กับพร็อพเพอร์ตี้ delegate ของโฆษณาที่มีการให้รางวัล ทั้งนี้ขึ้นอยู่กับรูปแบบที่คุณใช้ ผู้มอบสิทธิ์รายเดียวกันนี้มีเมธอดที่เกี่ยวข้องกับทั้งวงจรการโหลดและการนำเสนอโฆษณาในเวอร์ชัน 8 เหตุการณ์การโหลดและเหตุการณ์การนำเสนอจะแยกกัน ตอนนี้คุณสามารถ ลงทะเบียน
GADFullScreenContentDelegate
ได้ทุกเมื่อก่อนที่จะแสดงโฆษณาแทนที่จะต้องตั้งค่า ผู้มอบสิทธิ์รายเดียว ก่อนที่จะโหลดโฆษณา เหตุการณ์การโหลดโฆษณาซึ่งเฉพาะเจาะจงสำหรับแต่ละรูปแบบจะย้ายไปยังตัวแฮนเดิลการโหลดที่เสร็จสมบูรณ์รายการเดียวที่ส่งผ่านในเมธอดโหลด
โฆษณาคั่นระหว่างหน้า
โหลดโฆษณา
ข้อมูลโค้ดด้านล่างแสดงวิธีโหลดโฆษณาคั่นระหว่างหน้าและรับฟัง เหตุการณ์เมื่อโฆษณาโหลดสําเร็จหรือไม่สําเร็จ
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; }]; }
โฆษณาแบบดิสเพลย์
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"); } }
เหตุการณ์โฆษณาในงานนำเสนอ
ข้อมูลโค้ดด้านล่างแสดงวิธีจัดการการเรียกกลับเมื่อโฆษณาแสดง (สําเร็จหรือไม่สําเร็จ) และเมื่อมีการปิดโฆษณา
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."); }
ได้รับรางวัลแล้ว
โหลดโฆษณา
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 และจัดการรางวัล
โฆษณาที่มีการให้รางวัลกำหนดให้คุณต้องจัดการเหตุการณ์เมื่อผู้ใช้ได้รับรางวัล ใน 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 = 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 เดิมออก
เราเปิดตัว API เวอร์ชันใหม่กว่า
GADRewardedAd
ครั้งแรกในเดือนมีนาคม 2019 และเป็น API ที่แนะนำสำหรับโฆษณาที่มีการให้รางวัลมานานกว่า 18 เดือน ซึ่งได้รับการปรับปรุงมากกว่า GADRewardedBasedVideoAd
API รุ่นเดิม รวมถึงความสามารถในการโหลดโฆษณาที่มีการให้รางวัลมากกว่า 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
การนำการเรียกกลับของแอปพลิเคชันที่ออกไปแล้วออก
เราได้นำwillLeaveApplication
การเรียกกลับสำหรับโฆษณาทุกรูปแบบออก
แล้วเพื่อใช้applicationDidEnterBackground:
และ
sceneDidEnterBackground:
แทน การใช้ API ระดับระบบปฏิบัติการจะแจ้งให้คุณทราบทุกครั้งที่ผู้ใช้ออกจากแอป ไม่ว่าจะเป็นเพราะการโต้ตอบกับโฆษณาหรือไม่ก็ตาม
โปรดทราบว่าเราไม่เคยตั้งใจให้willLeaveApplication
การเรียกกลับเป็น
ตัวแฮนเดิลการคลิกโฆษณา และการใช้การเรียกกลับนี้เพื่อรายงานการคลิกไม่ได้
สร้างเมตริกที่ถูกต้อง ตัวอย่างเช่น การคลิกไอคอน AdChoices
ที่เปิดเบราว์เซอร์ภายนอกจะเรียกใช้การเรียกกลับ แต่จะไม่นับการคลิก
การเปลี่ยนชื่อคลาส
ตารางด้านล่างแสดงชื่อคลาสที่เฉพาะเจาะจงซึ่งมีการเปลี่ยนแปลงหรือถูกนำออกใน เวอร์ชัน 8 โดยสรุป
- เราได้เปลี่ยนชื่อชั้นเรียนทั้งหมดที่เกี่ยวข้องกับ
GADUnifiedNativeAd
เป็นGADNativeAd
แล้ว - ระบบได้นำ
GADRewardBasedVideoAd
GADNativeExpressAdView
และGADInstreamAd
ออกแล้ว - ระบบได้แทนที่คลาสทั้งหมดที่มีคำนำหน้า
DFP
ด้วยคำนำหน้าGAM
แล้ว
v7.68.0 คลาส | คลาส v8.0.0 |
---|---|
DFPBannerView | GAMBannerView |
DFPBannerViewOptions | GAMBannerViewOptions |
DFPInterstitial | GAMInterstitialAd |
DFPRequest | GAMRequest |
GADRequestError | NSError |
GADUnifiedNativeAdView | GADNativeAdView |
GADUnifiedNativeAd | GADNativeAd |
GADUnifiedNativeAdAssetIdentifiers | GADNativeAdAssetIdentifiers |
GADUnifiedNativeAdDelegate | GADNativeAdDelegate |
GADUnifiedNativeAdUnconfirmedClickDelegate | GADNativeAdUnconfirmedClickDelegate |
GADNativeCustomTemplateAd | GADCustomNativeAd |
GADNativeCustomTemplateAdLoaderDelegate | GADCustomNativeAdLoaderDelegate |
GADNativeAdDelegate | GADCustomNativeAdDelegate |
GADInAppPurchase | นำออกแล้ว |
GADInterstitial | GADInterstitialAd |
GADNativeExpressAdView | นำออกแล้ว |
GADRewardBasedVideoAd | นำออกแล้ว |
GADInstreamAd | นำออกแล้ว |
GADInstreamAdView | นำออกแล้ว |
วิธีการที่ถูกนำออก/แทนที่
ตารางด้านล่างแสดงการเปลี่ยนแปลงที่เฉพาะเจาะจงในเวอร์ชัน 8 โดยสรุป
- ระบบได้นำเมธอดและพร็อพเพอร์ตี้ที่เลิกใช้งานไปก่อนหน้านี้ออกแล้ว
-willLeaveApplication:
delegate methods have been removed for all formats.- ชื่อคลาสเครือข่ายโฆษณาได้ย้ายไปอยู่ที่พร็อพเพอร์ตี้
GADResponseInfo
แล้ว - ตัวระบุอุปกรณ์ทดสอบได้ย้ายไปที่พร็อพเพอร์ตี้
GADRequestConfiguration
แล้ว
v7.68.0 คลาส | API v7.68.0 | API v8.0.0 | หมายเหตุ |
---|---|---|---|
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 |