نقل حِزم تطوير البرامج (SDK)

تتناول هذه الصفحة عمليات نقل البيانات للإصدارات الحالية والسابقة من "حزمة SDK لإعلانات Google على الأجهزة الجوّالة" لنظام التشغيل iOS. من المتوقّع أن يتم طرح الإصدار 12.0.0 في شباط (فبراير) 2025.

نقل البيانات من الإصدار 11 من حزمة SDK إلى الإصدار 12

الترقية إلى Xcode 16.0

تم رفع الحد الأدنى لإصدار Xcode المتوافق إلى 16.0.

إتاحة تسمية Swift

يتضمّن الإصدار 12.0.0 تغييرات لاتّباع اصطلاحات التسمية في Swift إرشادات تصميم واجهة برمجة التطبيقات. تؤثر هذه التغييرات في Swift فقط. لم يتم إجراء أي تغييرات على أسماء واجهات برمجة التطبيقات Objective-C.

تغييرات بادئة الفئة

تم إجراء التغييرات التالية على بادئات الفئات:

  • تمت إزالة البادئة GAD من جميع الأسماء بجميع أنواعها.
  • تمت إعادة تسمية البادئة GAM إلى AdManager.
  • تمت إعادة تسمية البادئة GADM إلى Mediation.

حلّ الأخطاء

إنّ أفضل طريقة لحلّ الأخطاء الناتجة عن هذه التغييرات هي إجراء تصحيح باستخدام أداة Fix-It.

حلّ تعارضات التسمية

لحلّ تعارضات التسمية، استخدِم مساحة الاسم التي تقدّمها الوحدة. على سبيل المثال، أصبح اسم الجهاز GADRequest الآن Request. في ما يلي أمثلة على مساحات الأسماء التي تشير إلى فئة Request في "حزمة SDK لإعلانات Google على الأجهزة الجوّالة":

import GoogleMobileAds
...
var request: GoogleMobileAds.Request?

قائمة تفصيلية بتغييرات Swift

تعرِض الجداول التالية التغييرات التي تم إجراؤها على واجهات برمجة تطبيقات 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
GADAudioVideoManager audioSessionApplicationManaged isAudioSessionApplicationManaged
GADBannerView autoloadEnabled isAutoloadEnabled
GADMobileAds sharedInstance shared
applicationMuted isApplicationMuted
GADMuteThisAdReason reasonDescription reason
GADNativeAd customMuteThisAdAvailable isCustomMuteThisAdAvailable
GADNativeAdCustomClickGestureOptions tapsAllowed areTapsAllowed
GADNativeAdImageAdLoaderOptions imageLoadingDisabled isImageLoadingDisabled
GADNativeMuteThisAdLoaderOptions customMuteThisAdRequested isCustomMuteThisAdRequested
GADNativeSignalRequest imageLoadingDisabled isImageLoadingDisabled
customMuteThisAdRequested isCustomMuteThisAdRequested
GADRequest neighboringContentURLStrings neighboringContentURLs
GADResponseInfo extrasDictionary extras
GADServerSideVerificationOptions customRewardString customRewardText
GADSignal signalString signal
GADSignalRequest neighboringContentURLStrings neighboringContentURLs
GADVideoController customControlsRequested areCustomControlsRequested
clickToExpandEnabled isClickToExpandEnabled
GADVideoOptions startMuted shouldStartMuted
customControlsRequested areCustomControlsRequested
clickToExpandRequested isClickToExpandRequested

الدوال

النوع الإصدار 11 الإصدار 12
GADAdSize GADPortraitInlineAdaptiveBannerAdSizeWithWidth(_:) portraitInlineAdaptiveBanner(width:)
GADLandscapeInlineAdaptiveBannerAdSizeWithWidth(_:) landscapeInlineAdaptiveBanner(width:)
GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(_:) currentOrientationInlineAdaptiveBanner(width:)
GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(_:, _:) inlineAdaptiveBanner(width:maxHeight:)
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(_:) portraitAnchoredAdaptiveBanner(width:)
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(_:) landscapeAnchoredAdaptiveBanner(width:)
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(_:) currentOrientationAnchoredAdaptiveBanner(width:)
GADAdSizeFromCGSize(_:) adSizeFor(cgSize:)
GADAdSizeFullWidthPortraitWithHeight(_:) fullWidthPortrait(height:)
GADAdSizeFullWidthLandscapeWithHeight(_:) fullWidthLandscape(height:)
GADAdSizeEqualToSize(_:, _:) isAdSizeEqualToSize(size1:size2:)
IsGADAdSizeValid(_:) isAdSizeValid(size:)
GADAdSizeIsFluid(_:) isAdSizeFluid(size:)
CGSizeFromGADAdSize(_:) cgSize(for:)
NSStringFromGADAdSize(_:) string(for:)
NSValueFromGADAdSize(_:) nsValue(for:)
GADAdSizeFromNSValue(_:) adSizeFor(nsValue:)
GADClosestValidSizeForAdSizes(_:_:) closestValidSizeForAdSizes(original:possibleAdSizes:)
GADAppEventDelegate adView(_:didReceiveAppEvent:withInfo:) adView(_:didReceiveAppEvent:with:)
interstitialAd(_:didReceiveAppEvent:withInfo:) adView(_:didReceiveAppEvent:with:)
GADAppOpenAd load(withAdResponseString:) load(with:)
load(withAdUnitID:request:completionHandler:) load(with:request:completionHandler:)
canPresent(fromRootViewController:) canPresent(from:)
present(fromRootViewController:) present(from:)
GADBannerView load(withAdResponseString:) load(with:)
GADInterstitial load(withAdResponseString:) load(with:)
load(withAdUnitID:request:completionHandler:) load(with:request:completionHandler:)
canPresent(fromRootViewController:) canPresent(from:)
present(fromRootViewController:) present(from:)
GADRewardedAd load(withAdResponseString:) load(with:)
load(withAdUnitID:request:completionHandler:) load(with:request:completionHandler:)
canPresent(fromRootViewController:) canPresent(from:)
present(fromRootViewController:userDidEarnRewardHandler:) present(from:userDidEarnRewardHandler:)
GADRewardedInterstitialAd load(withAdResponseString:) load(with:)
load(withAdUnitID:request:completionHandler:) load(with:request:completionHandler:)
canPresent(fromRootViewController:) canPresent(from:)
present(fromRootViewController:userDidEarnRewardHandler:) present(from:userDidEarnRewardHandler:)
GADVersionNumber GADGetStringFromVersionNumber(_ version: GADVersionNumber) string(for:)
الوساطة
GADMAdNetworkAdapter getBannerWith(_:) getBanner(with:)
presentInterstitial(fromRootViewController:) presentInterstitial(from:)
getNativeAd(withAdTypes:options:) getNativeAd(with:options:)
GADMediatedUnifiedNativeAd didRecordClickOnAsset(withName:view:viewController:) didRecordClickOnAsset(with:view:viewController:)
GADMediationAdapter setUpWith(_:completionHandler:) setUp(with:completionHandler:)
GADMediationAdSize present(fromRootViewController:) present(from:)
GADMediationAppOpenAd present(fromRootViewController:) present(from:)
GADMediationInterstitialAd present(fromRootViewController:) present(from:)
GADMediationRewardedAd present(fromRootViewController:) present(from:)
GAMInterstitialAd load(withAdManagerAdUnitID:request:completionHandler:) load(with:request:completionHandler:)

