این صفحه، مهاجرتهای نسخههای فعلی و قبلی Google Mobile Ads SDK برای iOS را پوشش میدهد. ما انتظار داریم نسخه ۱۳.۰.۰ را در فوریه ۲۰۲۶ منتشر کنیم.
حداقل هدف استقرار به iOS 13 افزایش یافته است.
نسخه ۱۳.۰.۰، APIهای اندازه بنر تطبیقی لنگری موجود را منسوخ میکند و APIهای اندازه را برای بنرهای تبلیغاتی تطبیقی لنگری بزرگ معرفی میکند. Google Mobile Ads SDK میتواند با استفاده از APIهای اندازه بنر تطبیقی لنگری بزرگ جدید، تقاضای ویدیو را برای بنرهای تبلیغاتی ارائه دهد.
جدول زیر جزئیات APIهای اندازهگیری منسوخشده و جایگزینهای آنها را نشان میدهد:
| نسخه ۱۲ (منسوخ شده) | نسخه ۱۳ (جایگزین) |
|---|---|
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) | GADLargeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) | GADLargeLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) | GADLargePortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width) |
نسخه ۱۳.۰.۰ همچنان پشتیبانی از همزمانی دقیق Swift 6 را اضافه میکند.
neighboringContentURLStrings اضافه شد. از نسخه ۱۳.۰.۰ به بعد، اگر شیءای که از نوع String نباشد در آرایه neighboringContentURLStrings شناسایی شود، Google Mobile Ads SDK یک استثنا ایجاد میکند.
حداقل نسخه پشتیبانی شده Xcode به 16.0 افزایش یافته است.
نسخه ۱۲.۰.۰ شامل تغییراتی برای پیروی از قراردادهای نامگذاری در دستورالعملهای طراحی API سوئیفت است. این تغییرات فقط سوئیفت را تحت تأثیر قرار میدهند. هیچ تغییر نامگذاری در APIهای Objective-C اعمال نشده است.
تغییرات زیر در پیشوندهای کلاس ایجاد شده است:
- پیشوند
GADدر نام همه انواع حذف شد. - پیشوند
GAMرا بهAdManagerتغییر نام داد. - پیشوند
GADMبهMediationتغییر نام داد.
بهترین راه برای حل خطاهای ناشی از این تغییرات، انجام اصلاحیهی Fix-It است.
برای حل تداخلهای نامگذاری، از فضای نامی که توسط ماژول ارائه شده است استفاده کنید. برای مثال، GADRequest اکنون Request نامگذاری شده است. مثال زیر فضای نامهایی از کلاس Request Google Mobile Ads SDK را نشان میدهد:
import GoogleMobileAds
...
var request: GoogleMobileAds.Request?
جداول زیر تغییرات ایجاد شده در API های Swift را فهرست میکنند:
| نسخه ۱۱ | نسخه ۱۲ |
|---|---|
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 |
| نوع | نسخه ۱۱ | نسخه ۱۲ |
|---|---|---|
| GADLoader | loading | isLoading |
| مدیر صوتی و تصویری GAD | audioSessionApplicationManaged | isAudioSessionApplicationManaged |
| نمای بنر GAD | autoloadEnabled | isAutoloadEnabled |
| تبلیغات موبایل GAD | sharedInstance | shared |
applicationMuted | isApplicationMuted | |
| دلیل GADMuteThisAdReason | reasonDescription | reason |
| GADNativeAd | customMuteThisAdAvailable | isCustomMuteThisAdAvailable |
| گزینههای ژست کلیک و تبلیغات سفارشی GADNative | tapsAllowed | areTapsAllowed |
| گزینههای GADNativeAdImageAdLoader | imageLoadingDisabled | isImageLoadingDisabled |
| GADNativeMuteThisAdLoaderOptions | customMuteThisAdRequested | isCustomMuteThisAdRequested |
| درخواست سیگنال بومی GAD | imageLoadingDisabled | isImageLoadingDisabled |
customMuteThisAdRequested | isCustomMuteThisAdRequested | |
| درخواست GAD | neighboringContentURLStrings | neighboringContentURLs |
| اطلاعات پاسخ GAD | extrasDictionary | extras |
| گزینههای تأیید سمت سرور GAD | customRewardString | customRewardText |
| GADSignal | signalString | signal |
| درخواست سیگنال GADSignal | neighboringContentURLStrings | neighboringContentURLs |
| کنترلکنندهی ویدئوی GAD | customControlsRequested | areCustomControlsRequested |
clickToExpandEnabled | isClickToExpandEnabled | |
| گزینههای GADVideo | startMuted | shouldStartMuted |
customControlsRequested | areCustomControlsRequested | |
clickToExpandRequested | isClickToExpandRequested |
| نوع | نسخه ۱۱ | نسخه ۱۲ |
|---|---|---|
| اندازه GAD | 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:) | |
| نماینده رویداد GADApp | 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:) | |
| نمای بنر GAD | load(withAdResponseString:) | load(with:) |
| GADبینابینی | 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:) | |
| شماره نسخه GAD | GADGetStringFromVersionNumber(_ version: GADVersionNumber) | string(for:) |
| میانجیگری | ||
| آداپتور شبکه GADMAd | getBannerWith(_:) | getBanner(with:) |
presentInterstitial(fromRootViewController:) | presentInterstitial(from:) | |
getNativeAd(withAdTypes:options:) | getNativeAd(with:options:) | |
| GADMediatedUnifiedNativeAd | didRecordClickOnAsset(withName:view:viewController:) | didRecordClickOnAsset(with:view:viewController:) |
| آداپتور GADMedia | setUpWith(_:completionHandler:) | setUp(with:completionHandler:) |
| GADMediationAdSize | present(fromRootViewController:) | present(from:) |
| GADMediationAppOpenAd | present(fromRootViewController:) | present(from:) |
| GADmediationتبلیغات بینابینی | present(fromRootViewController:) | present(from:) |
| GADmediationRewardedAd | present(fromRootViewController:) | present(from:) |
| GAMInterstitialAd | load(withAdManagerAdUnitID:request:completionHandler:) | load(with:request:completionHandler:) |
ویژگی isMuted و متد setMute: در GADVideoController با یک ویژگی muted جایگزین شدهاند.
برای بهینهسازی استفاده از فضا، تبلیغات تطبیقی درونخطی در ابتدا هیچ فضایی را در قاب اشغال نمیکنند. فراخوانی CGSizeFromGADAdSize(_:) با اندازه تبلیغ تطبیقی درونخطی، اکنون ارتفاع 0 را برمیگرداند تا زمانی که SDK تبلیغات موبایلی گوگل، تبلیغ را برگرداند.
کلاسهای زیر بدون جایگزینی حذف میشوند:
-
GADDynamicHeightSearchBannerView -
GADDynamicHeightSearchRequest -
GADSearchBannerView
کدهای خطای زیر تغییر یافتهاند:
| کلاس | یادداشتها |
|---|---|
GADErrorMediationNoFill | خطاها اکنون به صورت GADErrorNoFill برمیگردند. |
GADErrorReceivedInvalidResponse | با GADErrorReceivedInvalidAdString جایگزین شده است. |
GADSimulatorID حذف شد. شبیهسازها بهطور پیشفرض در حالت آزمایشی هستند.
دیکشنری customTargeting در GADRequest اکنون به جای String از Any به عنوان نوع مقدار استفاده میکند. این به شما امکان میدهد مقادیر عددی را به API ارسال کنید.
- ارسال کلید
max_ad_content_ratingبهadditionalParametersدیگر پشتیبانی نمیشود. برای تنظیم حداکثر امتیاز محتوای تبلیغ، به فیلتر کردن محتوای تبلیغ مراجعه کنید.
حداقل هدف استقرار به iOS 12 افزایش یافته است.
حداقل نسخه Xcode پشتیبانی شده به 15.1 افزایش یافته است.
نسخه ۱۱.۰.۰ Google Mobile Ads SDK تبلیغات را فقط در دستگاههایی که iOS 13 و بالاتر دارند، نمایش میدهد.
در نسخه ۱۱.۰.۰، وابستگی به GoogleAppMeasurement حذف شده است. این وابستگی که باعث فعال شدن گزینه معیارهای کاربر در AdMob میشد، در اوایل سال ۲۰۲۴ متوقف خواهد شد. برای ادامه جمعآوری معیارهای کاربر در AdMob، برنامه AdMob خود را به Firebase متصل کنید و Google Analytics for Firebase SDK را در برنامه خود ادغام کنید.
تغییرات زیر بر قالبهای مختلف تبلیغات تأثیر میگذارند:
- برنامه باز است
- بینابینی
- پاداش داده شده
- تبلیغات بینابینی پاداشدار
پارامتر view controller در -canPresentFromRootViewController:error: و -presentFromRootViewController: قابل تهی شدن است. اگر nil ارسال شود، تبلیغ از بالاترین view controller در سلسله مراتب view controller نمایش داده میشود.
روشهای زیر حذف میشوند.
| نوع نسخه ۱۱.۰.۰ | روش | یادداشتها |
|---|---|---|
| GADAppOpenAd | load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) | به جای آن load(withAdUnitID adUnitID: String, request: GADRequest?) استفاده کنید. |
| GADMediationBannerAdEvent Delegate | willBackgroundApplication() | بدون جایگزینی. |
| واسطهگری GADمیانجیگری تبلیغات رویدادنماینده | willBackgroundApplication() | بدون جایگزینی. |
| نماینده رویداد تبلیغات بومی GAD | willBackgroundApplication() | بدون جایگزینی. |
| نماینده رویداد پاداش داده شده (GADMediationRewardedAdEventDelegate) | didRewardUser(with reward: GADAdReward) | به جای آن didRewardUser() استفاده کنید. |
| منبع اعلان تبلیغات بومی یکپارچه GADMediatedUnified | mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) | بدون جایگزینی. |
| پیکربندی GADRequest | setSameAppKeyEnabled(_ enabled: Bool) | به جای آن از setPublisherFirstPartyIDEnabled(_ enabled: Bool) استفاده کنید. |
tagForUnderAge(ofConsent underAgeOfConsent: Bool) | به جای آن از ویژگی tagForUnderAgeOfConsent استفاده کنید. | |
tag(forChildDirectedTreatment childDirectedTreatment: Bool) | به جای آن از ویژگی tagForChildDirectedTreatment استفاده کنید. |
ویژگیهای زیر حذف میشوند.
| کلاس v11.0.0 | ملک | یادداشتها |
|---|---|---|
| پیکربندی GADMediationAd | موقعیت مکانی hasUser | بدون جایگزینی. |
| کاربرLatitude | ||
| طول جغرافیایی کاربر | ||
| کاربر موقعیت مکانی دقت در مترها | ||
| درمان کودک محور | به جای آن از GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment استفاده کنید. | |
| اطلاعات پاسخ GAD | نام کلاس شبکه ad | به جای آن از adNetworkClassName از loadedAdNetworkResponseInfo استفاده کنید. |
GADAdFormatUnknown بدون جایگزینی حذف شد.
نسخه ۱۱.۰.۰، sdkVersion را حذف میکند. برای ثبت نسخه Google Mobile Ads SDK ، به جای آن versionNumber استفاده کنید.
GADMobileAds.sharedInstance().sdkVersion
GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)
از نسخه ۱۱.۰.۰ به بعد، اگر delegate GADAdLoader با پروتکل نماینده انواع تبلیغات درخواستی مطابقت نداشته باشد، درخواست تبلیغ ارسال نمیکند. پیش از این، پس از ارسال درخواست تبلیغ، با شکست مواجه میشد.
جدولی را ببینید که شرایط بهروز شده برای زمانی که ویژگیهای زیر true برمیگردانند را نشان میدهد.
| کلاس | ملک |
|---|---|
| پیکربندی GADMediationAd | isTestRequest |
| درخواست رویداد سفارشی GAD | isTesting |
| نسخه ۱۰.۰.۰ | نسخه ۱۱.۰.۰ |
|
|
نسخه ۱۰.۰.۰ Google Mobile Ads SDK تبلیغات را فقط در دستگاههایی که iOS 12 و بالاتر دارند، نمایش میدهد.
ارتقا به نسخه ۱۰.۰.۰ کیت توسعه Google Mobile Ads SDK برنامه شما را در دستگاههای iOS 11 و iOS 10 دچار مشکل نمیکند، با این حال، هیچ تبلیغی در آن دستگاهها نمایش داده نخواهد شد.
اکنون غیرفعال کردن بیتکد در برنامههای تلفن همراه شما برای ادغام Google Mobile Ads SDK الزامی است.
| نوع | یادداشتها |
|---|---|
| جنسیت GAD | بدون جایگزینی. |
| پروتکل آداپتور شبکه تبلیغات ویدیویی مبتنی بر پاداش GADM | تمام آداپتورهای میانجیگری پاداشدار که در Choose Networks فهرست شدهاند، بیش از یک سال است که استفاده از این پروتکلها را متوقف کردهاند. برای میانجیگری و رویدادهای سفارشی از GADMediationAdapter استفاده کنید. |
| پروتکل اتصالدهنده شبکه تبلیغات ویدیویی مبتنی بر پاداش GADM |
ویژگیهای زیر بدون جایگزینی حذف میشوند.
| کلاس v10.0.0 | ملک |
|---|---|
| درخواست میانجیگری GAD | کاربرتاریخ تولد |
| کاربرجنسیت | |
| کاربر موقعیت مکانی دارد | |
| کاربرLatitude | |
| طول جغرافیایی کاربر | |
| کاربر موقعیت مکانی دقت در مترها | |
| کاربرموقعیتتوضیحات | |
| درخواست رویداد سفارشی GAD | کاربر موقعیت مکانی دارد |
| کاربرLatitude | |
| طول جغرافیایی کاربر | |
| کاربر موقعیت مکانی دقت در مترها | |
| کاربرموقعیتتوضیحات |
حداقل نسخه iOS Google Mobile Ads SDK نسخه ۹.۰.۰ از آن پشتیبانی میکند، iOS 11 است.
ارتقا به نسخه ۹.۰.۰ کیت توسعه Google Mobile Ads SDK برنامه شما را در دستگاههای iOS 10 دچار مشکل نمیکند، با این حال، هیچ تبلیغی در آن دستگاهها نمایش داده نخواهد شد.
از نسخه ۹.۰.۰ به بعد، وقتی تبلیغات تمام صفحه نمایش داده میشوند، برنامه شما باید مطمئن شود که تبلیغات میتوانند نمایش نوار وضعیت را کنترل کنند. در صورت عدم انجام این کار، پیام خطایی در گزارشها مشاهده خواهید کرد.
بسته به طرحبندی خاص view controllerها در برنامه شما، ممکن است نیازی به ایجاد هیچ تغییری برای اطمینان از این موضوع نداشته باشید. در نظر بگیرید که آیا نیاز به تنظیم ویژگی childViewControllerForStatusBarHidden در rootViewController مربوط به تبلیغ خود دارید یا خیر.
هیچ تغییر رفتاری ایجاد نشده است. متد delegate درست قبل از نمایش تبلیغ فراخوانی میشود، بنابراین نام جدید متد، عملکرد آن را بهتر نشان میدهد.
- (void)setLocationWithLatitude:longitude:accuracy: از GADRequest حذف شده است زیرا دادههای موقعیت مکانی توسط گوگل برای هدفگیری تبلیغات استفاده نمیشود. در صورت لزوم، از APIهای شخص ثالث برای ارائه اطلاعات به شبکههای تبلیغاتی شخص ثالث استفاده کنید.
رویدادهای سفارشی به ناشرانی که از AdMob Mediation استفاده میکنند، این امکان را میدهد که برای شبکه تبلیغاتی که جزو شبکههای تبلیغاتی پشتیبانیشده نیست، میانجیگری آبشاری اضافه کنند.
تمام پروتکلهای رویداد سفارشی منسوخ شدهاند. در عوض، از پروتکلهای موجود GADMediationAdapter و GADMediationAdEventDelegate برای دستیابی به همان عملکردها استفاده کنید. این تغییر وضوح را بهبود میبخشد و شما را قادر میسازد رویدادهای سفارشی برای تبلیغات جایزهدار و تبلیغات بین اسکرولی ایجاد کنید که قبلاً در دسترس نبودند.
جدول زیر APIهای آداپتور میانجیگری مربوط به APIهای رویدادهای سفارشی را که باید از نسخه 9.0.0 به بعد استفاده شوند، فهرست میکند.
| نسخه ۸ | نسخه ۹ | |
|---|---|---|
| بنر رویداد سفارشی GAD GADCustomEventبینابینی GADCustomEventNativeAd | آداپتور GADMedia | بنر تبلیغاتی GADMediation GADmediationتبلیغات بینابینی 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: | |
| ناموجود | -loadInterscrollerAdFor AdConfiguration: completionHandler: | |
| ناموجود | -loadRewardedAdFor AdConfiguration: completionHandler: | |
-presentFromRootViewController: | -presentFromViewController: | |
-handlesUserClicks | -handlesUserClicks | |
-handlesUserImpressions | -handlesUserImpressions | |
جدول زیر روشهای مربوط به نماینده رویداد تبلیغات میانجیگری و روشهای نماینده رویداد سفارشی را که باید از نسخه ۹.۰.۰ به بعد استفاده شوند، فهرست میکند.
| نسخه ۸ | نسخه ۹ | |
|---|---|---|
| نماینده بنر رویداد GADCustomEventBannerDelegate نماینده بینابینی GADCustomEvent GADCustomEventNativeAdDelegate | نماینده رویداد GADMediationAdEvent | 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 | رابطهای inAppPurchase در GoogleMobileAds حذف شدند. |
نسخه ۸.۰.۰ Google Mobile Ads SDK چند تغییر عمده و همچنین برخی تغییر نامها و حذف APIها را معرفی میکند.
از نسخه ۸.۰.۰ به بعد، تبلیغات بینابینی و جایزهدار برای هماهنگی بیشتر، از یک سبک تبلیغاتی تمامصفحه عمومی استفاده میکنند. این APIهای تبلیغاتی تمامصفحه جدید، دو تفاوت عمده با APIهای تبلیغاتی تمامصفحه نسخه ۷ دارند:
loadمتد کلاس استاتیک.رویکرد قبلی برای بارگذاری/نمایش یک تبلیغ تمام صفحه به شرح زیر است:
- یک نمونه شیء تبلیغ ایجاد کنید و یک ارجاع به آن داشته باشید.
- یک نماینده (delegate) اختصاص دهید که بارگذاری و نمایش فراخوانیهای برگشتی (callbacks) را مدیریت کند.
- یک تبلیغ بارگذاری کنید.
- با استفاده از
isReadyبررسی کنید که آیا تبلیغ بارگذاری شده است یا خیر. - تبلیغ را نشان دهید.
در نسخه ۸، این رویکرد کمی تغییر کرده است. فراخوانیهای Load دیگر بخشی از یک delegate نیستند. در عوض، آنها به عنوان یک completion handler به متد
loadارسال میشوند:- یک متد بارگذاری استاتیک را روی کلاس ad فراخوانی کنید و یک کنترلکنندهی تکمیل بارگذاری ارائه دهید.
- در فراخوانی تکمیل بارگذاری، به تبلیغ بارگذاری شدهای که برگردانده شده است، ارجاع دهید.
- یک نماینده (delegate) اختصاص دهید که فراخوانیهای بازگشتی show را مدیریت کند.
- تبلیغ را نشان دهید.
رویکرد جدید این مزایا را ارائه میدهد:
- شما هرگز به تبلیغی که بارگذاری نشده باشد، ارجاع نخواهید داد.
- لازم نیست هنگام بارگذاری یک شیء تبلیغاتی، آن را نگه دارید.
رویدادهای تبلیغاتی مداوم.
نوع رویداد API موجود رابط برنامهنویسی کاربردی نسخه ۸ بارگذاری رویدادها GADInterstitialDelegateیاGADRewardedAdDelegateGADInterstitialAdLoadCompletionHandlerیاGADRewardedAdLoadCompletionHandlerرویدادهای ارائه GADFullScreenContentDelegateپیش از این، برای گوش دادن به هرگونه رویداد تبلیغاتی، شما یک کلاس که پروتکل
GADInterstitialDelegateرا در ویژگی delegate یک تبلیغ بینابینی پیادهسازی میکرد، یا یک کلاس که پروتکلGADRewardedAdDelegateرا در ویژگی delegate یک تبلیغ پاداشی پیادهسازی میکرد، بسته به اینکه از چه فرمتی استفاده میکنید، ثبت میکردید. همین delegate متدهایی مربوط به چرخه حیات بارگذاری و ارائه یک تبلیغ داشت.در نسخه ۸، رویدادهای بارگذاری و ارائه از هم جدا هستند. اکنون میتوانید هر زمان قبل از نمایش یک تبلیغ، یک
GADFullScreenContentDelegateثبت کنید، به جای اینکه لازم باشد قبل از بارگذاری تبلیغ، یک delegate واحد تنظیم کنید. رویدادهای بارگذاری تبلیغ، که مختص هر قالب هستند، به یک کنترلکننده تکمیل بارگذاری واحد که در متد load ارسال میشود، منتقل میشوند.
قطعه کدهای زیر به شما نشان میدهند که چگونه یک تبلیغ بینابینی را بارگذاری کنید و به رویدادهایی که هنگام بارگذاری موفق یا ناموفق تبلیغ رخ میدهند، گوش دهید.
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)") } }
@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]); }
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 } ) } }
@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; }]; }
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"); } }
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"); } }
قطعه کدهای زیر به شما نشان میدهند که چگونه فراخوانیهای برگشتی را در زمان نمایش تبلیغ (موفق یا ناموفق) و زمان رد شدن آن مدیریت کنید.
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.") }
- (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."); }
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.") }
- (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."); }
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.") } } } }
@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."); } }]; }
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 } ) } }
@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; }
تبلیغات پاداشی شما را ملزم میکنند که رویدادی را که کاربر پاداشی کسب میکند، مدیریت کنید. در نسخه ۷ از API مربوط به GADRewardedAd ، شما rewardedAd:userDidEarnReward: به عنوان بخشی از پروتکل GADRewardedAdDelegate پیادهسازی میکنید. برای نسخه ۸، شما GADUserDidEarnRewardHandler را برای نمایش تبلیغ پیادهسازی میکنید.
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. }
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"); } }
با API GADRewardedAd شما یک GADRewardedAdDelegate به متدی که تبلیغ را نمایش میدهد، ارسال میکنید. با API GADRewardedAd ، شما یک GADFullscreenContentDelegate به عنوان یک ویژگی روی تبلیغ، قبل از نمایش آن، تنظیم میکنید.
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."); }
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).") }
- (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."); }
رابط برنامهنویسی کاربردی جدیدتر GADRewardedAd اولین بار در مارس ۲۰۱۹ معرفی شد و بیش از ۱۸ ماه است که رابط برنامهنویسی کاربردی پاداشدار ترجیحی بوده است. این رابط در مقایسه با رابط برنامهنویسی کاربردی قدیمی GADRewardedBasedVideoAd پیشرفتهای بیشتری داشته است، از جمله قابلیت بارگذاری بیش از یک تبلیغ پاداشدار در یک زمان.
API قدیمی GADRewardedBasedVideoAd در SDK نسخه ۸.۰.۰ حذف شده است.
بنرهای هوشمند به نفع بنرهای تطبیقی منسوخ شدهاند. بنرهای تطبیقی عملکرد برتر و انعطافپذیری بیشتری در تنظیم عرض تبلیغ ارائه میدهند. اگر ترجیح میدهید به استفاده از بنرهای تمام عرض ادامه دهید، همچنان میتوانید این کار را با استفاده از بنر تطبیقی انجام دهید، همانطور که در قطعه کد زیر نشان داده شده است:
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: جایگزین آن شدهاند. با استفاده از APIهای سطح سیستم عامل، هر زمان که کاربران برنامه شما را ترک کنند، صرف نظر از اینکه آیا این ترک به دلیل تعامل تبلیغاتی بوده یا خیر، به شما اطلاع داده میشود.
توجه داشته باشید که فراخوانی willLeaveApplication هرگز قرار نبود یک کنترلکننده کلیک روی تبلیغات باشد و تکیه بر این فراخوانی برای گزارش کلیکها، معیار دقیقی ایجاد نمیکرد. برای مثال، کلیک روی آیکون AdChoices که یک مرورگر خارجی را اجرا میکرد، فراخوانی را فراخوانی میکرد اما یک کلیک را شمارش نمیکرد.
جدول زیر نام کلاسهای خاصی را که در نسخه ۸ تغییر یافته یا حذف شدهاند، فهرست میکند. به طور خلاصه:
- تمام کلاسهای مربوط به
GADUnifiedNativeAdبهGADNativeAdتغییر نام دادهاند. -
GADRewardBasedVideoAd،GADNativeExpressAdViewوGADInstreamAdحذف شدهاند. - تمام کلاسهای دارای پیشوند
DFPبا پیشوندGAMجایگزین شدهاند.
| کلاس v7.68.0 | کلاس v8.0.0 |
|---|---|
| نمای بنر DFP | نمای بنر گام |
| گزینههای نمایش بنر DFP | گزینههای نمایش بنر گام |
| DFPبینابینی | GAMInterstitialAd |
| درخواست DFP | درخواست GAM |
| خطای درخواست GAD | NSError |
| GADUnifiedNativeAdView | GADNativeAdView |
| GADUnifiedNativeAd | GADNativeAd |
| شناسههای دارایی تبلیغات بومی GADUnified | شناسههای دارایی تبلیغات بومی GAD |
| نماینده تبلیغات بومی GADUnified | نماینده تبلیغات GADNative |
| GADUnifiedNativeAdUnconfirmedClickDelegate | GADNativeAdUnconfirmedClickDelegate |
| قالب سفارشی GADNativeAd | GADCustomNativeAd |
| GADNativeCustomTemplateAdLoaderDelegate | نماینده GADCustomNativeAdLoaderDelegate |
| نماینده تبلیغات GADNative | نماینده تبلیغات بومی GAD |
| خرید GADInApp | حذف شد |
| GADبینابینی | GADبینابینی |
| GADNativeExpressAdView | حذف شد |
| تبلیغات ویدیویی مبتنی بر پاداش GAD | حذف شد |
| GADInstreamAd | حذف شد |
| GADInstreamAdView | حذف شد |
جدول زیر تغییرات خاص در نسخه ۸ را فهرست میکند. به طور خلاصه:
- متدها و ویژگیهایی که قبلاً منسوخ شده بودند، حذف شدهاند.
-
-willLeaveApplication:متدهای نماینده برای همه قالبها حذف شدهاند. - نام کلاس شبکه تبلیغاتی به ویژگی
GADResponseInfoمنتقل شده است. - شناسه دستگاه آزمایشی به ویژگی
GADRequestConfigurationمنتقل شده است.
| کلاس v7.68.0 | نسخه ۷.۶۸.۰ رابط برنامهنویسی کاربردی | نسخه ۸.۰.۰ رابط برنامهنویسی کاربردی | یادداشتها |
|---|---|---|---|
| تبلیغات موبایل GAD | +configureWithApplicationID: | -startWithCompletionHandler: | شناسه برنامه اکنون در Info.plist تنظیم شده است. |
| +غیرفعال کردن گزارش خرید خودکار درونبرنامهای | -disableAutomatedInApp PurchaseReporting | ||
| +غیرفعال کردن گزارش خرابی SDK | -disableSDKCrashReporting | ||
| درخواست GAD | دستگاههای تست | شناسههای دستگاه تست GADRequestConfiguration | ویژگی testDeviceIdentifiers برای همه درخواستهای تبلیغ اعمال میشود، در حالی که ویژگی قدیمی testDevices برای هر درخواست تنظیم میشد. |
| جنسیت | حذف شد | ||
| تولد | حذف شد | ||
| +نسخه sdk | GADMobileAds.sharedInstance.sdkVersion | ||
| -تنظیم تاریخ تولد با ماه:روز:سال: | حذف شد | ||
| -تنظیم موقعیت مکانی با توضیحات: | -تنظیم موقعیت مکانی با عرض جغرافیایی:طول جغرافیایی:دقت: | ||
| -tagForChildDirectedTreatment: | [برچسب پیکربندی GADMobileAds.sharedInstance.requestForChildDirectedTreatment] | ||
| کد خطای GAD | خطای kGAD* | خطای GAD* | پیشوند k از تمام ثابتهای کد خطا حذف میشود. |
| نمای بنر GAD | دارای بهروزرسانی خودکار است | بارگذاری خودکارفعال | |
| نماینده خرید درونبرنامهای | حذف شد | ||
| واسطه AdView | حذف شد | ||
| نام کلاس شبکه ad | اطلاعات پاسخ.adNetworkClassName | ||
| نمای بنر DFP | -setValidAdSizesWithSizes: | -setValidAdSizes: | |
| گزینههای نمایش بنر DFP | -adSizeDelegate | حذف شد | |
| نماینده GADBannerView | -adViewDidReceiveAd: | بنرنمایشدریافتتبلیغات | |
| -adView:didFailToReceive خطای AdWithError: | -bannerView:didFailToReceiveAdWithError: | ||
| -adViewWillPresentScreen: | -bannerViewWillPresentScreen: | ||
| -adViewWillDismissScreen: | -bannerViewWillDismissScreen: | ||
| -adViewDidDismissScreen: | -bannerViewDidDismissScreen: | ||
| -adViewWillLeaveApplication: | حذف شد | ||
| قالب سفارشی GADNativeAd | شناسه الگو | شناسه قالب آگهی سفارشی بومی GAD | |
| -performClickOnAssetWithKey: customClickHandler: | -performClickOnAssetWithKey: | ||
| گزینههای بارگذاری تصویر و تبلیغات GADNativeAd | جهتگیری تصویر ترجیحی | GADNativeAdMediaAdOptions .mediaAspectRatio | |
| GADبینابینی | نماینده خرید درونبرنامهای | حذف شد | |
| آماده است | حذف شد | به جای آن از canPresentFrom RootViewController:error: استفاده کنید. | |
| استفاده شده است | حذف شد | ||
| -آغازین | -initWithAdUnitID: | ||
| -تنظیمAdUnitID: | -initWithAdUnitID: | ||
| نام کلاس شبکه ad | اطلاعات پاسخ.adNetworkClassName | ||
| -interstitialWill LeaveApplication: | حذف شد | ||
| GADUnifiedNativeAd | کنترلکننده ویدیو | کنترلکنندهی محتوای رسانهای.ویدئویی | |
| نام کلاس شبکه ad | اطلاعات پاسخ.adNetworkClassName |