تتناول هذه الصفحة عمليات نقل البيانات للإصدارات الحالية والسابقة.
نقل البيانات من الإصدار 10 إلى الإصدار 11
الحد الأدنى لهدف النشر
تمت زيادة الحد الأدنى لهدف النشر إلى الإصدار 12 من نظام التشغيل iOS.
الحد الأدنى لإصدار Xcode
تمت زيادة الحد الأدنى لإصدار Xcode المتوافق إلى 15.1.
توقُّف عرض الإعلانات على الإصدار 12 من نظام التشغيل iOS
إنّ الإصدار 11.0.0 من حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" يعرض الإعلانات فقط على الأجهزة التي تعمل بالإصدار 13 من نظام التشغيل iOS أو الإصدارات الأحدث.
تمت إزالة تبعية GoogleAppMeasurement.
في الإصدار 11.0.0، تمت إزالة الاعتماد على GoogleAppMeasurement
. في أوائل عام 2024، سيتم
إيقاف هذه الاعتمادية التي أدت إلى تفعيل ميزة تبديل مقاييس سلوك المستخدمين في AdMob. لمواصلة جمع مقاييس سلوك المستخدِمين في AdMob، عليك ربط تطبيقك على AdMob بمنصّة Firebase ودمج حزمة تطوير البرامج (SDK) لإحصاءات Google لبرنامج Firebase في تطبيقك.
التغييرات على عرض الإعلان بملء الشاشة
ستؤثّر التغييرات التالية في أشكال الإعلانات المختلفة:
- إعلان على شاشة فتح التطبيق
- إعلان بيني
- تم منح المكافأة
- الإعلان البيني بمكافأة
معلَمة وحدة التحكّم في طريقة العرض في -canPresentFromRootViewController:error:
و-presentFromRootViewController:
قيمة فارغة. إذا تم تمرير صفر، يتم عرض الإعلان من أعلى وحدة تحكم في العرض في التسلسل الهرمي لوحدة التحكم في طرق العرض.
تمّت إزالة الطرق
تمت إزالة الطرق التالية.
النوع v11.0.0 | الطريقة | Notes |
---|---|---|
إعلان GADAppOpenAd | load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) |
يمكنك استخدام load(withAdUnitID adUnitID: String, request: GADRequest?) بدلاً منها. |
GADMediationBannerAdEventDelegate | willBackgroundApplication() |
لا يوجد بديل. |
GADMediationInterstitialAdEventDelegate | willBackgroundApplication() |
لا يوجد بديل. |
GADMediationNativeAdEventDelegate | willBackgroundApplication() |
لا يوجد بديل. |
GADMediationRewardedAdEventDelegate | didRewardUser(with reward: GADAdReward) |
يمكنك استخدام didRewardUser() بدلاً منها. |
GADMediatedUnifiedNativeAdNotificationSource | mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) |
لا يوجد بديل. |
GADRequestConfiguration | setSameAppKeyEnabled(_ enabled: Bool) |
يمكنك استخدام setPublisherFirstPartyIDEnabled(_ enabled: Bool) كبديل. |
tagForUnderAge(ofConsent underAgeOfConsent: Bool) |
استخدِم السمة tagForUnderAgeOfConsent بدلاً من ذلك. |
|
tag(forChildDirectedTreatment childDirectedTreatment: Bool) |
استخدِم السمة tagForChildDirectedTreatment بدلاً من ذلك. |
تمت إزالة المواقع.
تمت إزالة السمات التالية.
فئة v11.0.0 | الموقع | Notes |
---|---|---|
GADMediationAdConfiguration | hasUserLocation | لا يوجد بديل. |
userLatitude | ||
userLongitude | ||
userLocationAccuracyInMeters | ||
childDirectedTreatment | يمكنك استخدام GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment بدلاً منها. |
|
GADResponseInfo | adNetworkClassName | يمكنك استخدام adNetworkClassName من loadedAdNetworkResponseInfo بدلاً من ذلك. |
تمت إزالة GADAdFormat غير معروف
تمت إزالة "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 |
|
|
نقل البيانات من الإصدار 9 إلى الإصدار 10
توقّف عرض الإعلانات على نظام التشغيل iOS 11
يعرض الإصدار 10.0.0 من حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" الإعلانات فقط على الأجهزة التي تعمل بنظام التشغيل iOS 12 والإصدارات الأحدث.
لن تؤدي الترقية إلى الإصدار 10.0.0 من حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" إلى تعطُّل تطبيقك على الأجهزة التي تعمل بنظامَي التشغيل iOS 11 وiOS 10، ومع ذلك، لن يتمّ عرض أيّ إعلانات على تلك الأجهزة.
متطلبات رقم تعريف تطبيق "مدير الإعلانات"
رقم تعريف تطبيق "مدير الإعلانات" مطلوب الآن في Info.plist
لجميع تطبيقات "مدير الإعلانات" ويتطلب التنسيق ca-app-pub-################~##########
. يمكنك مراجعة تعديل Info.plist
للحصول على مزيد من التفاصيل.
متطلبات GoogleAppMeasurement.xcframework
أصبح GoogleAppMeasurement.xcframework مطلوبًا الآن لجميع تطبيقات "مدير الإعلانات". في حال تثبيت حزمة "SDK لإعلانات Google على الأجهزة الجوّالة" من خلال Cocoapods أو Swift Package Manager، لن يكون عليك اتخاذ أي إجراء إضافي. في حال تثبيت أُطر العمل يدويًا، يُرجى الاطّلاع على التنزيل اليدوي للحصول على مزيد من التفاصيل.
لم يعُد من الممكن استخدام ميزة "إنشاء البيانات باستخدام رمز بت"
أصبح إيقاف رمز بت في التطبيقات المتوافقة مع الأجهزة الجوّالة مطلوبًا الآن لدمج حزمة "SDK لإعلانات Google على الأجهزة الجوّالة".
تمت إزالة الأنواع.
Type | Notes |
---|---|
GADGender | لا يوجد بديل. |
GADMRewardBasedVideoAdNetworkAdapterProtocol | لقد توقّفت جميع محوِّلات التوسّط بمكافأة المدرَجة في قائمة Select Networks عن استخدام هذه البروتوكولات لمدة تزيد عن سنة. استخدِم GADMediationAdapter للتوسّط والأحداث المخصّصة. |
GADMRewardBasedVideoAdNetworkConnectorProtocol |
تمت إزالة المواقع
تمت إزالة السمات التالية بدون بديل.
الفئة v10.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 لا تستخدم بيانات الموقع الجغرافي لاستهداف الإعلانات. استخدِم واجهات برمجة التطبيقات التابعة لجهات خارجية لتوفير المعلومات لشبكات المواقع الإعلانية التابعة لجهات خارجية إذا لزم الأمر.
إيقاف واجهات الأحداث المخصَّصة نهائيًا
تمكّن الأحداث المخصّصة الناشرين الذين يستخدمون Ad Manager التوسّط من إضافة توسّط العرض الإعلاني بدون انقطاع لشبكة إعلانات ليست من شبكات الإعلانات المتوافقة.
تم إيقاف جميع بروتوكولات الأحداث المخصّصة نهائيًا. بدلاً من ذلك، استخدِم البروتوكولَين الحاليَين
GADMediationAdapter
وGADMediationAdEventDelegate
لتحقيق الوظائف نفسها. يساعد هذا التغيير في زيادة الوضوح ويتيح لك إنشاء أحداث مخصّصة للإعلانات التي تضم مكافآت والإعلانات البينية التي لم تكن متوفّرة في السابق.
واجهات برمجة التطبيقات
يسرد الجدول التالي واجهات برمجة التطبيقات المقابلة لمحوّل التوسّط مع واجهات برمجة التطبيقات للأحداث المخصّصة التي يجب استخدامها بدءًا من الإصدار 9.0.0.
v8 | v9 | |
---|---|---|
GADCustomEventBanner GADCustomEventInterstitial GADCustomEventNativeAd |
GADMediationAdapter | GADMediationBannerAd GADMediationInterstitialAd GADMediationInterscrollerAd GADMediationRewardedAd GADMediationNativeAd |
delegate
|
يتم عرض التفويض من خلال معالج إكمال التحميل لكل دالة تحميل من فئات
GADMediationAdapter .
|
|
-init |
-init |
|
-requestBannerAd:parameter: |
-loadBannerForAdConfiguration: |
|
-requestInterstitialAdWith |
-loadInterstitialFor |
|
-requestNativeAdWithParameter:
|
-loadNativeAdFor |
|
لا ينطبق | -loadInterscrollerAdFor |
|
لا ينطبق | -loadRewardedAdFor |
|
-presentFromRootViewController:
|
-presentFromViewController: |
|
-handlesUserClicks |
-handlesUserClicks |
|
-handlesUserImpressions |
-handlesUserImpressions |
طرق التفويض
يسرد الجدول أدناه طرق تفويض حدث إعلان التوسّط المقابلة لطرق تفويض الحدث المخصّصة التي يجب استخدامها بدءًا من الإصدار 9.0.0.
v8 | v9 | |
---|---|---|
GADCustomEventBanner الإدارة GADCustomEventInterstitial فواتير GADCustomEventNativeAdدور |
GADMediationAdEventDelegate | إعلان GADMediation |
-customEventBanner:didReceiveAd: -customEventInterstitialDidReceiveAd:
|
يتم تضمين حالة تحميل الإعلانات في معالج إكمال التحميل لكل دالة تحميل في الفئة GADMediationAdapter .
|
|
-customEventBanner:didFailAd: -customEventInterstitial:didFailAd:
|
||
-customEventBannerWasClicked: -customEventInterstitialWasClicked:
|
-reportClick |
|
-customEventBannerWill -customEventInterstitialWill
|
-willPresentFullScreenView |
|
-customEventBannerWill -customEventInterstitialWill
|
-willDismissFullScreenView |
|
-customEventBannerDid -customEventInterstitialDid
|
-didDismissFullScreenView |
|
-customEventBannerWill -customEventInterstitialWill
|
-willBackgroundApplication |
|
viewControllerFor |
-[GADMediationBannerAd view] |
الطرق والثوابت الأخرى التي تمت إزالتها/استبدالها
التغييرات في الطريقة أو الثبات أو الخاصية | |
---|---|
kGAD- ثوابت بادئة
|
تمّت إزالة الموضوع. استخدِم ثوابت GAD- مسبوقة.
|
GADAdNetworkResponseInfo
|
تمّت إزالة credentials . يمكنك استخدام adUnitMapping
بدلاً من ذلك.
|
GAMRequest
|
تم إيقاف kGAMSimulatorID في GAMRequest نهائيًا.
يمكنك استخدام GADSimulatorID في GADRequestConfiguration
بدلاً من ذلك.
|
GADCustomNativeAd
|
تم إيقاف mediaView في GADCustomNativeAd نهائيًا.
يمكنك استخدام mediaContent كبديل.
|
واجهات برمجة التطبيقات للشراء داخل التطبيق في GoogleMobileAds |
تمت إزالة inAppPurchase واجهات برمجة تطبيقات في GoogleMobileAds .
|
نقل البيانات من الإصدار 7 إلى الإصدار 8
يقدّم الإصدار 8.0.0 من حزمة تطوير البرامج (SDK) لإعلانات Google على الأجهزة الجوّالة بعض التغييرات الرئيسية، بالإضافة إلى بعض عمليات إعادة التسمية وإزالة واجهات برمجة التطبيقات.
تحديثات واجهة برمجة التطبيقات لتنسيق ملء الشاشة
بدءًا من الإصدار 8.0.0، تتشارك الإعلانات البينية والإعلانات التي تضم مكافأة نمطًا عامًا من الإعلانات بملء الشاشة لتحقيق المزيد من الاتساق. تتميز واجهات برمجة التطبيقات الجديدة للإعلانات بملء الشاشة بنوعين رئيسيين عن الإصدار 7 من واجهات برمجة التطبيقات للإعلانات بملء الشاشة:
طريقة الفئة الثابتة
load
:في ما يلي الأسلوب السابق لتحميل/عرض إعلان ملء الشاشة:
- أنشئ مثيلاً لكائن الإعلان واحتفظ بإشارة إليه.
- يمكنك تحديد مفوَّض يتولّى تحميل عمليات الردّ على المكالمات وعرضها.
- تحميل إعلان
- تحقَّق من تحميل الإعلان باستخدام "
isReady
". - اعرض الإعلان.
في الإصدار 8، يتغير النهج قليلاً. لم يعد تحميل استدعاءات الاتصال جزءًا من المفوَّض. وبدلاً من ذلك، يتم تمريرها إلى الإجراء
load
كمعالج إكمال:- عليك استدعاء طريقة تحميل ثابتة في فئة الإعلان وتوفير معالج لإكمال التحميل.
- في استدعاء إكمال التحميل، احتفظ بمرجع للإعلان المحمَّل الذي تم عرضه.
- يمكنك تخصيص مفوَّض يتولّى عرض عمليات معاودة الاتصال.
- اعرض الإعلان.
يوفر الأسلوب الجديد المزايا التالية:
- ولن يكون لديك على الإطلاق مرجع إلى إعلان لم يتم تحميله.
- ولا تحتاج إلى الاحتفاظ بكائن الإعلان أثناء تحميله.
أحداث إعلانات متّسقة:
نوع الفعالية واجهة برمجة التطبيقات الحالية v8 API تحميل الأحداث السمة GADInterstitialDelegate
أو السمةGADRewardedAdDelegate
السمة GAMInterstitialAdLoadCompletionHandler
أو السمةGADRewardedAdLoadCompletionHandler
أحداث العروض التقديمية GADFullScreenContentDelegate
في السابق، كان عليك تسجيل فئة تنفّذ بروتوكول
GADInterstitialDelegate
لخاصية المفوّض في الإعلان البيني، أو تسجّل فئة تنفّذ بروتوكولGADRewardedAdDelegate
لخاصية التفويض في الإعلان الذي يضم مكافأة، وذلك استنادًا إلى التنسيق الذي تستخدمه. كان لدى هذا المفوَّض نفسه طرق ذات صلة بكل من دورة حياة التحميل والعرض التقديمي للإعلان.في الإصدار 8، تكون أحداث التحميل والعرض منفصلة عن بعضها. يمكنك الآن تسجيل
GADFullScreenContentDelegate
في أي وقت قبل عرض إعلان بدلاً من أن يُطلب منك تعيين مفوَّض واحد قبل تحميل الإعلان. تنتقل أحداث تحميل الإعلانات، الخاصة بكل شكل، إلى معالِج واحد لإكمال التحميل تم تمريره في طريقة التحميل.
إعلان بيني
تحميل الإعلان
توضّح لك مقتطفات الرمز أدناه كيفية تحميل إعلان بيني ورصد الأحداث التي يتم رصدها عند نجاح الإعلان أو تعذُّر تحميله.
v7
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADInterstitialDelegate { var interstitial: DFPInterstitial! override func viewDidLoad() { super.viewDidLoad() interstitial = DFPInterstitial(adUnitID: "/6499/example/interstitial") interstitial.delegate = self let request = GAMRequest() interstitial.load(request) } /// Tells the delegate an ad request succeeded. func interstitialDidReceiveAd(_ ad: DFPInterstitial) { print("Interstitial ad loaded.") } /// Tells the delegate an ad request failed. func interstitial(_ ad: DFPInterstitial, didFailToReceiveAdWithError error: GADRequestError) { print("Interstitial ad failed to load with error: \(error.localizedDescription)") } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) DFPInterstitial *interstitial; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.interstitial = [[DFPInterstitial alloc] initWithAdUnitID:@"/6499/example/interstitial"]; self.interstitial.delegate = self; GAMRequest *request = [GAMRequest request]; [self.interstitial loadRequest:request]; } /// Tells the delegate an ad request succeeded. - (void)interstitialDidReceiveAd:(DFPInterstitial *)ad { NSLog(@"Insterstitial ad loaded."); } /// Tells the delegate an ad request failed. - (void)interstitial:(DFPInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error { NSLog(@"Interstitial ad failed to load with error: %@", [error localizedDescription]); }
v8
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADFullScreenContentDelegate { var interstitial: GAMInterstitialAd? override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() GAMInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738", request: request, completionHandler: { (ad, error) in if let error = error { print("Failed to load interstitial ad with error: \(error.localizedDescription)") return } self.interstitial = ad self.interstitial.fullScreenContentDelegate = self } ) } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) GAMInterstitialAd *interstitial; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; GAMRequest *request = [GAMRequest request]; [GAMInterstitialAd loadWithAdUnitID:@"/6499/example/interstitial" request:request completionHandler:^(GAMInterstitialAd *ad, NSError *error) { if (error) { NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]); return; } self.interstitial = ad; self.interstitial.fullScreenContentDelegate = self; }]; }
إعلان صوري
v7
Swift
func showInterstitial() { ... if interstitial.isReady { interstitial.present(fromRootViewController: self) } else { print("Ad wasn't ready") } }
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"); } }
أحداث إعلانات العرض التقديمي
توضّح لك مقتطفات الرمز أدناه كيفية التعامل مع طلبات معاودة الاتصال عند عرض الإعلان (بنجاح أو فشل) ووقت رفضه.
v7
Swift
override func viewDidLoad() { super.viewDidLoad() interstitial = DFPInterstitial(adUnitID: "/6499/example/interstitial") interstitial.delegate = self ... } /// Tells the delegate that an interstitial will be presented. func interstitialWillPresentScreen(_ ad: DFPInterstitial) { print("Interstitial ad will be presented.") } /// Tells the delegate the interstitial is to be animated off the screen. func interstitialWillDismissScreen(_ ad: DFPInterstitial) { print("Interstitial ad will be dismissed.") } /// Tells the delegate the interstitial had been animated off the screen. func interstitialDidDismissScreen(_ ad: DFPInterstitial) { print("Interstitial ad dismissed.") } /// Tells the delegate that a user click will open another app /// (such as the App Store), backgrounding the current app. /// /// This is not a reliable callback for an ad click event and is removed in /// version 8. If you wish to listen to an ad causing a user to leave the app, /// use applicationWillResignActive: or sceneWillResignActive: instead. func interstitialWillLeaveApplication(_ ad: DFPInterstitial) { print("Interstitial ad will leave application.") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; self.interstitial = [[DFPInterstitial alloc] initWithAdUnitID:"/6499/example/interstitial"]; self.interstitial.delegate = self; ... } /// Tells the delegate that an interstitial will be presented. - (void)interstitialWillPresentScreen:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will be presented."); } /// Tells the delegate the interstitial is to be animated off the screen. - (void)interstitialWillDismissScreen:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will be dismissed."); } /// Tells the delegate the interstitial had been animated off the screen. - (void)interstitialDidDismissScreen:(DFPInterstitial *)ad { NSLog(@"Interstitial ad dismissed."); } /// Tells the delegate that a user click will open another app /// (such as the App Store), backgrounding the current app. /// /// This is not a reliable callback for an ad click event and is removed in /// version 8. If you wish to listen to an ad causing a user to leave the app, /// use applicationWillResignActive: or sceneWillResignActive: instead. - (void)interstitialWillLeaveApplication:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will leave application."); }
v8
Swift
override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() GAMInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738", request: request, completionHandler: { (ad, error) in if let error = error { print(error.localizedDescription) return } self.interstitial = ad self.interstitial.fullScreenContentDelegate = self } ) } func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("Ad did present full screen content.") } func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) { print("Ad failed to present full screen content with error \(error.localizedDescription).") } func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("Ad did dismiss full screen content.") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; GAMRequest *request = [GAMRequest request]; [GAMInterstitialAd loadWithAdUnitID:@"/6499/example/interstitial" request:request completionHandler:^(GAMInterstitialAd *ad, NSError *error) { if (error) { NSLog(@"interstitial:didFailToReceiveAdWithError: %@", [error localizedDescription]) return; } self.interstitial = ad; self.interstitial.fullScreenContentDelegate = self; }]; } - (void)adDidPresentFullScreenContent:(id)ad { NSLog(@"Ad did present full screen content."); } - (void)ad:(id )ad didFailToPresentFullScreenContentWithError:(NSError *)error { NSLog(@"Ad failed to present full screen content with error %@.", [error localizedDescription]); } - (void)adDidDismissFullScreenContent:(id )ad { NSLog(@"Ad did dismiss full screen content."); }
تم منح المكافأة
تحميل الإعلان
v7
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADRewardedAdDelegate { /// The rewarded ad. var rewardedAd: GADRewardedAd? override func viewDidLoad() { super.viewDidLoad() rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313") rewardedAd.delegate = self rewardedAd?.load(GAMRequest()) { error in if let error = error { print("Rewarded ad failed to load with error: \(error.localizedDescription)") } else { print("Rewarded ad loaded.") } } } }
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; GAMRequest *request = [GAMRequest request]; [self.rewardedAd loadRequest:request completionHandler:^(GADRequestError * _Nullable error) { if (error) { NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]); } else { NSLog(@"Rewarded ad loaded."); } }]; }
v8
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADFullScreenContentDelegate { /// The rewarded ad. var rewardedAd: GADRewardedAd? override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136", request: request, completionHandler: { (ad, error) in if let error = error { print("Rewarded ad failed to load with error: \(error.localizedDescription)") return } self.rewardedAd = ad self.rewardedAd?.fullScreenContentDelegate = self } ) } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) GADRewardedAd *rewardedAd; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; GAMRequest *request = [GAMRequest request]; [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313" request:request completionHandler:^(GADRewardedAd *ad, NSError *error) { if (error) { NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]); return; } self.rewardedAd = ad; NSLog(@"Rewarded ad loaded."); self.rewardedAd.fullScreenContentDelegate = self; }
إعلان صوري والتعامل مع المكافآت
تتطلب الإعلانات التي تضم مكافآت التعامل مع الحدث عندما يربح المستخدم مكافأة. في
الإصدار 7 من واجهة برمجة التطبيقات GADRewardedAd
، يتم تنفيذ
rewardedAd:userDidEarnReward:
كجزء من بروتوكول GADRewardedAdDelegate
.
بالنسبة إلى الإصدار 8، يجب تنفيذ السمة GADUserDidEarnRewardHandler
لعرض الإعلان.
v7
Swift
func showRewardedAd() { ... if rewardedAd.isReady { rewardedAd.present(fromRootViewController: self delegate:self) } else { print("Ad wasn't ready") } } /// Tells the delegate that the user earned a reward. func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarnReward: GADAdReward) { // TODO: Reward the user. }
Objective-C
- (void)showRewardedAd: { ... if (self.rewardedAd.isReady) { [self.rewardedAd presentFromRootViewController:self delegate:self]; } else { NSLog(@"Ad wasn't ready"); } } /// Tells the delegate that the user earned a reward. - (void)rewardedAd:(GADRewardedAd *)rewardedAd userDidEarnReward:(GADAdReward *)reward { // TODO: Reward the user. }
v8
Swift
func showRewardedAd() { ... if let ad = rewardedAd { ad.present(fromRootViewController: self, userDidEarnRewardHandler: { let reward = ad.adReward // TODO: Reward the user. } ) } else { print("Ad wasn't ready") } }
Objective-C
- (void)showRewardedAd: { ... if (self.rewardedAd) { [self.rewardedAd presentFromRootViewController:self userDidEarnRewardHandler:^ { GADAdReward *reward = self.rewardedAd.adReward; // TODO: Reward the user. }]; } else { NSLog(@"Ad wasn't ready"); } }
أحداث إعلانات العرض التقديمي
ومن خلال GADRewardedAd
API، تُدخِل GADRewardedAdDelegate
إلى الطريقة التي تعرِض الإعلان. من خلال واجهة برمجة التطبيقات GADRewardedAd
، يمكنك ضبط
GADFullscreenContentDelegate
كخاصية في الإعلان قبل عرض
الإعلان.
v7
Swift
func showRewardedAd() { ... if rewardedAd.isReady { rewardedAd.present(fromRootViewController: self delegate:self) } else { print("Ad wasn't ready") } } /// Tells the delegate that the rewarded ad was presented. func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) { print("Rewarded ad presented.") } /// Tells the delegate that the rewarded ad was dismissed. func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) { print("Rewarded ad dismissed.") } /// Tells the delegate that the rewarded ad failed to present. func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) { print("Rewarded ad failed to present with error: \(error.localizedDescription).") }
Objective-C
- (void)showRewardedAd: { ... if (self.rewardedAd.isReady) { [self.rewardedAd presentFromRootViewController:self delegate:self]; } else { NSLog(@"Ad wasn't ready"); } } /// Tells the delegate that the rewarded ad was presented. - (void)rewardedAdDidPresent:(GADRewardedAd *)rewardedAd { NSLog(@"Rewarded ad presented."); } /// Tells the delegate that the rewarded ad failed to present. - (void)rewardedAd:(GADRewardedAd *)rewardedAd didFailToPresentWithError:(NSError *)error { NSLog(@"Rewarded ad failed to present with error: %@", [error localizedDescription]); } /// Tells the delegate that the rewarded ad was dismissed. - (void)rewardedAdDidDismiss:(GADRewardedAd *)rewardedAd { NSLog(@"Rewarded ad dismissed."); }
v8
Swift
override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136", request: request, completionHandler: { (ad, error) in if let error = error { print(error.localizedDescription) return } self.rewardedAd = ad self.rewardedAd?.fullScreenContentDelegate = self } ) } /// Tells the delegate that the rewarded ad was presented. func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("Rewarded ad presented.") } /// Tells the delegate that the rewarded ad was dismissed. func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("Rewarded ad dismissed.") } /// Tells the delegate that the rewarded ad failed to present. func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) { print("Rewarded ad failed to present with error: \(error.localizedDescription).") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; GAMRequest *request = [GAMRequest request]; [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313" request:request completionHandler:^(GADRewardedAd *ad, NSError *error) { if (error) { NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]); return; } self.rewardedAd = ad; NSLog(@"Rewarded ad loaded."); self.rewardedAd.fullScreenContentDelegate = self; } /// Tells the delegate that the rewarded ad was presented. - (void)adDidPresentFullScreenContent:(id)ad { NSLog(@"Rewarded ad presented."); } /// Tells the delegate that the rewarded ad failed to present. - (void)ad:(id )ad didFailToPresentFullScreenContentWithError:(NSError *)error { NSLog(@"Rewarded ad failed to present with error: %@", [error localizedDescription]); } /// Tells the delegate that the rewarded ad was dismissed. - (void)adDidDismissFullScreenContent:(id )ad { NSLog(@"Rewarded ad dismissed."); }
إزالة واجهة برمجة تطبيقات GADRewardedBasedVideoAd القديمة
تم طرح
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
.
الفئة v7.68.0 | الفئة v8.0.0 |
---|---|
DFPBannerView | GAMBannerView |
DFPBannerViewOptions | GAMBannerViewOptions |
DFPInterstitial | إعلان بيني في "مدير إعلانات Google" |
DFPRequest | GAMRequest |
GADRequestError | NSError |
GADUnifiedNativeAdView | GADNativeAdView |
إعلان GADUnifiedNativeAd | إعلان GADNativeAd |
GADUnifiedNativeAdAssetIdentifiers | GADNativeAdAssetIdentifiers |
GADUnifiedNativeAdDelegate | GADNativeAdDelegate |
GADUnifiedNativeAdUnconfirmedClickDelegate | GADNativeAdUnconfirmedClickDelegate |
GADNativeCustomTemplateAd | GADCustomNativeAd |
GADNativeCustomTemplateAdLoaderDelegate | GADCustomNativeAdLoaderDelegate |
GADNativeAdDelegate | GADCustomNativeAdDelegate |
GADInAppPurchase | تمت إزالته |
GADInterstitial | إعلان بيني GAD |
GADNativeExpressAdView | تمت إزالته |
إعلان فيديو يستند إلى GADRewardBased | تمت إزالته |
إعلان GADInstream | تمت إزالته |
GADInstreamAdView | تمت إزالته |
طرق تمت إزالتها/استبدالها
يسرد الجدول التالي التغييرات المحدَّدة في الإصدار 8. باختصار:
- وتمّت إزالة الطرق والخصائص المتوقّفة سابقًا.
- تمت إزالة
-willLeaveApplication:
طريقة تفويض لجميع التنسيقات. - تم نقل اسم فئة شبكة الإعلانات إلى السمة
GADResponseInfo
. - تم نقل معرّف جهاز الاختبار إلى السمة
GADRequestConfiguration
.
الفئة v7.68.0 | الإصدار 7.68.0 من واجهة برمجة التطبيقات | الإصدار 8.0.0 من واجهة برمجة التطبيقات | Notes |
---|---|---|---|
إعلانات GADMobileAds | +ConfigureWithApplicationID: | -startWithCompleteHandler: | تم ضبط رقم تعريف التطبيق الآن في Info.plist. |
+disableAutoAutoInApp |
-disableAutoAutoInApp |
||
+disableSDKCrashReporting | -disableSDKCrashReporting | ||
GADRequest | testDevices | GADRequestConfiguration |
تنطبق الخاصية testDeviceIds على جميع طلبات الإعلانات، في حين أنّه تم ضبط سمة testDevices القديمة لكل طلب. |
gender | تمت إزالته | ||
عيد الميلاد | تمت إزالته | ||
+sdkVersion | GADMobileAds.sharedInstance |
||
-setBirthday |
تمت إزالته | ||
-setLocationWithDescription: | -setLocationWith |
||
-tagForChildDirectedTreatment: | [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment] | ||
GADErrorCode | kGADError* | خطأ GADError* | يتم إسقاط البادئة k من جميع ثوابت رمز الخطأ.
|
GADBannerView | hasAutoRefreshed | autoloadEnabled | |
inAppPurchaseDelegate | تمت إزالته | ||
mediatedAdView | تمت إزالته | ||
adNetworkClassName | ResponseInfo |
||
DFPBannerView | -setصالحAdSizesWithSizes: | -setvalidAdSizes: | |
DFPBannerViewOptions | -adSizeSize | تمت إزالته | |
GADBannerViewDelegate | -adViewDidSingleAd: | -bannerViewDidReceivedAd: | |
-adView:didFailToReceive |
-bannerView:didFailToReceive |
||
-adViewwillPresentScreen: | -bannerViewwillPresentScreen: | ||
-adViewwillSeeScreen: | -bannerViewwill المحدَّدScreen: | ||
-adViewDidPauseScreen: | -bannerViewDidPauseScreen: | ||
-adViewwillمغادرةApplication: | تمت إزالته | ||
GADNativeCustomTemplateAd | templateID | GADCustomNativeAd.formatID | |
-performClickOnAssetWithKey: |
-performClickOnAssetWithKey: | ||
GADNativeAdImageAd |
preferredImageOrientation | GADNativeAdMediaAdOptions |
|
GADInterstitial | inAppPurchaseDelegate | تمت إزالته | |
isReady | تمت إزالته | استخدِم canPresentFrom |
|
hasBeenUsed | تمت إزالته | ||
-init | -initWithAdUnitID: | ||
-setAdUnitID: | -initWithAdUnitID: | ||
adNetworkClassName | ResponseInfo |
||
-interstitialwill |
تمت إزالته | ||
إعلان GADUnifiedNativeAd | videoController | mediaContent.videoController | |
adNetworkClassName | ResponseInfo |