تغييرات في واجهة برمجة التطبيقات للتحكّم في حالة كتم صوت الفيديو

تم استبدال السمة isMuted وطريقة setMute: في GADVideoController بالسمة muted.

تغييرات على الإعلانات التكيّفية المضمّنة

لتحسين استخدام المساحة، لا تشغل الإعلانات المتكيّفة المضمّنة في البداية أيّ مساحة في الإطار. يؤدي الآن استدعاء CGSizeFromGADAdSize(_:) باستخدام حجم إعلان تكيُّفي مضمّن إلى عرض ارتفاع 0 إلى أن تعرِض حزمة تطوير البرامج (SDK) لإعلانات Google على الأجهزة الجوّالة إعلانًا.

إعلانات البحث المخصّص التي تمّت إزالتها

تتم إزالة الفئات التالية بدون استبدالها:

  • GADDynamicHeightSearchBannerView
  • GADDynamicHeightSearchRequest
  • GADSearchBannerView

تغييرات على رموز الخطأ

تم تغيير رموز الخطأ التالية:

دورات تدريبية ملاحظات
GADErrorMediationNoFill يتم الآن عرض الأخطاء على النحو التالي: GADErrorNoFill.
GADErrorReceivedInvalidResponse تم استبداله بـ GADErrorReceivedInvalidAdString.

تمت إزالة GADSimulatorID

تمت إزالة GADSimulatorID. تكون المحاكيات في وضع الاختبار تلقائيًا.

التغييرات في الاستهداف المخصّص

يستخدم الآن القاموس customTargeting في GADRequest القيمة Any بدلاً من String كنوع القيمة. يتيح لك ذلك تمرير قيم رقمية إلى واجهة برمجة التطبيقات.

تغييرات على مَعلمات "الإضافات"

نقل البيانات من الإصدار 10 إلى الإصدار 11

الحد الأدنى لهدف النشر

تم رفع الحد الأدنى لإصدار النشر إلى iOS 12.

الحد الأدنى لإصدار Xcode

تم رفع الحد الأدنى لإصدار Xcode المتوافق إلى 15.1.

توقّف عرض الإعلانات على الإصدار 12 من نظام التشغيل iOS

لا يعرض الإصدار 11.0.0 من حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" الإعلانات إلا على الأجهزة التي تعمل بالإصدار 13 من نظام التشغيل iOS والإصدارات الأحدث.

إزالة التبعية لـ GoogleAppMeasurement

في الإصدار 11.0.0، تمت إزالة الاعتماد على GoogleAppMeasurement. سيتم إيقاف هذا العنصر التابع الذي كان يشغّل مفتاح التبديل بين مقاييس سلوك المستخدِمين في AdMob في أوائل العام 2024. لمواصلة جمع مقاييس سلوك المستخدِمين في AdMob، عليك ربط تطبيقك على AdMob بمنصّة Firebase ودمج حزمة تطوير البرامج (SDK) لخدمة إحصاءات Google لبرنامج Firebase في تطبيقك.

تغييرات على عرض الإعلانات بملء الشاشة

تؤثر التغييرات التالية في أشكال الإعلانات المختلفة:

  • إعلان على شاشة فتح التطبيق
  • إعلان بيني
  • تم منح المكافأة
  • إعلان بيني يضمّ مكافأة

المَعلمة view controller في -canPresentFromRootViewController:error: و -presentFromRootViewController: هي مَعلمة nullable. في حال تم تمرير القيمة "غير محدّد"، يتم عرض الإعلان من أعلى عنصر تحكّم في العرض في التسلسل الهرمي لعناصر التحكّم في العرض.

الطرق التي تمت إزالتها

تمّت إزالة الطرق التالية.

