این صفحه انتقالهای نسخههای فعلی و قبلی Google Mobile Ads SDK برای iOS را پوشش میدهد. نسخه 12.0.0 انتظار می رود در فوریه 2025 منتشر شود.
از نسخه SDK نسخه 11 به نسخه 12 مهاجرت کنید
به Xcode 16.0 ارتقا دهید
حداقل نسخه Xcode پشتیبانی شده به 16.0 افزایش یافته است.
پشتیبانی از نامگذاری سوئیفت
نسخه 12.0.0 شامل تغییراتی برای پیروی از قراردادهای نامگذاری در دستورالعمل های طراحی Swift API است. این تغییرات فقط روی سوئیفت تأثیر می گذارد. هیچ تغییر نامی در APIهای Objective-C ایجاد نشده است.
پیشوند کلاس تغییر می کند
تغییرات زیر در پیشوندهای کلاس ایجاد شده است:
- پیشوند
GADدر همه نامها برای همه انواع حذف شد. - پیشوند
GAMرا بهAdManagerتغییر نام داد. - نام پیشوند
GADMرا بهMediationتغییر داد.
رفع خطاها
بهترین راه برای رفع خطاهای ناشی از این تغییرات، اصلاح Fix-It است.
تضادهای نامگذاری را حل کنید
برای حل تداخل نامگذاری، از فضای نام ارائه شده توسط ماژول استفاده کنید. برای مثال، GADRequest اکنون Request نام دارد. نمونه زیر کلاس Request SDK Ads Google Mobile را در فضاهای نام قرار می دهد:
import GoogleMobileAds
...
var request: GoogleMobileAds.Request?
لیست جزئیات تغییرات سوئیفت
جداول زیر تغییرات ایجاد شده در APIهای Swift را نشان می دهد:
| نسخه 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 |
| مدیر تبلیغات | |
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 |
| GADA AudioVideoManager | 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 |
| سیگنال GADS | 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:) | |
| GADAppEvent Delegate | 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:) |
| میانجیگری | ||
| آداپتور GADMAdNetwork | 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:) |
| GAInterstitialAd | load(withAdManagerAdUnitID:request:completionHandler:) | load(with:request:completionHandler:) |
API به کنترل وضعیت بیصدا کردن ویدیو تغییر میکند
ویژگی isMuted و متد setMute: در GADVideoController با یک ویژگی muted جایگزین می شوند.
تغییرات در تبلیغات تطبیقی درون خطی
برای بهینهسازی استفاده از فضا، تبلیغات تطبیقی درون خطی در ابتدا هیچ فضایی در کادر اشغال نمیکنند. فراخوانی CGSizeFromGADAdSize(_:) با اندازه آگهی تطبیقی درون خطی، اکنون ارتفاع 0 را برمیگرداند تا زمانی که Google Mobile Ads SDK آگهی را برگرداند.
تبلیغات جستجوی سفارشی حذف شد
کلاس های زیر بدون جایگزینی حذف می شوند:
-
GADDynamicHeightSearchBannerView -
GADDynamicHeightSearchRequest -
GADSearchBannerView
تغییرات در کدهای خطا
کدهای خطای زیر تغییر کرده اند:
| کلاس | یادداشت ها |
|---|---|
GADErrorMediationNoFill | خطاها اکنون به عنوان GADErrorNoFill باز می گردند. |
GADErrorReceivedInvalidResponse | با GADErrorReceivedInvalidAdString جایگزین شده است. |
GADSimulatorID حذف شد
GADSimulatorID حذف شد. شبیه سازها به طور پیش فرض در حالت تست هستند.
تغییرات در هدف گذاری سفارشی
فرهنگ لغت customTargeting در GADRequest اکنون از Any به جای String به عنوان نوع مقدار استفاده می کند. این به شما امکان می دهد مقادیر عددی را به API ارسال کنید.
تغییرات در پارامترهای اضافی
- ارسال کلید
max_ad_content_ratingبهadditionalParametersدیگر پشتیبانی نمیشود. برای تنظیم حداکثر رتبه بندی محتوای آگهی، به فیلتر محتوای آگهی مراجعه کنید.
از نسخه 10 به نسخه 11 مهاجرت کنید
حداقل هدف استقرار
حداقل هدف استقرار به iOS 12 افزایش یافته است.
حداقل نسخه Xcode
حداقل نسخه Xcode پشتیبانی شده به 15.1 افزایش یافته است.
تبلیغات در iOS 12 متوقف می شود
Google Mobile Ads SDK نسخه 11.0.0 تبلیغات را فقط در دستگاههای دارای iOS 13 و بالاتر ارائه میکند.
وابستگی GoogleAppMeasurement حذف شد
در نسخه 11.0.0، وابستگی به GoogleAppMeasurement حذف شده است. این وابستگی که به تغییر معیارهای کاربر در AdMob کمک میکند، در اوایل سال 2024 متوقف میشود. برای ادامه جمعآوری معیارهای کاربر در AdMob، برنامه AdMob خود را به Firebase پیوند دهید و Google Analytics برای Firebase SDK را در برنامه خود ادغام کنید.
تغییرات در ارائه تبلیغات تمام صفحه
تغییرات زیر بر فرمت های تبلیغاتی مختلف تأثیر می گذارد:
- برنامه باز شد
- بینابینی
- پاداش داده شد
- بینابینی با پاداش
پارامتر view controller در -canPresentFromRootViewController:error: و -presentFromRootViewController: قابل تهی است. اگر صفر تصویب شود، تبلیغ از بالاترین نمایش کنترلر در سلسله مراتب view controller ارائه می شود.
روش ها حذف شد
روش های زیر حذف می شوند.
| v11.0.0 نوع | روش | یادداشت ها |
|---|---|---|
| GADAppOpenAd | load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) | به جای آن از load(withAdUnitID adUnitID: String, request: GADRequest?) استفاده کنید. |
| GADMediationBannerAdEvent Delegate | willBackgroundApplication() | بدون جایگزینی |
| GADMediationInterstitialAdEvent Delegate | willBackgroundApplication() | بدون جایگزینی |
| GADMediationNativeAdEvent Delegate | willBackgroundApplication() | بدون جایگزینی |
| GADMediationRewardedAdEvent Delegate | didRewardUser(with reward: GADAdReward) | به جای آن از didRewardUser() استفاده کنید. |
| GADMediatedUnifiedNativeAdNotificationSource | mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) | بدون جایگزینی |
| پیکربندی GADRequest | setSameAppKeyEnabled(_ enabled: Bool) | به جای آن setPublisherFirstPartyIDEnabled(_ enabled: Bool) استفاده کنید. |
tagForUnderAge(ofConsent underAgeOfConsent: Bool) | به جای آن از ویژگی tagForUnderAgeOfConsent استفاده کنید. | |
tag(forChildDirectedTreatment childDirectedTreatment: Bool) | به جای آن از ویژگی tagForChildDirectedTreatment استفاده کنید. |
خواص حذف شد
ویژگی های زیر حذف می شوند.
| کلاس v11.0.0 | اموال | یادداشت ها |
|---|---|---|
| GADMediationAdConfiguration | hasUserLocation | بدون جایگزینی |
| userLatitude | ||
| طول کاربر | ||
| userLocationAccuracyInMeters | ||
| کودک جهت درمان | به جای آن از GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment استفاده کنید. | |
| GADResponseInfo | adNetworkClassName | به جای آن از adNetworkClassName از loadedAdNetworkResponseInfo استفاده کنید. |
GADAdFormatUnknown حذف شد
GADAdFormatUnknown بدون جایگزینی حذف شد.
تغییرات در ورود به سیستم نسخه SDK
نسخه 11.0.0 sdkVersion حذف می کند. برای ورود به سیستم نسخه SDK تبلیغات تلفن همراه Google، به جای آن versionNumber استفاده کنید.
نسخه 10.0.0
GADMobileAds.sharedInstance().sdkVersion
نسخه 11.0.0
GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)
تغییرات در مدیریت خطای GADAdLoader
با شروع نسخه 11.0.0، GADAdLoader در صورتی که delegate آن با پروتکل نمایندگی انواع تبلیغات درخواستی مطابقت نداشته باشد، درخواست تبلیغاتی نمی کند. پیش از این، پس از درخواست آگهی انجام نشد.
تغییرات در رفتار تست
جدولی را ببینید که شرایط بهروزرسانی شده را برای زمانی که ویژگیهای زیر true میشوند نشان میدهد.
| کلاس | اموال |
|---|---|
| GADMediationAdConfiguration | isTestRequest |
| GADCustomEvent Request | isTesting |
| نسخه 10.0.0 | نسخه 11.0.0 |
|
|
از نسخه 9 به نسخه 10 مهاجرت کنید
تبلیغات در iOS 11 متوقف می شود
Google Mobile Ads SDK نسخه 10.0.0 تبلیغات را فقط در دستگاههای دارای iOS 12 و بالاتر ارائه میکند.
ارتقاء به Google Mobile Ads SDK نسخه 10.0.0 برنامه شما را در دستگاههای iOS 11 و iOS 10 خراب نمیکند، با این حال، هیچ تبلیغی در آن دستگاهها نمایش داده نمیشود.
ساخت با بیت کد دیگر پشتیبانی نمی شود
اکنون برای ادغام Google Mobile Ads SDK، غیرفعال کردن بیت کد در برنامه های تلفن همراه شما لازم است.
انواع حذف شده است
| تایپ کنید | یادداشت ها |
|---|---|
| GADGender | بدون جایگزینی |
| پروتکل GADMRewardBasedVideoAdNetworkAdapter | همه آداپتورهای واسطهای پاداشدار فهرستشده در Choose Networks استفاده از این پروتکلها را برای بیش از یک سال متوقف کردهاند. از GADMediationAdapter برای میانجیگری و رویدادهای سفارشی استفاده کنید. |
| پروتکل GADMRewardBasedVideoAdNetworkConnector |
خواص حذف شد
ویژگی های زیر بدون جایگزینی حذف می شوند.
| کلاس v10.0.0 | اموال |
|---|---|
| GADMediationAdRequest | تولد کاربر |
| userGender | |
| userHasLocation | |
| userLatitude | |
| طول کاربر | |
| userLocationAccuracyInMeters | |
| userLocationDescription | |
| GADCustomEvent Request | userHasLocation |
| userLatitude | |
| طول کاربر | |
| userLocationAccuracyInMeters | |
| userLocationDescription |
از نسخه 8 به نسخه 9 مهاجرت کنید
تبلیغات در 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:
هیچ تغییر رفتاری وجود ندارد. روش delegate درست قبل از ارائه آگهی فراخوانی می شود، بنابراین نام روش جدید عملکرد آن را بهتر نشان می دهد.
API تنظیم مکان را در GADRequest حذف کنید
- (void)setLocationWithLatitude:longitude:accuracy: از GADRequest حذف شده است زیرا اطلاعات مکان توسط Google برای هدفیابی تبلیغات استفاده نمیشود. در صورت لزوم از API های شخص ثالث برای ارائه اطلاعات به شبکه های تبلیغاتی شخص ثالث استفاده کنید.
منسوخ شدن رابط های رویداد سفارشی
رویدادهای سفارشی ناشران را با استفاده از AdMob Mediation قادر میسازد تا میانجیگری آبشاری را برای یک شبکه تبلیغاتی که یکی از شبکههای تبلیغاتی پشتیبانیشده نیست اضافه کنند.
همه پروتکل های رویداد سفارشی منسوخ شده اند. در عوض، از پروتکلهای GADMediationAdapter و GADMediationAdEventDelegate موجود برای دستیابی به عملکردهای مشابه استفاده کنید. این تغییر وضوح را بهبود میبخشد و شما را قادر میسازد رویدادهای سفارشی را برای آگهیهای دارای پاداش و آگهیهای بین اسکرولری که قبلاً در دسترس نبودند ایجاد کنید.
API ها
جدول زیر APIهای آداپتور میانجی مربوط به APIهای رویدادهای سفارشی را فهرست میکند که باید از نسخه 9.0.0 استفاده شوند.
| v8 | v9 | |
|---|---|---|
| GADCustomEventBanner GADCustomEventInterstitial GADCustomEventNativeAd | GADMediationAdapter | GADMediationBannerAd GADMediationInterstitialAd GADMediationInterscrollerAd GADMediationRewardedAd GADMediationNativeAd |
delegate | Delegate توسط کنترل کننده تکمیل بار هر تابع بار از کلاس GADMediationAdapter برگردانده می شود. | |
-init | -init | |
-requestBannerAd:parameter: label:request: | -loadBannerForAdConfiguration: completionHandler: | |
-requestInterstitialAdWith Parameter:label:request: | -loadInterstitialFor AdConfiguration: completionHandler: | |
-requestNativeAdWithParameter: request:adTypes:options: rootViewController: | -loadNativeAdFor AdConfiguration: completionHandler: | |
| N/A | -loadInterscrollerAdFor AdConfiguration: completionHandler: | |
| N/A | -loadRewardedAdFor AdConfiguration: completionHandler: | |
-presentFromRootViewController: | -presentFromViewController: | |
-handlesUserClicks | -handlesUserClicks | |
-handlesUserImpressions | -handlesUserImpressions | |
روش های تفویض اختیار
جدول زیر روشهای انتقال رویداد آگهی میانجیگری مربوط به روشهای واگذاری رویداد سفارشی را فهرست میکند که باید از نسخه 9.0.0 استفاده شوند.
| v8 | v9 | |
|---|---|---|
| GADCustomEventBannerDelegate GADCustomEventInterstitialDelegate GADCustomEventNativeAdDelegate | GADMediationAdEvent Delegate | GADMediationAd |
-customEventBanner:didReceiveAd:-customEventInterstitialDidReceiveAd: | وضعیت بار آگهی در کنترل کننده تکمیل بار هر تابع بار در کلاس GADMediationAdapter گنجانده شده است. | |
-customEventBanner:didFailAd:-customEventInterstitial:didFailAd: | ||
-customEventBannerWasClicked:-customEventInterstitialWasClicked: | -reportClick | |
-customEventBannerWill PresentModal:-customEventInterstitialWill PresentModal: | -willPresentFullScreenView | |
-customEventBannerWill DismissModal:-customEventInterstitialWill DismissModal: | -willDismissFullScreenView | |
-customEventBannerDid DismissModal:-customEventInterstitialDid DismissModal: | -didDismissFullScreenView | |
-customEventBannerWill LeaveApplication:-customEventInterstitialWill LeaveApplication: | -willBackgroundApplication | |
viewControllerFor PresentingModalView | -[GADMediationBannerAd view] | |
سایر روش ها و ثابت های حذف/جایگزین شده
| تغییرات در روش، ثابت یا ویژگی | |
|---|---|
kGAD- ثابت های پیشوند | حذف شد. از ثابت های پیشوند GAD- استفاده کنید. |
GADAdNetworkResponseInfo | credentials حذف شد به جای آن از adUnitMapping استفاده کنید. |
GADCustomNativeAd | mediaView در GADCustomNativeAd منسوخ شده است. به جای آن از mediaContent استفاده کنید. |
APIهای خرید درون برنامه ای در GoogleMobileAds | APIهای inAppPurchase در GoogleMobileAds حذف شدند. |
از نسخه 7 به نسخه 8 مهاجرت کنید
Google Mobile Ads SDK نسخه 8.0.0 چند تغییر عمده و همچنین برخی تغییر نام ها و حذف API ها را معرفی می کند.
به روز رسانی API با فرمت تمام صفحه
با شروع نسخه 8.0.0، تبلیغات بینابینی و دارای پاداش، یک سبک عمومی تبلیغات تمام صفحه را برای ثبات بیشتر به اشتراک می گذارند. این APIهای تبلیغات تمام صفحه جدید دو تفاوت عمده با APIهای تبلیغات تمام صفحه نسخه 7 دارند:
loadروش کلاس استاتیکروش قبلی برای بارگیری/نمایش آگهی تمام صفحه به شرح زیر است:
- یک نمونه شیء تبلیغاتی ایجاد کنید و یک مرجع به آن نگه دارید.
- نماینده ای اختصاص دهید که بارگیری و نمایش تماس های برگشتی را انجام دهد.
- یک تبلیغ را بارگیری کنید.
- بررسی کنید که آیا آگهی با استفاده از
isReadyبارگیری شده است. - آگهی را نمایش دهید.
در نسخه 8، رویکرد کمی تغییر می کند. تماسهای بارگیری دیگر بخشی از یک نماینده نیستند. در عوض، آنها به عنوان یک کنترل کننده تکمیل به روش
loadمنتقل می شوند:- یک روش بار استاتیک در کلاس تبلیغات فراخوانی کنید و یک کنترل کننده تکمیل بار ارائه دهید.
- در پاسخ به تماس تکمیل بارگذاری، به آگهی بارگیری شده که برگردانده شده است اشاره کنید.
- نماینده ای اختصاص دهید که پاسخگوی تماس های نمایشی را کنترل کند.
- آگهی را نمایش دهید.
رویکرد جدید این مزایا را فراهم می کند:
- شما هرگز به تبلیغی که بارگذاری نشده است اشاره ای نخواهید داشت.
- در حین بارگذاری یک شیء تبلیغاتی مجبور نیستید آن را نگه دارید.
رویدادهای تبلیغاتی مداوم
نوع رویداد API موجود v8 API بارگذاری رویدادها GADInterstitialDelegateیاGADRewardedAdDelegateGADInterstitialAdLoadCompletionHandlerیاGADRewardedAdLoadCompletionHandlerرویدادهای ارائه GADFullScreenContentDelegateقبلاً، برای گوش دادن به رویدادهای تبلیغاتی، کلاسی را ثبت میکردید که پروتکل
GADInterstitialDelegateرا در ویژگی نماینده یک بینابینی پیادهسازی میکند، یا کلاسی را ثبت میکنید که پروتکلGADRewardedAdDelegateرا بسته به قالبی که از آن استفاده میکنید، در ویژگی نماینده آگهی پاداشدهی شده پیادهسازی میکند. همین نماینده روشهایی داشت که هم به چرخه عمر بارگذاری و هم ارائه آگهی مربوط میشد.با نسخه 8، رویدادهای بارگذاری و ارائه جداگانه هستند. اکنون میتوانید یک
GADFullScreenContentDelegateرا هر زمان که بخواهید قبل از نمایش آگهی ثبت کنید، بهجای اینکه قبل از بارگیری آگهی، یک نماینده را تعیین کنید. رویدادهای بار آگهی، که مخصوص هر قالب هستند، به یک کنترل کننده تکمیل بار منتقل می شوند که در روش بارگذاری ارسال شده است.
بینابینی
بارگذاری آگهی
قطعه کد زیر به شما نشان می دهد که چگونه یک تبلیغ بینابینی را بارگیری کنید و در صورت موفقیت یا عدم بارگیری آگهی به رویدادها گوش دهید.
v7
سویفت
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADInterstitialDelegate { var interstitial: GADInterstitial! override func viewDidLoad() { super.viewDidLoad() interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/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)") } }
هدف-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
سویفت
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 } ) } }
هدف-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
سویفت
func showInterstitial() { ... if interstitial.isReady { interstitial.present(fromRootViewController: self) } else { print("Ad wasn't ready") } }
هدف-C
- (void)showInterstitial: { ... if (self.interstitial.isReady) { [self.interstitial presentFromRootViewController:self]; } else { NSLog(@"Ad wasn't ready"); } }
v8
سویفت
func showInterstitial() { ... if let ad = interstitial { ad.present(fromRootViewController: self) } else { print("Ad wasn't ready") } }
هدف-C
- (void)showInterstitial: { ... if (self.interstitial) { [self.interstitial presentFromRootViewController:self]; } else { NSLog(@"Ad wasn't ready"); } }
رویدادهای تبلیغاتی ارائه
تکههای کد زیر به شما نشان میدهند که چگونه میتوانید با تماسهای زمانی که آگهی ارائه میشود (با موفقیت یا ناموفق) و زمانی که رد میشود، تماس بگیرید.
v7
سویفت
override func viewDidLoad() { super.viewDidLoad() interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/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.") }
هدف-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
سویفت
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.") }
هدف-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
سویفت
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.") } } } }
هدف-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) GADRewardedAd *rewardedAd; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.rewardedAd = [[GADRewardedAd alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"]; self.rewardedAd.delegate = self; GADRequest *request = [GADRequest request]; [self.rewardedAd loadRequest:request completionHandler:^(GADRequestError * _Nullable error) { if (error) { NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]); } else { NSLog(@"Rewarded ad loaded."); } }]; }
v8
سویفت
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADFullScreenContentDelegate { /// The rewarded ad. var rewardedAd: GADRewardedAd? override func viewDidLoad() { super.viewDidLoad() let request = GADRequest() GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136", request: request, completionHandler: { (ad, error) in if let error = error { print("Rewarded ad failed to load with error: \(error.localizedDescription)") return } self.rewardedAd = ad self.rewardedAd?.fullScreenContentDelegate = self } ) } }
هدف-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 API GADRewardedAd ، rewardedAd:userDidEarnReward: به عنوان بخشی از پروتکل GADRewardedAdDelegate پیاده سازی می کنید. برای نسخه 8، شما GADUserDidEarnRewardHandler را برای ارائه آگهی پیاده سازی می کنید.
v7
سویفت
func showRewardedAd() { ... if rewardedAd.isReady { rewardedAd.present(fromRootViewController: self delegate:self) } else { print("Ad wasn't ready") } } /// Tells the delegate that the user earned a reward. func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarnReward: GADAdReward) { // TODO: Reward the user. }
هدف-C
- (void)showRewardedAd: { ... if (self.rewardedAd.isReady) { [self.rewardedAd presentFromRootViewController:self delegate:self]; } else { NSLog(@"Ad wasn't ready"); } } /// Tells the delegate that the user earned a reward. - (void)rewardedAd:(GADRewardedAd *)rewardedAd userDidEarnReward:(GADAdReward *)reward { // TODO: Reward the user. }
v8
سویفت
func showRewardedAd() { ... if let ad = rewardedAd { ad.present(fromRootViewController: self, userDidEarnRewardHandler: { let reward = ad.adReward // TODO: Reward the user. } ) } else { print("Ad wasn't ready") } }
هدف-C
- (void)showRewardedAd: { ... if (self.rewardedAd) { [self.rewardedAd presentFromRootViewController:self userDidEarnRewardHandler:^ { GADAdReward *reward = self.rewardedAd.adReward; // TODO: Reward the user. }]; } else { NSLog(@"Ad wasn't ready"); } }
رویدادهای تبلیغاتی ارائه
با GADRewardedAd API شما یک GADRewardedAdDelegate به روشی که تبلیغ را ارائه می دهد، ارسال می کنید. با GADRewardedAd API، یک GADFullscreenContentDelegate به عنوان یک ویژگی روی آگهی قبل از ارائه آگهی تنظیم می کنید.
v7
سویفت
func showRewardedAd() { ... if rewardedAd.isReady { rewardedAd.present(fromRootViewController: self delegate:self) } else { print("Ad wasn't ready") } } /// Tells the delegate that the rewarded ad was presented. func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) { print("Rewarded ad presented.") } /// Tells the delegate that the rewarded ad was dismissed. func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) { print("Rewarded ad dismissed.") } /// Tells the delegate that the rewarded ad failed to present. func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) { print("Rewarded ad failed to present with error: \(error.localizedDescription).") }
هدف-C
- (void)showRewardedAd: { ... if (self.rewardedAd.isReady) { [self.rewardedAd presentFromRootViewController:self delegate:self]; } else { NSLog(@"Ad wasn't ready"); } } /// Tells the delegate that the rewarded ad was presented. - (void)rewardedAdDidPresent:(GADRewardedAd *)rewardedAd { NSLog(@"Rewarded ad presented."); } /// Tells the delegate that the rewarded ad failed to present. - (void)rewardedAd:(GADRewardedAd *)rewardedAd didFailToPresentWithError:(NSError *)error { NSLog(@"Rewarded ad failed to present with error: %@", [error localizedDescription]); } /// Tells the delegate that the rewarded ad was dismissed. - (void)rewardedAdDidDismiss:(GADRewardedAd *)rewardedAd { NSLog(@"Rewarded ad dismissed."); }
v8
سویفت
override func viewDidLoad() { super.viewDidLoad() let request = GADRequest() GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136", request: request, completionHandler: { (ad, error) in if let error = error { print(error.localizedDescription) return } self.rewardedAd = ad self.rewardedAd?.fullScreenContentDelegate = self } ) } /// Tells the delegate that the rewarded ad was presented. func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("Rewarded ad presented.") } /// Tells the delegate that the rewarded ad was dismissed. func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("Rewarded ad dismissed.") } /// Tells the delegate that the rewarded ad failed to present. func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) { print("Rewarded ad failed to present with error: \(error.localizedDescription).") }
هدف-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."); }
حذف API Legacy GADRewardedBasedVideoAd
API جدیدتر GADRewardedAd برای اولین بار در مارس 2019 معرفی شد و برای بیش از 18 ماه بهترین API پاداش دار بوده است. در مقایسه با API قدیمی GADRewardedBasedVideoAd ، پیشرفتهای بیشتری داشته است، از جمله توانایی بارگیری بیش از یک آگهی با پاداش در یک زمان.
API قدیمی GADRewardedBasedVideoAd در SDK نسخه 8.0.0 حذف شده است.
منسوخ شدن بنر هوشمند به نفع بنر تطبیقی
تبلیغات بنری هوشمند به نفع تبلیغات بنری تطبیقی منسوخ شده است. بنرهای تطبیقی عملکرد برتر و انعطاف پذیری بیشتری را در تنظیم عرض آگهی ارائه می دهند. اگر ترجیح می دهید به استفاده از بنرهای تمام عرض ادامه دهید، همچنان می توان با استفاده از بنر تطبیقی، همانطور که در قطعه کد زیر نشان داده شده است، این کار را انجام داد:
سویفت
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) } }
هدف-C
@implementation ViewController - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // Note: The safe area is not known until viewWillAppear. GADAdSize adSize = [self getFullWidthAdaptiveAdSize]; } - (GADAdSize)getFullWidthAdaptiveAdSize { CGRect frame = self.view.frame; // Here safe area is taken into account, hence the view frame is used after // the view has been laid out. if (@available(iOS 11.0, *)) { frame = UIEdgeInsetsInsetRect(self.view.frame, self.view.safeAreaInsets); } return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width); } @end
حذف پاسخ تماس برنامه را ترک کنید
پاسخ تماس willLeaveApplication برای همه قالبهای تبلیغاتی به نفع روشهای applicationDidEnterBackground: و sceneDidEnterBackground: حذف شده است. استفاده از API های سطح سیستم عامل هر زمان که کاربران برنامه شما را ترک می کنند، صرف نظر از اینکه به دلیل تعامل تبلیغاتی باشد یا نه، به شما اطلاع می دهد.
توجه داشته باشید که callback willLeaveApplication هرگز به عنوان یک کنترل کننده کلیک روی تبلیغات در نظر گرفته نشده است و تکیه بر این تماس برای گزارش کلیک ها معیار دقیقی ایجاد نمی کند. به عنوان مثال، با کلیک بر روی نماد AdChoices که یک مرورگر خارجی را راهاندازی میکند، پاسخ تماس را فراخوانی میکند اما یک کلیک حساب نمیشود.
تغییر نام کلاس ها
جدول زیر نام کلاسهای خاصی را که در نسخه 8 تغییر کرده یا حذف شدهاند فهرست میکند.
- همه کلاسهای مربوط به
GADUnifiedNativeAdبهGADNativeAdتغییر نام دادهاند. -
GADRewardBasedVideoAd،GADNativeExpressAdView، وGADInstreamAdحذف شدهاند. - همه کلاسهای دارای پیشوند
DFPبا پیشوندGAMجایگزین شدهاند.
| کلاس v7.68.0 | کلاس v8.0.0 |
|---|---|
| DFPBannerView | GAMBannerView |
| DFPBannerViewOptions | GAMBannerViewOptions |
| DFPIInterstitial | GAInterstitialAd |
| DFPRequest | GAMRequest |
| خطای GADRequest | خطای NSE |
| GADUnifiedNativeAdView | GADNativeAdView |
| GADUnifiedNativeAd | GADNativeAd |
| GADUnifiedNativeAdAssetIdentifiers | GADNativeAdAssetIdentifiers |
| GADUnifiedNativeAdDelegate | GADNativeAdDelegate |
| GADUnifiedNativeAdUnconfirmedClickDelegate | GADNativeAdUnconfirmedClickDelegate |
| GADNativeCustomTemplateAd | GADCustomNative Ad |
| GADNativeCustomTemplateAdLoaderDelegate | GADCustomNativeAdLoaderDelegate |
| GADNativeAdDelegate | GADCustomNativeAdDelegate |
| GADINAppPurchase | حذف شد |
| GADInterstitial | GADInterstitialAd |
| GADNativeExpressAdView | حذف شد |
| GADRewardBasedVideoAd | حذف شد |
| GADInstreamAd | حذف شد |
| GADInstreamAdView | حذف شد |
روشها حذف/جایگزین شدند
جدول زیر تغییرات خاص نسخه 8 را فهرست می کند. به طور خلاصه:
- روشها و ویژگیهای منسوخ شده قبلی حذف شدهاند.
-
-willLeaveApplication:روش های نمایندگی برای همه فرمت ها حذف شده است. - نام کلاس شبکه تبلیغاتی به ویژگی
GADResponseInfoمنتقل شده است. - شناسه دستگاه آزمایشی به ویژگی
GADRequestConfigurationمنتقل شده است.
| کلاس v7.68.0 | v7.68.0 API | v8.0.0 API | یادداشت ها |
|---|---|---|---|
| GADMobileAds | +configureWithApplicationID: | -startWithCompletion Handler: | شناسه برنامه اکنون در Info.plist تنظیم شده است. |
| +disableAutomatedInApp PurchaseReporting | -disableAutomatedInApp PurchaseReporting | ||
| +disableSDKCrashReporting | غیرفعال کردن SDKCrashReporting | ||
| GADRequest | دستگاه های تست | GADRequestConfiguration .testdeviceidentifiers | ویژگی testDeviceIdentifiers برای همه درخواستهای تبلیغاتی اعمال میشود، در حالی که ویژگی قدیمی testDevices برای هر درخواست تنظیم شده بود. |
| جنسیت | حذف شد | ||
| تولد | حذف شد | ||
| +sdkVersion | GADMobileAds.sharedInstance .sdkVersion | ||
| -setBirthday WithMonth:day:year: | حذف شد | ||
| -setLocationWithDescription: | -setLocationWith Latitude:longitude:accuracy: | ||
| -tagForChildDirectedTreatment: | [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment] | ||
| GADErrorCode | kGADEخطا* | خطای GADE* | پیشوند k از تمام ثابت های کد خطا حذف می شود. |
| GADBannerView | دارای Refreshed خودکار است | autoload فعال شد | |
| inAppPurchaseDelegate | حذف شد | ||
| mediatedAdView | حذف شد | ||
| adNetworkClassName | answerInfo .adNetworkClassName | ||
| DFPBannerView | -setValidAdSizesWithSizes: | -setValidAdSizes: | |
| DFPBannerViewOptions | -adSizeDelegate | حذف شد | |
| GADBannerViewDelegate | -adViewDidReceiveAd: | -bannerViewDidReceiveAd: | |
| -adView:didFailToReceive AdWithError: | -bannerView:didFailToReceive AdWithError: | ||
| -adViewWillPresentScreen: | -bannerViewWillPresentScreen: | ||
| -adViewWillDismissScreen: | -bannerViewWillDismissScreen: | ||
| -adViewDidDismissScreen: | -bannerViewDidDisissScreen: | ||
| -adViewWillLeaveApplication: | حذف شد | ||
| GADNativeCustomTemplateAd | شناسه الگو | GADCustomNativeAd.formatID | |
| -performClickOnAssetWithKey: customClickHandler: | -performClickOnAssetWithKey: | ||
| GADNativeAdImageAd LoaderOptions | preferredImageOrientation | GADNativeAdMediaAdOptions .mediaAspectRatio | |
| GADInterstitial | inAppPurchaseDelegate | حذف شد | |
| آماده است | حذف شد | به جای آن از canPresentFrom RootViewController:error: استفاده کنید. | |
| استفاده شده است | حذف شد | ||
| -init | -initWithAdUnitID: | ||
| -setAdUnitID: | -initWithAdUnitID: | ||
| adNetworkClassName | answerInfo .adNetworkClassName | ||
| -interstitialWill LeaveApplication: | حذف شد | ||
| GADUnifiedNativeAd | ویدئو کنترلر | mediaContent.videoController | |
| adNetworkClassName | answerInfo .adNetworkClassName |