หน้านี้ครอบคลุมการย้ายข้อมูลสำหรับ 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
ตัวอย่างเนมสเปซต่อไปนี้เป็นคลาส Request
ของ Google Mobile Ads SDK
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 จะแสดงโฆษณา
นําโฆษณา Search ที่กําหนดเองออกแล้ว
ระบบจะนำคลาสต่อไปนี้ออกโดยไม่มีคลาสอื่นมาแทนที่
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 แต่โฆษณาจะไม่แสดงในอุปกรณ์เหล่านั้น
ระบบไม่รองรับการสร้างด้วยบิตโค้ดอีกต่อไป
ตอนนี้คุณต้องปิดใช้บิตโค้ดในแอปบนอุปกรณ์เคลื่อนที่เพื่อผสานรวม 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
ที่มีอยู่เพื่อให้ได้ฟังก์ชันการทำงานแบบเดียวกัน การเปลี่ยนแปลงนี้ช่วยเพิ่มความชัดเจนและช่วยให้คุณสร้างเหตุการณ์ที่กําหนดเองสําหรับโฆษณาที่มีการให้รางวัลและโฆษณาระหว่างหน้าเว็บได้ ซึ่งก่อนหน้านี้ไม่สามารถทำได้
API
ตารางด้านล่างแสดงรายการ API ของ Mediation Adapter ที่สอดคล้องกันกับเหตุการณ์ที่กําหนดเองซึ่งควรใช้ตั้งแต่เวอร์ชัน 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 instead.
|
GADCustomNativeAd
|
mediaView ใน GADCustomNativeAd เลิกใช้งานแล้ว
ให้ใช้ mediaContent แทน
|
In-App Purchase API ใน GoogleMobileAds |
ระบบนำ inAppPurchase API ใน GoogleMobileAds ออกแล้ว
|
ย้ายข้อมูลจาก v7 ไปยัง v8
Google Mobile Ads SDK เวอร์ชัน 8.0.0 มีการเปลี่ยนแปลงที่สำคัญ 2-3 อย่าง การเปลี่ยนชื่อและการนำ API ออกบางส่วน
การอัปเดต API รูปแบบเต็มหน้าจอ
เริ่มตั้งแต่เวอร์ชัน 8.0.0 เป็นต้นไป โฆษณาคั่นระหว่างหน้าและโฆษณาที่มีการให้รางวัลจะใช้ สไตล์โฆษณาเพื่อให้สอดคล้องกันมากขึ้น API โฆษณาแบบเต็มหน้าจอใหม่นี้มี ข้อแตกต่างที่สำคัญจาก API โฆษณาแบบเต็มหน้าจอเวอร์ชัน 7 ได้แก่
เมธอดของคลาสแบบคงที่
load
วิธีโหลด/แสดงโฆษณาแบบเต็มหน้าจอก่อนหน้านี้มีดังนี้
- สร้างอินสแตนซ์ออบเจ็กต์โฆษณาและเก็บข้อมูลอ้างอิงไว้
- กำหนดผู้รับมอบสิทธิ์ที่จัดการโหลดและแสดง Callback
- โหลดโฆษณา
- ตรวจสอบว่าโฆษณาโหลดโดยใช้
isReady
หรือไม่ - แสดงโฆษณา
ในเวอร์ชัน 8 แนวทางการเปลี่ยนแปลงเล็กน้อย ยกเลิกการโหลด Callback แล้ว ของผู้ที่ได้รับมอบสิทธิ์ แต่จะส่งเข้าไปในเมธอด
load
แทน เครื่องจัดการการทำงานเสร็จสมบูรณ์:- เรียกเมธอดการโหลดแบบคงที่ในคลาสโฆษณาและแจ้งการโหลดจนเสร็จสมบูรณ์ เครื่องจัดการ
- ใน Callback ที่โหลดเสร็จสมบูรณ์ ให้ใช้การอ้างอิงโฆษณาที่โหลดซึ่ง ส่งคืนแล้ว
- กำหนดผู้รับมอบสิทธิ์ที่จัดการ Callback ของรายการ
- แสดงโฆษณา
แนวทางใหม่จะให้ประโยชน์ดังต่อไปนี้
- จะไม่มีการอ้างอิงไปยังโฆษณาที่ไม่โหลด
- คุณไม่ต้องยึดออบเจ็กต์โฆษณาไว้ขณะโหลด
เหตุการณ์โฆษณาที่สอดคล้องกัน
ประเภทของกิจกรรม API ที่มีอยู่ API V8 เหตุการณ์การโหลด GADInterstitialDelegate
หรือ วันที่GADRewardedAdDelegate
GADInterstitialAdLoadCompletionHandler
หรือ วันที่GADRewardedAdLoadCompletionHandler
กิจกรรมการนำเสนอ GADFullScreenContentDelegate
ก่อนหน้านี้ หากต้องการฟังเหตุการณ์โฆษณา คุณจะต้องลงทะเบียนชั้นเรียนที่ จะใช้
GADInterstitialDelegate
ไปยังพร็อพเพอร์ตี้ผู้รับมอบสิทธิ์ของโฆษณาคั่นระหว่างหน้า หรือลงทะเบียนคลาสที่ จะใช้GADRewardedAdDelegate
ไปยังพร็อพเพอร์ตี้ผู้รับมอบสิทธิ์ของโฆษณาที่มีการให้รางวัล ทั้งนี้ขึ้นอยู่กับรูปแบบใด ที่คุณใช้อยู่ ผู้รับมอบสิทธิ์เดียวกันนี้มีวิธีที่เกี่ยวข้องกับทั้งการโหลดและ การนำเสนอโฆษณาเมื่อใช้เวอร์ชัน 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"); } }
เหตุการณ์โฆษณาการนำเสนอ
ข้อมูลโค้ดด้านล่างแสดงวิธีจัดการ Callback เมื่อโฆษณา แสดง (ไม่ว่าจะสำเร็จหรือไม่สำเร็จ) และเมื่อปิดไป
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; }
แสดงโฆษณาและจัดการรางวัล
โฆษณาที่มีการให้รางวัลกำหนดให้คุณจัดการกิจกรรมเมื่อผู้ใช้ได้รับรางวัล ด้วย
เวอร์ชัน 7 ของ GADRewardedAd
API คุณใช้
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."); }
การนำ GADมีการให้รางวัลBasedVideoAd API เดิมออก
ใหม่
GADRewardedAd
API เปิดตัวครั้งแรกในเดือนมีนาคม 2019 ซึ่งเป็นรูปแบบที่มีการให้รางวัลมากกว่า
API มานานกว่า 18 เดือน ซึ่งมีประสิทธิภาพดีขึ้นเมื่อเทียบกับรุ่นเดิม
GADRewardedBasedVideoAd
API ซึ่งรวมถึงความสามารถในการโหลดมากกว่า 1 รายการ
ที่มีการให้รางวัลครั้งละ 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 ของแอปพลิเคชันออก
willLeaveApplication
การติดต่อกลับสำหรับรูปแบบโฆษณาทั้งหมดได้รับการ
ถูกนำออกเพื่อให้
applicationDidEnterBackground:
และ
sceneDidEnterBackground:
การใช้ API ระดับระบบปฏิบัติการจะแจ้งให้คุณทราบเมื่อใดก็ตามที่ผู้ใช้ออกจากแอปโดยไม่คํานึงถึง
เป็นผลมาจากการโต้ตอบกับโฆษณาหรือไม่
โปรดทราบว่า willLeaveApplication
การติดต่อกลับไม่ได้มีเจตนาที่จะเป็น
เครื่องจัดการการคลิกโฆษณา และใช้ Callback นี้เพื่อรายงานการคลิกไม่ได้
สร้างเมตริกที่แม่นยำ เช่น การคลิกที่ตัวเลือกโฆษณาอื่นๆ
ที่เปิดเบราว์เซอร์ภายนอกเรียกใช้ Callback แต่ไม่ได้นับ
คลิก
การเปลี่ยนชื่อชั้นเรียน
ตารางด้านล่างแสดงชื่อคลาสเฉพาะที่มีการเปลี่ยนแปลงหรือถูกนำออกใน เวอร์ชัน 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 |
โฆษณาเนทีฟแบบรวม GAD | 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 | API เวอร์ชัน 7.68.0 | API เวอร์ชัน 8.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 | นำออกแล้ว | ใช้ canOfferFrom |
|
hasBeenUsed | นำออกแล้ว | ||
-init | -initWithAdUnitID: | ||
-setAdUnitID: | -initWithAdUnitID: | ||
adNetworkClassName | responseInfo |
||
-interstitialWill |
นำออกแล้ว | ||
โฆษณาเนทีฟแบบรวม GAD | videoController | mediaContent.videoController | |
adNetworkClassName | responseInfo |