النوع v11.0.0 الطريقة ملاحظات
GADAppOpenAd load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) استخدِم load(withAdUnitID adUnitID: String, request: GADRequest?) بدلاً من ذلك.
GADMediationBannerAdEventDelegate willBackgroundApplication() لا يمكن استبداله.
GADMediationInterstitialAdEventDelegate willBackgroundApplication() لا يمكن استبداله.
GADMediationNativeAdEventDelegate willBackgroundApplication() لا يمكن استبداله.
GADMediationRewardedAdEventDelegate didRewardUser(with reward: GADAdReward) استخدِم didRewardUser() بدلاً من ذلك.
GADMediatedUnifiedNativeAdNotificationSource mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) لا يمكن استبداله.
GADRequestConfiguration setSameAppKeyEnabled(_ enabled: Bool) استخدِم setPublisherFirstPartyIDEnabled(_ enabled: Bool) بدلاً من ذلك.
tagForUnderAge(ofConsent underAgeOfConsent: Bool) استخدِم السمة tagForUnderAgeOfConsent بدلاً من ذلك.
tag(forChildDirectedTreatment childDirectedTreatment: Bool) استخدِم السمة tagForChildDirectedTreatment بدلاً من ذلك.

المواقع التي تمت إزالتها

تتم إزالة السمات التالية.

الإصدار 11.0.0 من الفئة الموقع ملاحظات
GADMediationAdConfiguration hasUserLocation لا يمكن استبداله.
userLatitude
userLongitude
userLocationAccuracyInMeters
childDirectedTreatment استخدِم 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
GADCustomEventRequest isTesting
v10.0.0 v11.0.0
  • تم تحديد الجهاز صراحةً كجهاز اختبار في testDeviceIdentifiers.
  • تم تحديد الجهاز صراحةً كجهاز اختبار في testDeviceIdentifiers.
  • الجهاز هو جهاز محاكاة.
  • تمّ تحديد الجهاز صراحةً كجهاز اختباري في واجهة مستخدم AdMob.

نقل البيانات من الإصدار 9 إلى الإصدار 10

توقّف عرض الإعلانات على نظام التشغيل iOS 11

لا يعرض الإصدار 10.0.0 من حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" الإعلانات إلا على الأجهزة التي تعمل بالإصدار 12 من نظام التشغيل iOS والإصدارات الأحدث.

لن تؤدّي الترقية إلى الإصدار 10.0.0 من حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" إلى تعطُّل تطبيقك على أجهزة iOS 11 وiOS 10، ولكن لن يتم عرض أي إعلانات على هذه الأجهزة.

لم يعُد إنشاء التطبيقات باستخدام الرموز الثنائية متوافقًا.

أصبح الآن إيقاف ترميز البت في تطبيقاتك المتوافقة مع الأجهزة الجوّالة مطلوبًا لدمج حزمة "SDK لإعلانات Google على الأجهزة الجوّالة".

الأنواع التي تمت إزالتها

النوع ملاحظات
GADGender لا يمكن استبداله.
GADMRewardBasedVideoAdNetworkAdapterProtocol توقّفت جميع محوِّلات التوسّط لعرض الإعلانات التي تضمّن مكافآت والمدرَجة في Choose Networks عن استخدام هذه البروتوكولات لأكثر من عام. استخدِم GADMediationAdapter للتوسّط والأحداث المخصّصة.
GADMRewardBasedVideoAdNetworkConnectorProtocol

المواقع التي تمت إزالتها

تتم إزالة السمات التالية بدون استبدالها.

الإصدار 10.0.0 من الفئة الموقع
GADMediationAdRequest userBirthday
userGender
userHasLocation
userLatitude
userLongitude
userLocationAccuracyInMeters
userLocationDescription
GADCustomEventRequest userHasLocation
userLatitude
userLongitude
userLocationAccuracyInMeters
userLocationDescription

نقل البيانات من الإصدار 8 إلى الإصدار 9

توقّف عرض الإعلانات على نظام التشغيل iOS 10

الحد الأدنى لإصدار iOS المتوافق مع الإصدار 9.0.0 من حزمة SDK لإعلانات Google على الأجهزة الجوّالة هو iOS 11.

لن تؤدي الترقية إلى الإصدار 9.0.0 من حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" إلى تعطُّل تطبيقك على أجهزة iOS 10، ولكن لن يتم عرض أي إعلانات على هذه الأجهزة.

فرض عناصر التحكّم في شريط الحالة بشكل أكثر صرامة

اعتبارًا من الإصدار 9.0.0، عند عرض إعلانات بتنسيق ملء الشاشة، يجب أن يضمن تطبيقك أن تكون الإعلانات قادرة على التحكّم في عرض شريط الحالة. ستظهر لك رسالة خطأ في السجلّات في حال عدم إجراء ذلك.

استنادًا إلى التنسيق المحدّد لعناصر التحكّم في العرض في تطبيقك، قد لا تحتاج إلى إجراء أي تغييرات لضمان ذلك. فكِّر في ما إذا كنت بحاجة إلى ضبط السمة childViewControllerForStatusBarHidden في rootViewController إعلانك.

إعادة تسمية adDidPresentFullScreenContent: إلى adWillPresentFullScreenContent:

ما مِن تغيير في السلوك. يتمّ استدعاء طريقة المفوّض مباشرةً قبل أن يبدأ عرض الإعلان، لذا يعكس اسم الطريقة الجديدة وظيفتها بشكلٍ أفضل.

إزالة واجهة برمجة التطبيقات لإعداد الموقع الجغرافي في GADRequest

تم حذف - (void)setLocationWithLatitude:longitude:accuracy: من GADRequest لأنّ Google لا تستخدم بيانات الموقع الجغرافي لاستهداف الإعلانات. استخدِم واجهات برمجة التطبيقات التابعة لجهات خارجية لتقديم المعلومات إلى شبكات المواقع الإعلانية التابعة لجهات خارجية إذا كان ذلك مطلوبًا.

إيقاف واجهات الأحداث المخصّصة نهائيًا

تتيح الأحداث المخصّصة للناشرين الذين يستخدمون توسّط AdMob إضافة توسّط العرض الإعلاني بدون انقطاع لشبكة مواقع إعلانية ليست من الشبكات المتوافقة.

