این صفحه انتقال نسخههای فعلی و قبلی Google Mobile Ads SDK برای iOS را پوشش میدهد. انتظار داریم نسخه ۱۳.۰.۰ را در فوریه ۲۰۲۶ منتشر کنیم.
انتقال از نسخه ۱۲ به نسخه ۱۳
حداقل هدف استقرار افزایش یافت
حداقل هدف استقرار به iOS 13 افزایش یافته است.
تغییرات در میاناهای برنامهسازی کاربردی اندازه برنمای تطبیقی لنگرانداخته
نسخه ۱۳.۰.۰ میاناهای برنامهسازی کاربردی اندازه برنمای تطبیقی لنگردار موجود را منسوخ میکند و میاناهای برنامهسازی کاربردی اندازه را برای آگهیهای برنمای تطبیقی لنگردار بزرگ معرفی میکند. Google Mobile Ads SDK میتواند بااستفاده از میاناهای برنامهسازی کاربردی اندازه آگهی حاشیهای تطبیقی لنگرانداخته بزرگ جدید، تقاضای ویدیو را به آگهیهای حاشیهای ارائه دهد.
جدول زیر جزئیات میاناهای برنامهسازی کاربردی اندازهگذاری منسوخشده و جایگزینهای آنها را نشان میدهد:
| v12 (منسوخشده) | v13 (Replacement) |
|---|---|
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargeLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLargePortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
ادامه پشتیبانی از همروندی Swift 6
نسخه ۱۳.۰.۰ همچنان پشتیبانی از همزمانی دقیق Swift 6 را اضافه میکند.
اجرای نوع سختگیرانهتری برای آرایه neighboringContentURLStrings اضافه شد
از نسخه ۱۳.۰.۰ به بعد، اگر شیئی که از نوع String نیست در آرایه neighboringContentURLStrings شناسایی شود، Google Mobile Ads SDK استثنایی را مطرح میکند.
انتقال از نسخه ۱۱ به نسخه ۱۲
ارتقا به Xcode 16.0
حداقل نسخه Xcode پشتیبانیشده به ۱۶.۰ افزایش یافته است.
پشتیبانی از نامگذاری Swift
نسخه ۱۲.۰.۰ شامل تغییراتی برای پیروی از قراردادهای نامگذاری در رهنمودهای طراحی Swift API است. این تغییرات فقط بر 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 را فهرست میکند:
| نسخه ۱۱ | نسخه ۱۲ |
|---|---|
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 |
| مدیر تبلیغات | |
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 |
ثابتها
| نسخه ۱۱ | نسخه ۱۲ |
|---|---|
GADAdLoaderAdType.gamBanner |
AdLoaderAdType.adManagerBanner |
GADAdSizeBanner |
AdSizeBanner |
GADAdSizeFluid |
AdSizeFluid |
GADAdSizeFullBanner |
AdSizeFullBanner |
GADAdSizeInvalid |
AdSizeInvalid |
GADAdSizeLargeBanner |
AdSizeLargeBanner |
GADAdSizeLeaderboard |
AdSizeLeaderboard |
GADAdSizeMediumRectangle |
AdSizeMediumRectangle |
GADAdSizeSkyscraper |
AdSizeSkyscraper |
GoogleMobileAdsVersionString |
GoogleMobileAdsVersion |
مشخصات
| نوع | نسخه ۱۱ | نسخه ۱۲ |
|---|---|---|
| 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 |
توابع
| نوع | نسخه ۱۱ | نسخه ۱۲ |
|---|---|---|
| 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 استفاده کنید.
تغییرات میانای برنامهسازی کاربردی برای کنترل وضعیت بیصدا کردن ویدیو
خصوصیت isMuted و روش setMute: در GADVideoController با خصوصیت muted جایگزین شده است.
تغییرات در آگهیهای تطبیقی درونخطی
برای بهینهسازی استفاده از فضا، آگهیهای تطبیقی درونخطی در ابتدا هیچ فضایی را در قاب اشغال نمیکنند. فراخوانی CGSizeFromGADAdSize(_:) با
اندازه آگهی تطبیقی درونخطی اکنون ارتفاع 0 را برمیگرداند تا زمانی که «کیت توسعه نرمافزار
تبلیغات تلفن همراه» Google آگهی را برگرداند.
آگهیهای جستجوی سفارشی برداشتهشده
کلاسهای زیر بدون جایگزین برداشته شدهاند:
GADDynamicHeightSearchBannerViewGADDynamicHeightSearchRequestGADSearchBannerView
تغییرات در کدهای خطا
کدهای خطای زیر تغییر کردهاند:
| کلاس | یادداشتها |
|---|---|
GADErrorMediationNoFill |
خطاها اکنون بهصورت GADErrorNoFill برگردانده میشوند. |
GADErrorReceivedInvalidResponse |
با GADErrorReceivedInvalidAdString جایگزین شده است. |
GADSimulatorID برداشته شد
GADSimulatorID برداشته شد. شبیهسازها بهطور پیشفرض در حالت آزمایشی هستند.
تغییرات در هدفیابی سفارشی
واژهنامه customTargeting در GADRequest اکنون از Any بهجای String بهعنوان نوع مقدار استفاده میکند. این کار به شما امکان میدهد مقادیر عددی را به API ارسال کنید.
تغییرات در پارامترهای اضافی
- ارسال کلیدها به
additionalParametersدیگر هدفیابی سفارشی را برای درخواستهای آگهی Ad Manager اعمال نمیکند. برای اعمال هدفیابی سفارشی، به هدفیابی سفارشی مراجعه کنید.
- انتقال کلید
max_ad_content_ratingبهadditionalParametersدیگر پشتیبانی نمیشود. برای تنظیم حداکثر ردهبندی محتوای آگهی، فیلتر کردن محتوای آگهی را ببینید.
انتقال از نسخه ۱۰ به نسخه ۱۱
حداقل هدف استقرار
حداقل هدف استقرار به iOS 12 افزایش یافته است.
حداقل نسخه Xcode
حداقل نسخه Xcode پشتیبانیشده به ۱۵.۱ افزایش یافته است.
آگهیها در iOS 12 ارائه نمیشوند
Google Mobile Ads SDK نسخه ۱۱.۰.۰ فقط در دستگاههای دارای iOS 13 و بالاتر آگهی ارائه میدهد.
وابستگی GoogleAppMeasurement برداشته شد
در نسخه ۱۱.۰.۰، وابستگی به
GoogleAppMeasurement
برداشته شده است. این وابستگی که کلید سنجههای کاربر را در AdMob فعال میکرد در اوایل سال ۲۰۲۴
متوقف خواهد شد. برای
ادامه جمعآوری سنجههای کاربر در AdMob،
برنامه AdMob خود را به Firebase پیوند دهید و
کیت توسعه نرمافزار
Google Analytics برای Firebase را در
برنامهتان ادغام کنید.
تغییرات در ارائه آگهی تمامصفحه
تغییرات زیر بر قالبهای آگهی مختلف تأثیر میگذارد:
- باز شدن برنامه
- بینابینی
- پاداش
- بینابینی پاداشدار
پارامتر کنترلکننده نما در -canPresentFromRootViewController:error: و
-presentFromRootViewController: میتواند تهی باشد. اگر nil ارسال شود، آگهی از بالاترین کنترلکننده نما در سلسلهمراتب کنترلکننده نما ارائه میشود.
روشها برداشته شد
روشهای زیر برداشته میشوند.
| v11.0.0 Type | روش | یادداشتها |
|---|---|---|
| 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 بدون جایگزین برداشته شد.
تغییرات اعمالشده در ثبت نسخه کیت توسعه نرمافزار
نسخه ۱۱.۰.۰ sdkVersion را برمیدارد. برای ثبت نسخه Google Mobile Ads SDK،
از versionNumber
استفاده کنید.
نسخه ۱۰.۰.۰
GADMobileAds.sharedInstance().sdkVersion
نسخه ۱۱.۰.۰
GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)
تغییرات در رسیدگی به خطای GADAdLoader
از نسخه ۱۱.۰.۰، GADAdLoader اگر
delegate
با پروتکل نماینده نوع آگهی درخواستی مطابقت نداشته باشد، درخواست آگهی نمیکند. قبلاً،
پساز درخواست آگهی ناموفق بود.
تغییرات در رفتار آزمایش
جدول زیر را ببینید که شرایط بهروزشده را برای زمانی که ویژگیهای زیر
true را برمیگردانند نشان میدهد.
| کلاس | دارایی |
|---|---|
| GADMediationAdConfiguration | isTestRequest |
| GADCustomEventRequest | isTesting |
| v10.0.0 | v11.0.0 |
|
|
انتقال از نسخه ۹ به نسخه ۱۰
آگهیها در iOS 11 ارائه نمیشوند
Google Mobile Ads SDK نسخه ۱۰.۰.۰ فقط در دستگاههای دارای iOS نسخه ۱۲ و بالاتر آگهی ارائه میدهد.
ارتقا به نسخه 10.0.0 از Google Mobile Ads SDK باعث ازکار افتادن برنامهتان در دستگاههای iOS 11 و iOS 10 نمیشود، اما هیچ آگهیای در این دستگاهها ارائه نخواهد شد.
الزام شناسه برنامه Ad Manager
اکنون «شناسه برنامه Ad Manager» در Info.plist برای همه برنامههای Ad Manager الزامی است و
باید قالب ca-app-pub-################~########## داشته باشد. برای جزئیات بیشتر،
Info.plist را بهروز کنید.
الزام GoogleAppMeasurement.xcframework
اکنون GoogleAppMeasurement.xcframework برای همه برنامههای Ad Manager الزامی است. اگر Google Mobile Ads SDK را ازطریق Cocoapods یا Swift Package Manager نصب کنید، هیچ اقدام دیگری لازم نیست. اگر چارچوبها را بهصورت دستی نصب میکنید، برای جزئیات بیشتر به بارگیری دستی مراجعه کنید.
ساختن با بیتکد دیگر پشتیبانی نمیشود
اکنون برای ادغام کردن Google Mobile Ads SDK، غیرفعال کردن بیتکد در برنامههای تلفن همراه الزامی است.
انواع برداشته شد
| نوع | یادداشتها |
|---|---|
| GADGender | بدون جایگزین. |
| GADMRewardBasedVideoAdNetworkAdapterProtocol | همه آداپتورهای واسطهگری پاداشدار فهرستشده در انتخاب شبکهها بیشاز یک سال است که استفاده از این پروتکلها را متوقف کردهاند. از GADMediationAdapter برای میانجیگری و رویدادهای سفارشی استفاده کنید. |
| GADMRewardBasedVideoAdNetworkConnectorProtocol |
داراییها برداشته شد
ویژگیهای زیر بدون جایگزین برداشته میشوند.
| کلاس v10.0.0 | دارایی |
|---|---|
| GADMediationAdRequest | userBirthday |
| userGender | |
| userHasLocation | |
| userLatitude | |
| userLongitude | |
| userLocationAccuracyInMeters | |
| userLocationDescription | |
| GADCustomEventRequest | userHasLocation |
| userLatitude | |
| userLongitude | |
| userLocationAccuracyInMeters | |
| userLocationDescription |
انتقال از نسخه ۸ به نسخه ۹
آگهیها در iOS 10 ارائه نمیشوند
حداقل نسخه iOS که نسخه Google Mobile Ads SDK ۹.۰.۰ پشتیبانی میکند iOS ۱۱ است.
ارتقا به نسخه 9.0.0 از Google Mobile Ads SDK باعث ازکار افتادن برنامهتان در دستگاههای iOS 10 نمیشود، اما هیچ آگهیای در این دستگاهها ارائه نخواهد شد.
اجرای سختگیرانهتر کنترلهای نوار وضعیت
از نسخه ۹.۰.۰ به بعد، وقتی آگهیهای قالب تمامصفحه را ارائه میکنید، برنامهتان باید مطمئن شود که آگهیها میتوانند ارائه نوار وضعیت را کنترل کنند. اگر این کار را انجام ندهید، پیام خطایی در گزارشها خواهید دید.
بسته به چیدمان خاص کنترلکنندههای نما در برنامهتان، ممکن است برای اطمینان از این موضوع نیازی به ایجاد هیچ تغییری نداشته باشید. بررسی کنید که آیا لازم است ویژگی
childViewControllerForStatusBarHidden
را در rootViewController آگهیتان تنظیم کنید.
تغییر نام adDidPresentFullScreenContent: به adWillPresentFullScreenContent:
هیچ تغییری در رفتار وجود ندارد. روش نماینده درست قبلاز ارائه آگهی فراخوانده میشود، بنابراین نام روش جدید عملکرد آن را بهتر نشان میدهد.
برداشتن میانای برنامهسازی کاربردی تنظیم مکان در GADRequest
- (void)setLocationWithLatitude:longitude:accuracy: از
GADRequest حذف شده است زیرا Google از دادههای مکان برای هدفیابی آگهیها استفاده نمیکند. درصورت لزوم، از میاناهای برنامهسازی کاربردی شخص ثالث برای ارائه اطلاعات به شبکههای آگهی شخص ثالث استفاده کنید.
منسوخ شدن میاناهای رویداد سفارشی
رویدادهای سفارشی به ناشران امکان میدهد بااستفاده از «میانجیگری Ad Manager»، میانجیگری آبشاری را برای شبکه آگهیای که جزو شبکههای آگهی پشتیبانیشده نیست اضافه کنند.
همه پروتکلهای رویداد سفارشی منسوخ شدهاند. درعوض، از پروتکلهای موجود
GADMediationAdapter
و
GADMediationAdEventDelegate
برای دستیابی به همان عملکردها استفاده کنید. این تغییر شفافیت را بهبود میبخشد و
به شما امکان میدهد رویدادهای سفارشی برای آگهیهای پاداشدار و آگهیهای بینصفحهای ایجاد کنید که
قبلاً دردسترس نبودند.
میاناهای برنامهسازی کاربردی (API)
جدول زیر میاناهای برنامهسازی کاربردی آداپتور میانجی مربوطه را برای میاناهای برنامهسازی کاربردی رویدادهای سفارشی که باید از نسخه ۹.۰.۰ به بعد استفاده شوند فهرست میکند.
| 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 |
|
روشهای واگذاری
جدول زیر روشهای نماینده رویداد آگهی میانجی مربوطه را برای روشهای نماینده رویداد سفارشی که باید از نسخه ۹.۰.۰ شروع شوند، فهرست میکند.
| 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 استفاده کنید.
|
میاناهای برنامهسازی کاربردی خرید درونبرنامهای در GoogleMobileAds |
inAppPurchase میانای برنامهسازی کاربردی در GoogleMobileAds
برداشته شد.
|
انتقال از نسخه ۷ به نسخه ۸
Google Mobile Ads SDK نسخه ۸.۰.۰ چند تغییر عمده و همچنین تغییر نام و حذف برخیاز میاناهای برنامهسازی کاربردی را معرفی میکند.
بهروزرسانیهای میانای برنامهسازی کاربردی قالب تمامصفحه
از نسخه ۸.۰.۰، آگهیهای بینابینی و پاداشدار از سبک آگهی تمامصفحه عمومی مشترکی استفاده میکنند تا سازگاری بیشتری داشته باشند. این میاناهای برنامهسازی کاربردی آگهی تمامصفحه جدید دو تفاوت عمده با میاناهای برنامهسازی کاربردی آگهی تمامصفحه نسخه ۷ دارند:
روش کلاس ثابت
load.رویکرد قبلی برای بار کردن/ نشان دادن آگهی تمامصفحه بهصورت زیر است:
- یک نمونه شیء آگهی ایجاد کنید و مرجعی برای آن نگه دارید.
- نمایندهای را اختصاص دهید که فراخوانیهای برگشتی بار کردن و نمایش را مدیریت کند.
- آگهیای را بار کنید.
- بررسی کنید که آیا آگهی بااستفاده از
isReadyبار شده است یا نه. - آگهی را نشان دهید.
در نسخه ۸، رویکرد کمی تغییر میکند. فراخوانیهای برگشتی بارگیری دیگر بخشی از نماینده نیستند. درعوض، آنها بهعنوان یک کنترلکننده تکمیل به روش
loadمنتقل میشوند:- یک روش بارگذاری ثابت را در کلاس آگهی فراخوانی کنید و یک کنترلکننده تکمیل بارگذاری ارائه دهید.
- در فراخوانی برگشتی تکمیل بارگیری، مرجعی به آگهی بارشده که برگردانده شده است نگه دارید.
- نمایندهای را اختصاص دهید که فراخوانیهای برگشتی نمایش را مدیریت کند.
- آگهی را نشان دهید.
رویکرد جدید این مزایا را ارائه میدهد:
- هرگز ارجاعی به آگهیای که بار نشده است نخواهید داشت.
- لازم نیست شیء آگهی را درحین بار شدن نگه دارید.
رویدادهای آگهی ثابت.
نوع رویداد میانای برنامهسازی کاربردی موجود v8 API رویدادهای بار کردن GADInterstitialDelegateیاGADRewardedAdDelegateGAMInterstitialAdLoadCompletionHandlerیاGADRewardedAdLoadCompletionHandlerرویدادهای ارائه GADFullScreenContentDelegatePreviously, to listen for any ad events, you would register a class that implements the
GADInterstitialDelegateprotocol to an interstitial's delegate property, or register a class that implements theGADRewardedAdDelegateprotocol to a rewarded ad's delegate property depending on which format you're using. این نماینده روشهایی مربوط به چرخه عمر بار کردن و ارائه آگهی داشت.در نسخه ۸، رویدادهای بار کردن و ارائه جدا هستند. اکنون میتوانید
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)") } }
آبجکتیو-سی
@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 } ) } }
آبجکتیو-سی
@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") } }
آبجکتیو-سی
- (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") } }
آبجکتیو-سی
- (void)showInterstitial: { ... if (self.interstitial) { [self.interstitial presentFromRootViewController:self]; } else { NSLog(@"Ad wasn't ready"); } }
رویدادهای آگهی ارائه
تکهکدهای زیر به شما نشان میدهند که چگونه تماسهای برگشتی را برای زمانی که آگهی ارائه میشود (موفق یا ناموفق) و زمانی که رد میشود، مدیریت کنید.
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.") }
آبجکتیو-سی
- (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.") }
آبجکتیو-سی
- (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.") } } } }
آبجکتیو-سی
@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 } ) } }
آبجکتیو-سی
@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; }
نمایش آگهی و مدیریت پاداش
آگهیهای پاداشدار از شما میخواهند که رویداد را زمانی که کاربر پاداش دریافت میکند، مدیریت کنید. با
نسخه ۷ از GADRewardedAd API، شما
rewardedAd:userDidEarnReward: را بهعنوان بخشی از پروتکل GADRewardedAdDelegate پیادهسازی میکنید.
برای نسخه ۸، 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. }
آبجکتیو-سی
- (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") } }
آبجکتیو-سی
- (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، یک 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).") }
آبجکتیو-سی
- (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).") }
آبجکتیو-سی
- (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
اولینبار در مارس ۲۰۱۹ معرفی شد و بیشاز ۱۸ ماه است که API پاداشدار ترجیحی بوده است. این میانای برنامهسازی کاربردی درمقایسه با میانای برنامهسازی کاربردی قدیمی GADRewardedBasedVideoAd بهبودهای بیشتری داشته است، ازجمله توانایی بار کردن بیش از یک آگهی پاداشدار در هر نوبت.
GADRewardedBasedVideoAd API قدیمی در کیت توسعه نرمافزار نسخه ۸.۰.۰ برداشته شده است.
منسوخ شدن برنمای هوشمند بهنفع برنمای تطبیقی
آگهیهای برنمای هوشمند منسوخ شدهاند و آگهیهای برنمای تطبیقی جایگزین آنها شدهاند. برنماهای تطبیقی عملکرد برتر و انعطافپذیری بیشتری در تنظیم عرض آگهی ارائه میدهند. اگر ترجیح میدهید همچنان از برنماهای با عرض کامل استفاده کنید، همانطور که در تکهکد زیر نشان داده شده است، همچنان میتوانید این کار را بااستفاده از برنمای تطبیقی انجام دهید:
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) } }
آبجکتیو-سی
@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:
برداشته شده است. استفاده از میاناهای برنامهسازی کاربردی سطح سیستمعامل به شما اطلاع میدهد که کاربران چه زمانی برنامهتان را ترک میکنند، صرفنظر از اینکه این اتفاق بهدلیل تعامل با آگهی باشد یا نه.
توجه داشته باشید که فراخوانی برگشتی willLeaveApplication هرگز قرار نبوده است که
گرداننده کلیک آگهی باشد و تکیه بر این فراخوانی برگشتی برای گزارش کردن کلیکها
سنجه دقیقی تولید نمیکند. برای مثال، کلیک روی نماد AdChoices که مرورگر خارجی را راهاندازی میکرد، فراخوانی برگشتی را فراخوانی میکرد اما کلیک را نمیشمرد.
تغییر نام کلاس
جدول زیر نام کلاسهای خاصی را که در نسخه ۸ تغییر کرده یا حذف شدهاند فهرست میکند. بهطور خلاصه:
- نام همه کلاسهای مرتبط با
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 | برداشتهشده |
روشهای برداشتهشده/ جایگزینشده
جدول زیر تغییرات خاص در نسخه ۸ را فهرست میکند. بهطور خلاصه:
- روشها و ویژگیهای منسوخشده قبلی برداشته شدهاند.
- روشهای نماینده
-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 برای هر درخواست تنظیم میشد. |
| جنسیت | برداشتهشده | ||
| تولد | برداشتهشده | ||
| +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 |