تم إيقاف جميع بروتوكولات الأحداث المخصّصة نهائيًا. بدلاً من ذلك، استخدِم بروتوكولَي GADMediationAdapter و GADMediationAdEventDelegate الحاليَين لتحقيق الوظائف نفسها. يساهم هذا التغيير في تحسين الوضوح ويمنحك إمكانية إنشاء أحداث مخصّصة للإعلانات التي تضم مكافآت والإعلانات التي تظهر بين لقطات الشاشة والتي لم تكن متاحة في السابق.

واجهات برمجة التطبيقات

يسرد الجدول أدناه واجهات برمجة التطبيقات الخاصة بمحوِّل التوسّط المقابلة للأحداث المخصّصة وواجهات برمجة التطبيقات التي يجب استخدامها اعتبارًا من الإصدار 9.0.0.

v8 v9
GADCustomEventBanner
GADCustomEventInterstitial
GADCustomEventNativeAd
GADMediationAdapter GADMediationBannerAd
GADMediationInterstitialAd
GADMediationInterscrollerAd
GADMediationRewardedAd
GADMediationNativeAd
delegate يتم إرجاع المفوَّض من خلال معالِج اكتمال التحميل لكل دالة تحميل من فئة GADMediationAdapter
-init -init
-requestBannerAd:parameter:label:request: -loadBannerForAdConfiguration:completionHandler:
-requestInterstitialAdWithParameter:label:request: -loadInterstitialForAdConfiguration:completionHandler:
-requestNativeAdWithParameter:request:adTypes:options:rootViewController: -loadNativeAdForAdConfiguration:completionHandler:
لا ينطبق -loadInterscrollerAdForAdConfiguration:completionHandler:
لا ينطبق -loadRewardedAdForAdConfiguration:completionHandler:
-presentFromRootViewController: -presentFromViewController:
-handlesUserClicks -handlesUserClicks
-handlesUserImpressions -handlesUserImpressions

طرق التفويض

يسرد الجدول أدناه طرق تعيين أحداث الإعلانات للتوسّط المقابلة ل methods طرق تعيين الأحداث المخصّصة التي يجب استخدامها اعتبارًا من الإصدار 9.0.0.

v8 v9
GADCustomEventBannerDelegate
GADCustomEventInterstitialDelegate
GADCustomEventNativeAdDelegate
GADMediationAdEventDelegate GADMediationAd
-customEventBanner:didReceiveAd:
-customEventInterstitialDidReceiveAd:
يتم تضمين حالة تحميل الإعلان في معالِج اكتمال التحميل ل كل دالة تحميل في فئة GADMediationAdapter
-customEventBanner:didFailAd:
-customEventInterstitial:didFailAd:
-customEventBannerWasClicked:
-customEventInterstitialWasClicked:
-reportClick
-customEventBannerWillPresentModal:
-customEventInterstitialWillPresentModal:
-willPresentFullScreenView
-customEventBannerWillDismissModal:
-customEventInterstitialWillDismissModal:
-willDismissFullScreenView
-customEventBannerDidDismissModal:
-customEventInterstitialDidDismissModal:
-didDismissFullScreenView
-customEventBannerWillLeaveApplication:
-customEventInterstitialWillLeaveApplication:
-willBackgroundApplication
viewControllerForPresentingModalView -[GADMediationBannerAd view]

الطرق والثوابت الأخرى التي تمّت إزالتها أو استبدالها

التغييرات في الطريقة أو الثابت أو السمة
kGAD- الثوابت التي تحتوي على بادئة تمّت إزالة الموضوع. استخدِم الثوابت التي تبدأ بالبادئة GAD-.
GADAdNetworkResponseInfo تمّت إزالة credentials. استخدِم adUnitMapping بدلاً من ذلك.
GADCustomNativeAd تم إيقاف mediaView في GADCustomNativeAd نهائيًا. استخدِم mediaContent بدلاً من ذلك.
واجهات برمجة التطبيقات لشراء المحتوى داخل التطبيقات في GoogleMobileAds تمت إزالتها.inAppPurchaseGoogleMobileAds

نقل البيانات من الإصدار 7 إلى الإصدار 8

يتضمّن الإصدار 8.0.0 من حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" بعض التغييرات الرئيسية، بالإضافة إلى بعض عمليات إعادة تسمية واجهات برمجة التطبيقات وإزالتها.

تحديثات واجهة برمجة التطبيقات لتنسيق ملء الشاشة

بدءًا من الإصدار 8.0.0، تتشارك الإعلانات البينية والإعلانات التي تضم مكافأة عامًا كاملاً نمط الإعلان على الشاشة لتحقيق مزيد من الاتساق. تحتوي واجهات برمجة التطبيقات الجديدة للإعلانات التي يتم عرضها بملء الشاشة على اثنين الاختلافات الرئيسية عن الإصدار 7 من واجهات برمجة التطبيقات للإعلانات بملء الشاشة:

  1. طريقة الصف الثابتة load

    في ما يلي الطريقة السابقة لتحميل/عرض إعلان بملء الشاشة:

    1. أنشئ مثيل كائن إعلان واحتفظ بإشارة إليه.
    2. عيِّن مستخدمًا يشرف على التحميل ويعرض عمليات معاودة الاتصال.
    3. حمِّل إعلانًا.
    4. تحقَّق ممّا إذا تم تحميل الإعلان باستخدام isReady.
    5. اعرض الإعلان.

    في الإصدار 8، تغيرت النهج قليلاً. لم يعد تحميل طلبات معاودة الاتصال كجزء من الشخص المفوَّض. وبدلاً من ذلك، يتم تمريرها إلى طريقة load باعتبارها معالج الإكمال:

    1. استدعاء طريقة تحميل ثابتة في فئة الإعلان وتوفير إكمال التحميل .
    2. في استدعاء إكمال التحميل، ارجع إلى الإعلان الذي تم تحميله والذي عاد.
    3. عيِّن مستخدمًا مفوّضًا لمعالجة طلبات معاودة الاتصال.
    4. اعرض الإعلان.

    يوفر الأسلوب الجديد المزايا التالية:

    • ولن يكون لديك أبدًا إشارة إلى إعلان لم يتم تحميله.
    • لن تحتاج إلى الاحتفاظ بكائن الإعلان أثناء تحميله.
  2. أحداث الإعلانات المنتظمة:

    نوع الحدث واجهة برمجة التطبيقات الحالية الإصدار 8 من واجهة برمجة التطبيقات
    تحميل الأحداث GADInterstitialDelegate أو GADRewardedAdDelegate GADInterstitialAdLoadCompletionHandler أو GADRewardedAdLoadCompletionHandler
    أحداث العروض التقديمية GADFullScreenContentDelegate

    في السابق، للاستماع إلى أي أحداث إعلانية، كنت تريد تسجيل فئة لتنفيذ GADInterstitialDelegate إلى الملكية المفوَّضة لأحد الإعلانات البينية أو تسجيل فئة لتنفيذ GADRewardedAdDelegate إلى الموقع المفوَّض للإعلان الذي يضم مكافأة بناءً على شكل الإعلان التي تستخدمها. كان لدى هذا الشخص المفوَّض نفسه طرق تتعلق بكل من التحميل دورة حياة العرض التقديمي للإعلان.

    وفي الإصدار 8، تكون أحداث التحميل والعرض التقديمي منفصلة. يمكنك الآن تسجيل GADFullScreenContentDelegate أي وقت قبل عرض إعلان بدلاً من أن يُطلب منه تحديد قبل تحميل الإعلان. أحداث عدد الإعلانات المخصّصة لكلّ منها التنسيق، انتقل إلى معالج واحد لاكتمال التحميل تم تمريره في طريقة التحميل.

إعلان بيني

تحميل الإعلان

توضِّح لك مقتطفات الرمز أدناه كيفية تحميل إعلان بيني والاستماع إلى الأحداث التي يتم عندها عرض الإعلان بنجاح أو تعذُّر تحميله.

الإصدار 7

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADInterstitialDelegate {

  var interstitial: GADInterstitial!

  override func viewDidLoad() {
    super.viewDidLoad()
    interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
    interstitial.delegate = self
    let request = GADRequest()
    interstitial.load(request)
  }

  /// Tells the delegate an ad request succeeded.
  func interstitialDidReceiveAd(_ ad: GADInterstitial) {
    print("Interstitial ad loaded.")
  }

  /// Tells the delegate an ad request failed.
  func interstitial(_ ad: GADInterstitial, didFailToReceiveAdWithError error: GADRequestError) {
    print("Interstitial ad failed to load with error: \(error.localizedDescription)")
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADInterstitial *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"];
  self.interstitial.delegate = self;
  GADRequest *request = [GADRequest request];
  [self.interstitial loadRequest:request];
}

/// Tells the delegate an ad request succeeded.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
  NSLog(@"Insterstitial ad loaded.");
}

/// Tells the delegate an ad request failed.
- (void)interstitial:(GADInterstitial *)ad
    didFailToReceiveAdWithError:(GADRequestError *)error {
  NSLog(@"Interstitial ad failed to load with error: %@", [error localizedDescription]);
}

v8

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADFullScreenContentDelegate {

  var interstitial: GADInterstitialAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    let request = GADRequest()
    GADInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738",
                                request: request,
                      completionHandler: { (ad, error) in
                        if let error = error {
                          print("Failed to load interstitial ad with error: \(error.localizedDescription)")
                          return
                        }
                        self.interstitial = ad
                        self.interstitial.fullScreenContentDelegate = self
                      }
    )
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADInterstitialAd *interstitial;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"
                              request:request
                    completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]);
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

إعلان صوري

الإصدار 7

Swift

func showInterstitial() {
  ...
  if interstitial.isReady {
    interstitial.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
}

Objective-C

- (void)showInterstitial: {
  ...
  if (self.interstitial.isReady) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

v8

Swift

func showInterstitial() {
  ...
  if let ad = interstitial {
    ad.present(fromRootViewController: self)
  } else {
    print("Ad wasn't ready")
  }
}

Objective-C

- (void)showInterstitial: {
  ...
  if (self.interstitial) {
    [self.interstitial presentFromRootViewController:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

أحداث إعلانات العرض التقديمي

توضّح لك مقتطفات الرمز أدناه كيفية التعامل مع عمليات الاستدعاء عندما يتم عرض الإعلان تقديمه (بنجاح أو غير ناجح) وعند رفضه.

الإصدار 7

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
  interstitial.delegate = self
  ...
}

/// Tells the delegate that an interstitial will be presented.
func interstitialWillPresentScreen(_ ad: GADInterstitial) {
  print("Interstitial ad will be presented.")
}

/// Tells the delegate the interstitial is to be animated off the screen.
func interstitialWillDismissScreen(_ ad: GADInterstitial) {
  print("Interstitial ad will be dismissed.")
}

/// Tells the delegate the interstitial had been animated off the screen.
func interstitialDidDismissScreen(_ ad: GADInterstitial) {
  print("Interstitial ad dismissed.")
}

/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
///
/// This is not a reliable callback for an ad click event and is removed in
/// version 8. If you wish to listen to an ad causing a user to leave the app,
/// use applicationWillResignActive: or sceneWillResignActive: instead.
func interstitialWillLeaveApplication(_ ad: GADInterstitial) {
  print("Interstitial ad will leave application.")
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:"ca-app-pub-3940256099942544/4411468910"];
  self.interstitial.delegate = self;
  ...
}

/// Tells the delegate that an interstitial will be presented.
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will be presented.");
}

/// Tells the delegate the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will be dismissed.");
}

/// Tells the delegate the interstitial had been animated off the screen.
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad dismissed.");
}

/// Tells the delegate that a user click will open another app
/// (such as the App Store), backgrounding the current app.
///
/// This is not a reliable callback for an ad click event and is removed in
/// version 8. If you wish to listen to an ad causing a user to leave the app,
/// use applicationWillResignActive: or sceneWillResignActive: instead.
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad {
  NSLog(@"Interstitial ad will leave application.");
}

v8

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738",
                              request: request,
                    completionHandler: { (ad, error) in
                      if let error = error {
                        print(error.localizedDescription)
                        return
                      }
                      self.interstitial = ad
                      self.interstitial.fullScreenContentDelegate = self
                    }
  )
}

func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did present full screen content.")
}

func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
  print("Ad failed to present full screen content with error \(error.localizedDescription).")
}

func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did dismiss full screen content.")
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  GADRequest *request = [GADRequest request];
  [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"
                              request:request
                    completionHandler:^(GADInterstitialAd *ad, NSError *error) {
    if (error) {
      NSLog(@"interstitial:didFailToReceiveAdWithError: %@", [error localizedDescription])
      return;
    }
    self.interstitial = ad;
    self.interstitial.fullScreenContentDelegate = self;
  }];
}

- (void)adDidPresentFullScreenContent:(id)ad {
  NSLog(@"Ad did present full screen content.");
}

- (void)ad:(id)ad didFailToPresentFullScreenContentWithError:(NSError *)error {
  NSLog(@"Ad failed to present full screen content with error %@.", [error localizedDescription]);
}

- (void)adDidDismissFullScreenContent:(id)ad {
  NSLog(@"Ad did dismiss full screen content.");
}

تم منح المكافأة

تحميل الإعلان

الإصدار 7

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADRewardedAdDelegate {
  /// The rewarded ad.
  var rewardedAd: GADRewardedAd?

  override func viewDidLoad() {
    super.viewDidLoad()
    rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
    rewardedAd.delegate = self
    rewardedAd?.load(GADRequest()) { error in
      if let error = error {
        print("Rewarded ad failed to load with error: \(error.localizedDescription)")
      } else {
        print("Rewarded ad loaded.")
      }
    }
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  self.rewardedAd = [[GADRewardedAd alloc]
      initWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"];
  self.rewardedAd.delegate = self;
  GADRequest *request = [GADRequest request];
  [self.rewardedAd loadRequest:request completionHandler:^(GADRequestError * _Nullable error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
    } else {
      NSLog(@"Rewarded ad loaded.");
    }
  }];
}

v8

Swift

import GoogleMobileAds
import UIKit

class ViewController: UIViewController, GADFullScreenContentDelegate {
  /// The rewarded ad.
  var rewardedAd: GADRewardedAd?

  override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136",
                          request: request, completionHandler: { (ad, error) in
                            if let error = error {
                              print("Rewarded ad failed to load with error: \(error.localizedDescription)")
                              return
                            }
                            self.rewardedAd = ad
                            self.rewardedAd?.fullScreenContentDelegate = self
                          }
  )
  }
}

Objective-C

@import GoogleMobileAds;
@import UIKit;

@interface ViewController () 

@property(nonatomic, strong) GADRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  GADRequest *request = [GADRequest request];
  [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"
                          request:request
                completionHandler:^(GADRewardedAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
      return;
    }
    self.rewardedAd = ad;
    NSLog(@"Rewarded ad loaded.");
    self.rewardedAd.fullScreenContentDelegate = self;
}

مكافأة الإعلان الصوري والاسم المعرِّف

تتطلّب الإعلانات التي تضم مكافأة معالجة الحدث عندما يحصل المستخدم على مكافأة. مع 7 من واجهة برمجة تطبيقات GADRewardedAd، فأنت تنفّذ rewardedAd:userDidEarnReward: كجزء من بروتوكول GADRewardedAdDelegate. في الإصدار 8، عليك تنفيذ GADUserDidEarnRewardHandler بهدف اعرض الإعلان.

الإصدار 7

Swift

func showRewardedAd() {
  ...
  if rewardedAd.isReady {
    rewardedAd.present(fromRootViewController: self delegate:self)
  } else {
    print("Ad wasn't ready")
  }
}

/// Tells the delegate that the user earned a reward.
func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarnReward: GADAdReward) {
  // TODO: Reward the user.
}

Objective-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd.isReady) {
    [self.rewardedAd presentFromRootViewController:self delegate:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

/// Tells the delegate that the user earned a reward.
- (void)rewardedAd:(GADRewardedAd *)rewardedAd userDidEarnReward:(GADAdReward *)reward {
  // TODO: Reward the user.
}

v8

Swift

func showRewardedAd() {
  ...
  if let ad = rewardedAd {
      ad.present(fromRootViewController: self,
               userDidEarnRewardHandler: {
                 let reward = ad.adReward
                 // TODO: Reward the user.
               }
      )
  } else {
    print("Ad wasn't ready")
  }
}

Objective-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd) {
    [self.rewardedAd presentFromRootViewController:self
                          userDidEarnRewardHandler:^ {
      GADAdReward *reward = self.rewardedAd.adReward;
      // TODO: Reward the user.
    }];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

أحداث إعلانات العرض التقديمي

باستخدام GADRewardedAd API، يمكنك ضبط GADRewardedAdDelegate في الطريقة. التي تعرض الإعلان باستخدام GADRewardedAd API، يمكنك إعداد GADFullscreenContentDelegate كخاصية في الإعلان قبل عرض الإعلان.

الإصدار 7

Swift

func showRewardedAd() {
  ...
  if rewardedAd.isReady {
    rewardedAd.present(fromRootViewController: self delegate:self)
  } else {
    print("Ad wasn't ready")
  }
}

/// Tells the delegate that the rewarded ad was presented.
func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) {
  print("Rewarded ad presented.")
}
/// Tells the delegate that the rewarded ad was dismissed.
func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) {
  print("Rewarded ad dismissed.")
}
/// Tells the delegate that the rewarded ad failed to present.
func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) {
  print("Rewarded ad failed to present with error: \(error.localizedDescription).")
}

Objective-C

- (void)showRewardedAd: {
  ...
  if (self.rewardedAd.isReady) {
    [self.rewardedAd presentFromRootViewController:self delegate:self];
  } else {
    NSLog(@"Ad wasn't ready");
  }
}

/// Tells the delegate that the rewarded ad was presented.
- (void)rewardedAdDidPresent:(GADRewardedAd *)rewardedAd {
  NSLog(@"Rewarded ad presented.");
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)rewardedAd:(GADRewardedAd *)rewardedAd didFailToPresentWithError:(NSError *)error {
  NSLog(@"Rewarded ad failed to present with error: %@",
        [error localizedDescription]);
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)rewardedAdDidDismiss:(GADRewardedAd *)rewardedAd {
  NSLog(@"Rewarded ad dismissed.");
}

v8

Swift

override func viewDidLoad() {
  super.viewDidLoad()
  let request = GADRequest()
  GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136",
                          request: request, completionHandler: { (ad, error) in
                            if let error = error {
                              print(error.localizedDescription)
                              return
                            }
                            self.rewardedAd = ad
                            self.rewardedAd?.fullScreenContentDelegate = self
                          }
  )
}

/// Tells the delegate that the rewarded ad was presented.
func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Rewarded ad presented.")
}
/// Tells the delegate that the rewarded ad was dismissed.
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Rewarded ad dismissed.")
}
/// Tells the delegate that the rewarded ad failed to present.
func ad(_ ad: GADFullScreenPresentingAd,
    didFailToPresentFullScreenContentWithError error: Error) {
  print("Rewarded ad failed to present with error: \(error.localizedDescription).")
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];

  GADRequest *request = [GADRequest request];
  [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"
                          request:request
                completionHandler:^(GADRewardedAd *ad, NSError *error) {
    if (error) {
      NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
      return;
    }
    self.rewardedAd = ad;
    NSLog(@"Rewarded ad loaded.");
    self.rewardedAd.fullScreenContentDelegate = self;
}

/// Tells the delegate that the rewarded ad was presented.
- (void)adDidPresentFullScreenContent:(id)ad {
  NSLog(@"Rewarded ad presented.");
}

/// Tells the delegate that the rewarded ad failed to present.
- (void)ad:(id)ad
    didFailToPresentFullScreenContentWithError:(NSError *)error {
  NSLog(@"Rewarded ad failed to present with error: %@",
       [error localizedDescription]);
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)adDidDismissFullScreenContent:(id)ad {
  NSLog(@"Rewarded ad dismissed.");
}

إزالة واجهة برمجة التطبيقات القديمة GAD AwardedbasedVideoAd API

الأحدث GADRewardedAd تمّ طرح واجهة برمجة التطبيقات للمرة الأولى في آذار (مارس) 2019، فكانت الأفضل من حيث عدد الإعلانات بمكافأة. واجهة برمجة التطبيقات لأكثر من 18 شهرًا. تحتوي على مزيد من التحسينات مقارنةً بالقديمة واجهة برمجة تطبيقات GADRewardedBasedVideoAd، بما في ذلك إمكانية تحميل أكثر من عنصر إعلان يضم مكافأة في كل مرة

تمت إزالة واجهة برمجة التطبيقات GADRewardedBasedVideoAd القديمة في الإصدار 8.0.0 من حزمة تطوير البرامج (SDK).

إيقاف البانر الذكي نهائيًا لصالح إعلان البانر التكيُّفي

تم إيقاف إعلانات البانر الذكية نهائيًا. لصالح بانر تكيُّفي الإعلانات. توفّر إعلانات البانر التكيُّفية أداءً فائقًا ومرونة أكبر في تعيين عرض الإعلان. إذا كنت تفضّل مواصلة استخدام إعلانات بانر ذات العرض الكامل، يمكن باستخدام إعلان بانر تكيُّفي، كما هو موضّح في مقتطف الرمز التالي:

Swift

class ViewController: UIViewController {

  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    // Note: The safe area is not known until viewWillAppear.
    let adSize = getFullWidthAdaptiveAdSize()
  }

  func getFullWidthAdaptiveAdSize() -> GADAdSize {
    // Here safe area is taken into account, hence the view frame is used after the
    // view has been laid out.
    let frame = { () -> CGRect in
      if #available(iOS 11.0, *) {
        return view.frame.inset(by: view.safeAreaInsets)
      } else {
        return view.frame
      }
    }()
    return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width)
  }
}

Objective-C

@implementation ViewController

- (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  // Note: The safe area is not known until viewWillAppear.
  GADAdSize adSize = [self getFullWidthAdaptiveAdSize];
}

- (GADAdSize)getFullWidthAdaptiveAdSize {
  CGRect frame = self.view.frame;
  // Here safe area is taken into account, hence the view frame is used after
  // the view has been laid out.
  if (@available(iOS 11.0, *)) {
    frame = UIEdgeInsetsInsetRect(self.view.frame, self.view.safeAreaInsets);
  }
  return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width);
}

@end

مغادرة إزالة معاودة الاتصال بالتطبيق

تم willLeaveApplication طلب إعادة الاتصال لجميع أشكال الإعلانات إزالتها لصالح applicationDidEnterBackground: أو sceneDidEnterBackground: الطرق. يؤدي استخدام واجهات برمجة التطبيقات على مستوى نظام التشغيل إلى تلقّي إشعارات كلما غادر المستخدمون تطبيقك، بغض النظر عن سواء كان ذلك بسبب تفاعل مع الإعلان أم لا.

يُرجى العلم أنّ willLeaveApplication طلب معاودة الاتصال لم يكن الغرض منه أبدًا معالج نقرات الإعلان، والاعتماد على رد الاتصال هذا للإبلاغ عن النقرات لم إنتاج مقياس دقيق. على سبيل المثال، يمكن النقر على "خيارات الإعلان" رمز شغّل متصفحًا خارجيًا استدعى معاودة الاتصال ولكن لم يتم احتساب نقرة.

عمليات إعادة تسمية الصف

يسرد الجدول أدناه أسماء الفئات المحدّدة التي تم تغييرها أو إزالتها في الإصدار 8. باختصار:

  • تمت إعادة تسمية جميع الصفوف ذات الصلة بـ "GADUnifiedNativeAd" إلى GADNativeAd
  • GADRewardBasedVideoAd وGADNativeExpressAdView وGADInstreamAd لديهما تمت إزالته.
  • تم استبدال جميع الصفوف التي تبدأ بالبادئة DFP بالبادئة GAM.
الإصدار 7.68.0 من فئة فئة الإصدار 8.0.0
DFPBannerView GAMBannerView
DFPBannerViewOptions GAMBannerViewOptions
DFPInterstitial GAMInterstitialAd
DFPRequest GAMRequest
GADRequestError NSError
GADUnifiedNativeAdView GADNativeAdView
شركة GADUnifiedNativeAd GADNativeAd
GADUnifiedNativeAdAssetIdentifiers GADNativeAdAssetIdentifiers
GADUnifiedNativeAdDelegate GADNativeAdDelegate
GADUnifiedNativeAdUnconfirmedClickDelegate GADNativeAdUnconfirmedClickDelegate
GADNativeCustomTemplateAd GADCustomNativeAd
GADNativeCustomTemplateAdLoaderDelegate GADCustomNativeAdLoaderDelegate
GADNativeAdDelegate GADCustomNativeAdDelegate
GADInAppPurchase تمت الإزالة
GADInterstitial GADInterstitialAd
GADNativeExpressAdView تمت الإزالة
GADRewardBasedVideoAd تمت الإزالة
GADInstreamAd تمت الإزالة
GADInstreamAdView تمت الإزالة

تمت إزالة أو استبدال الطرق.

يسرد الجدول التالي التغييرات المحددة في الإصدار 8. باختصار:

  • وتمت إزالة الطرق والخصائص المتوقّفة نهائيًا في السابق.
  • تمت إزالة طرق تفويض -willLeaveApplication: من جميع التنسيقات.
  • تم نقل اسم فئة شبكة الإعلانات إلى الموقع GADResponseInfo.
  • تم نقل معرّف الجهاز الاختباري إلى GADRequestConfiguration. الموقع.
الإصدار 7.68.0 من فئة الإصدار 7.68.0 من واجهة برمجة التطبيقات الإصدار 8.0.0 من واجهة برمجة التطبيقات ملاحظات
GADMobileAds +configureWithApplicationID: -startWithCompletionHandler: تم ضبط رقم تعريف التطبيق الآن في Info.plist.
+disableAutomatedInAppPurchaseReporting -disableAutomatedInAppPurchaseReporting
+disableSDKCrashReporting -disableSDKCrashReporting
GADRequest testDevices GADRequestConfiguration.testdeviceidentifiers تنطبق خاصية testDeviceIdentifiers على جميع طلبات الإعلانات، بينما تنطبق خاصية testDeviceIdentifiers على جميع طلبات الإعلانات. تم إعداد السمة testDevices القديمة لكل طلب.
الجنس تمت الإزالة
عيد الميلاد تمت الإزالة
+sdkVersion GADMobileAds.sharedInstance.sdkVersion
-setBirthdayWithMonth:day:year: تمت الإزالة
-setLocationWithDescription: -setLocationWithLatitude:longitude:accuracy:
-tagForChildDirectionTreatment: [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectionTreatment]
GADErrorCode kGADError* خطأ GADError* يتم إسقاط البادئة k من جميع ثوابت رموز الخطأ.
GADBannerView hasAutoRefreshed autoloadEnabled
inAppPurchaseDelegate تمت الإزالة
mediatedAdView تمت الإزالة
adNetworkClassName responseInfo.adNetworkClassName
DFPBannerView -setValidAdSizesWithSizes: -setValidAdSizes:
DFPBannerViewOptions -adSizeDelegate تمت الإزالة
GADBannerViewDelegate -adViewDidReceiveAd: -bannerViewDidReceiveAd:
-adView:didFailToReceiveAdWithError: -bannerView:didFailToReceiveAdWithError:
-adViewWillPresentScreen: -bannerViewWillPresentScreen:
-adViewWillDismissScreen: -bannerViewWillDismissScreen:
-adViewDidDismissScreen: -bannerViewDidDismissScreen:
-adViewWillLeaveApplication: تمت الإزالة
GADNativeCustomTemplateAd templateID GADCustomNativeAd.formatID
-performClickOnAssetWithKey:customClickHandler: -performClickOnAssetWithKey:
GADNativeAdImageAdLoaderOptions preferredImageOrientation GADNativeAdMediaAdOptions.mediaAspectRatio
GADInterstitial inAppPurchaseDelegate تمت الإزالة
isReady تمت الإزالة استخدِم canPresentFromRootViewController:error: بدلاً من ذلك.
hasBeenUsed تمت الإزالة
-init -initWithAdUnitID:
-setAdUnitID: -initWithAdUnitID:
adNetworkClassName responseInfo.adNetworkClassName
-interstitialWillLeaveApplication: تمت الإزالة
شركة GADUnifiedNativeAd videoController mediaContent.videoController
adNetworkClassName responseInfo.adNetworkClassName