الإعلانات البينية هي إعلانات بملء الشاشة تغطي واجهة التطبيق المضيف. وعادةً ما تظهر هذه الإعلانات في نقاط الانتقال العادية في تدفق التطبيقات، مثلاً أثناء فترة الإيقاف المؤقت بين المستويات في الألعاب. عندما يعرض تطبيق إعلانًا بينيًا، يمكن للمستخدم النقر على الإعلان والمتابعة إلى وجهته أو إغلاقه والعودة إلى التطبيق.
يوضّح هذا الدليل كيفية دمج الإعلانات البينية في تطبيق Unity.
اختبار الإعلانات دائمًا باستخدام الإعلانات الاختبارية
يحتوي نموذج الرمز البرمجي التالي على رقم تعريف وحدة إعلانية يمكنك استخدامه لطلب إعلانات اختبارية. تم إعداد هذا المعرّف خصيصًا لعرض إعلانات اختبارية بدلاً من إعلانات فعلية لكل طلب، ما يجعله آمنًا للاستخدام.
ومع ذلك، بعد تسجيل تطبيق في واجهة الويب الخاصة بـ "مدير إعلانات Google" وإنشاء أرقام تعريف خاصة بوحداتك الإعلانية لاستخدامها في تطبيقك، عليك إعداد جهازك بشكل صريح كجهاز اختباري أثناء عملية التطوير.
/21775744923/example/interstitial
إعداد حزمة تطوير البرامج (SDK) للإعلانات على الأجهزة الجوّالة
قبل تحميل الإعلانات، يجب أن يبدأ تطبيقك في إعداد حزمة تطوير البرامج (SDK) لإعلانات Google على الأجهزة الجوّالة من خلال استدعاء MobileAds.Initialize(). يجب إجراء ذلك مرة واحدة فقط، ويُفضّل عند تشغيل التطبيق.
usingGoogleMobileAds;usingGoogleMobileAds.Api;publicclassGoogleMobileAdsDemoScript:MonoBehaviour{publicvoidStart(){// Initialize Google Mobile Ads SDK.MobileAds.Initialize((InitializationStatusinitStatus)=>
{// This callback is called once the MobileAds SDK is initialized.});}}
في حال استخدام التوسّط، انتظِر إلى أن يتم تنفيذ معاودة الاتصال قبل تحميل الإعلانات، لأنّ ذلك سيضمن تهيئة جميع محوّلات التوسّط.
تحميل الإعلان البيني
يتم تحميل إعلان بيني باستخدام الطريقة الثابتة Load() في الفئة InterstitialAd. تتطلّب طريقة التحميل رقم تعريف وحدة إعلانية وكائن AdManagerAdRequest ومعالج إكمال يتم استدعاؤه عند نجاح تحميل الإعلان أو تعذّره. يتم توفير الكائن AdManagerInterstitialAd الذي تم تحميله كمعلَمة في معالج الإكمال. يحمّل المثال التالي AdManagerInterstitialAd:
// Create our request used to load the ad.varadRequest=newAdRequest();// Send the request to load the ad.InterstitialAd.Load("AD_UNIT_ID",adRequest,(InterstitialAdad,LoadAdErrorerror)=>
{if(error!=null){// The ad failed to load.return;}// The ad loaded successfully.});
لعرض إعلان بيني تم تحميله، استدعِ طريقة Show() على مثيل AdManagerInterstitialAd. قد يتم عرض الإعلانات مرة واحدة لكل عملية تحميل. استخدِم طريقة CanShowAd() للتأكّد من أنّ الإعلان جاهز للعرض.
لتخصيص سلوك إعلانك بشكل أكبر، يمكنك ربط عدد من الأحداث في دورة حياة الإعلان. يستمع المثال التالي إلى أحداث الإعلانات:
interstitialAd.OnAdPaid+=(AdValueadValue)=>
{// Raised when the ad is estimated to have earned money.};interstitialAd.OnAdImpressionRecorded+=()=>
{// Raised when an impression is recorded for an ad.};interstitialAd.OnAdClicked+=()=>
{// Raised when a click is recorded for an ad.};interstitialAd.OnAdFullScreenContentOpened+=()=>
{// Raised when the ad opened full screen content.};interstitialAd.OnAdFullScreenContentClosed+=()=>
{// Raised when the ad closed full screen content.};interstitialAd.OnAdFullScreenContentFailed+=(AdErrorerror)=>
{// Raised when the ad failed to open full screen content.};
يُعلم هذا الإجراء المكوّن الإضافي بأنّ العنصر لم يعُد مستخدَمًا ويمكن استعادة الذاكرة التي يشغلها. سيؤدي عدم استدعاء هذه الطريقة إلى حدوث تسرُّب للذاكرة.
التحميل المُسبَق للإعلان البيني التالي
الإعلانات البينية هي عنصر يُستخدَم لمرة واحدة. وهذا يعني أنّه بعد عرض إعلان بيني، لا يمكن استخدام العنصر مرة أخرى. لطلب إعلان بيني آخر، أنشئ عنصر AdManagerInterstitialAd جديدًا.
لإعداد إعلان بيني لفرصة الظهور التالية، يمكنك التحميل المُسبَق للإعلان البيني عند ظهور حدث الإعلان OnAdFullScreenContentClosed أو OnAdFullScreenContentFailed.
interstitialAd.OnAdFullScreenContentClosed+=()=>
{// Reload the ad so that we can show another as soon as possible.varadRequest=newAdRequest();InterstitialAd.Load("AD_UNIT_ID",adRequest,(InterstitialAdad,LoadAdErrorerror)=>
{// Handle ad loading here.});};
تحديد ما إذا كانت "الإعلانات البينية" هي نوع الإعلانات المناسب لتطبيقك
تعمل "الإعلانات البينية" بشكل أفضل في التطبيقات التي تتضمّن نقاط انتقال طبيعية.
يتم إنشاء نقطة انتقال عند إكمال مهمة في التطبيق، مثل مشاركة صورة أو إكمال أحد مستويات اللعبة. احرص على تحديد نقاط عرض الإعلانات البينية في مسار تطبيقك بشكل مناسب، وكيفية تفاعل المستخدم معها.
إيقاف الإجراء مؤقتًا عند عرض إعلان بيني
هناك العديد من أنواع الإعلانات البينية المختلفة، مثل الإعلانات النصية أو المصوّرة أو إعلانات الفيديو. من المهم التأكّد من أنّ تطبيقك يعلّق استخدام بعض الموارد عند عرض إعلان بيني، وذلك للسماح للإعلان بالاستفادة من هذه الموارد. على سبيل المثال، عند إجراء طلب لعرض إعلان بيني، احرص على إيقاف أي ناتج صوتي مؤقتًا يصدره تطبيقك. ويمكنك استئناف تشغيل الأصوات في الحدث OnAdFullScreenContentClosed()، الذي يمكن استدعاؤه عندما ينتهي المستخدم من التفاعل مع الإعلان. بالإضافة إلى ذلك، ننصحك بإيقاف أي مهام حسابية مكثّفة مؤقتًا، مثل حلقة الألعاب، أثناء عرض الإعلان. ويضمن ذلك ألّا يواجه المستخدم
رسومات بطيئة أو غير مستجيبة أو فيديو متقطّع.
لا تغرق المستخدم بالإعلانات.
قد تبدو زيادة معدّل تكرار الإعلانات البينية في تطبيقك طريقة رائعة لزيادة الإيرادات، ولكنّها قد تؤدي أيضًا إلى انخفاض مستوى تجربة المستخدمين وانخفاض معدّلات النقر. تأكَّد من عدم مقاطعة المستخدمين بشكل متكرّر لدرجة أنّهم لم يعودوا قادرين على الاستمتاع باستخدام تطبيقك.
تاريخ التعديل الأخير: 2025-09-06 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-09-06 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eInterstitial ads are full-screen ads displayed at natural transition points in an app, allowing users to interact or close them.\u003c/p\u003e\n"],["\u003cp\u003eThis guide provides instructions on integrating interstitial ads into a Unity app using the Google Mobile Ads SDK.\u003c/p\u003e\n"],["\u003cp\u003eKey implementation steps include loading, displaying, handling events, cleaning up, and preloading interstitial ads.\u003c/p\u003e\n"],["\u003cp\u003eBest practices emphasize strategic ad placement, pausing app actions during display, and avoiding excessive ad frequency for optimal user experience.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/ad-manager/mobile-ads-sdk/android/interstitial \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/interstitial \"View this page for the iOS platform docs.\") [Unity](/ad-manager/mobile-ads-sdk/unity/interstitial \"View this page for the Unity platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/flutter/interstitial \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nInterstitial ads are full-screen ads that cover the interface of their host app.\nThey're typically displayed at natural transition points in the flow of an app,\nsuch as during the pause between levels in a game. When an app shows an\ninterstitial ad, the user has the choice to either tap on the ad and continue to\nits destination or close it and return to the app.\n\n\nThis guide explains how to integrate interstitial ads into a Unity app.\n\nPrerequisites\n\n- Complete the [Get started guide](/ad-manager/mobile-ads-sdk/unity/quick-start).\n\nAlways test with test ads\n\nThe following sample code contains an ad unit ID which you can use to request\ntest ads. It's been specially configured to return test ads rather than\nproduction ads for every request, making it safe to use.\n\nHowever, after you've registered an app in the\nAd Manager web interface and created your own ad unit\nIDs for use in your app, explicitly [configure your device as a test\ndevice](/ad-manager/mobile-ads-sdk/unity/test-ads#enable_test_devices) during\ndevelopment.\n\n`/21775744923/example/interstitial`\n\nInitialize the Mobile Ads SDK\n\nBefore loading ads, have your app initialize Google Mobile Ads SDK by calling\n`MobileAds.Initialize()`. This needs to be done only once, ideally at app launch. \n\n using GoogleMobileAds;\n using GoogleMobileAds.Api;\n\n public class GoogleMobileAdsDemoScript : MonoBehaviour\n {\n public void Start()\n {\n // Initialize Google Mobile Ads SDK.\n MobileAds.Initialize((InitializationStatus initStatus) =\u003e\n {\n // This callback is called once the MobileAds SDK is initialized.\n });\n }\n }\n\nIf you're using mediation, wait until the callback occurs before loading ads as\nthis will ensure that all mediation adapters are initialized.\n\nLoad the interstitial ad\n\nLoading an interstitial ad is accomplished using the static `Load()` method on the\n`InterstitialAd` class. The load method requires an ad unit ID, an\n`AdManagerAdRequest` object, and a completion handler which\ngets called when ad loading succeeds or fails. The loaded\n`AdManagerInterstitialAd` object is provided as a parameter in\nthe completion handler. The following example loads AdManagerInterstitialAd: \n\n // Create our request used to load the ad.\n var adRequest = new AdRequest();\n\n // Send the request to load the ad.\n InterstitialAd.Load(\"\u003cvar translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e\", adRequest, (InterstitialAd ad, LoadAdError error) =\u003e\n {\n if (error != null)\n {\n // The ad failed to load.\n return;\n }\n // The ad loaded successfully.\n }); \n https://github.com/googleads/googleads-mobile-unity/blob/9544f919c5c8067939fa38d7fb45d698a7408dc1/samples/HelloWorld/Assets/Snippets/InterstitialAdSnippets.cs#L21-L33\n\nReplace \u003cvar class=\"readonly\" translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e with your ad unit ID.\n| **Warning:** Attempting to load a new ad from the ad request completion block when an ad failed to load is strongly discouraged. If you must load an ad from the ad request completion block, limit ad load retries to avoid continuous failed ad requests in situations such as limited network connectivity.\n\n\n| **Tip:** You can use ad load calls to build up a cache of preloaded ads before you intend to show them, so that ads can be shown with zero latency when needed. Since ads expire after an hour, you should clear this cache and reload with new ads every hour.\n\n\u003cbr /\u003e\n\nShow the interstitial ad\n\nTo show a loaded interstitial ad, call the `Show()` method on the\n`AdManagerInterstitialAd` instance. Ads may be shown once per\nload. Use the `CanShowAd()` method to verify that the ad is ready to be shown.\n**Note:** Interstitial ads should be displayed during natural pauses in the flow of an app, such as between levels of a game or after the user completes a task. \n\n if (interstitialAd != null && interstitialAd.CanShowAd())\n {\n interstitialAd.Show();\n } \n https://github.com/googleads/googleads-mobile-unity/blob/9544f919c5c8067939fa38d7fb45d698a7408dc1/samples/HelloWorld/Assets/Snippets/InterstitialAdSnippets.cs#L40-L43\n\nListen to interstitial ad events\n\nTo further customize the behavior of your ad, you can hook into a number of\nevents in the ad's lifecycle. The following example listens to ad events: \n\n interstitialAd.OnAdPaid += (AdValue adValue) =\u003e\n {\n // Raised when the ad is estimated to have earned money.\n };\n interstitialAd.OnAdImpressionRecorded += () =\u003e\n {\n // Raised when an impression is recorded for an ad.\n };\n interstitialAd.OnAdClicked += () =\u003e\n {\n // Raised when a click is recorded for an ad.\n };\n interstitialAd.OnAdFullScreenContentOpened += () =\u003e\n {\n // Raised when the ad opened full screen content.\n };\n interstitialAd.OnAdFullScreenContentClosed += () =\u003e\n {\n // Raised when the ad closed full screen content.\n };\n interstitialAd.OnAdFullScreenContentFailed += (AdError error) =\u003e\n {\n // Raised when the ad failed to open full screen content.\n }; \n https://github.com/googleads/googleads-mobile-unity/blob/9544f919c5c8067939fa38d7fb45d698a7408dc1/samples/HelloWorld/Assets/Snippets/InterstitialAdSnippets.cs#L50-L73\n\nClean up the interstitial ad\n\nWhen you are finished with an `AdManagerInterstitialAd`, make\nsure to call the `Destroy()` method before dropping your reference to it: \n\n if (interstitialAd != null)\n {\n interstitialAd.Destroy();\n } \n https://github.com/googleads/googleads-mobile-unity/blob/9544f919c5c8067939fa38d7fb45d698a7408dc1/samples/HelloWorld/Assets/Snippets/InterstitialAdSnippets.cs#L80-L83\n\nThis notifies the plugin that the object is no longer used and the memory it\noccupies can be reclaimed. Failure to call this method results in memory leaks.\n\nPreload the next interstitial ad\n\nInterstitial ads are a one-time-use object. This means once an interstitial ad\nis shown, the object can't be used again. To request another interstitial ad,\ncreate a new `AdManagerInterstitialAd` object.\n\nTo prepare an interstitial ad for the next impression opportunity, preload the\ninterstitial ad once the `OnAdFullScreenContentClosed` or\n`OnAdFullScreenContentFailed` ad event is raised. \n\n interstitialAd.OnAdFullScreenContentClosed += () =\u003e\n {\n // Reload the ad so that we can show another as soon as possible.\n var adRequest = new AdRequest();\n InterstitialAd.Load(\"\u003cvar translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e\", adRequest, (InterstitialAd ad, LoadAdError error) =\u003e\n {\n // Handle ad loading here.\n });\n }; \n https://github.com/googleads/googleads-mobile-unity/blob/9544f919c5c8067939fa38d7fb45d698a7408dc1/samples/HelloWorld/Assets/Snippets/InterstitialAdSnippets.cs#L90-L98\n\nBest practices\n\nDetermine whether interstitial ads are the right type of ad for your app.\n: Interstitial ads work best in apps with natural transition points.\n The conclusion of a task within an app, such as sharing an image or completing a\n game level, creates such a point. Make sure you consider at which points in your\n app's flow to best display interstitial ads and how the user is likely to respond.\n\nPause the action when displaying an interstitial ad.\n: There are a number of different types of interstitial ads such as text,\n image, or video. It's important to make sure that when your app displays an\n interstitial ad, it also suspends its use of some resources to allow the ad to\n take advantage of them. For example, when you make the call to display an\n interstitial ad, be sure to pause any audio output being produced by your app.\n You can resume playing sounds in the `OnAdFullScreenContentClosed()` event,\n which can be invoked when the user has finished interacting with the ad. In\n addition, consider temporarily halting any intense computation tasks, such as a\n game loop, while the ad is being displayed. This ensures that the user doesn't\n experience slow or unresponsive graphics or stuttered video.\n\nDon't flood the user with ads.\n: While increasing the frequency of interstitial ads in your app might seem\n like a great way to increase revenue, it can also degrade the user experience\n and lower click-through rates. Make sure that users aren't so frequently\n interrupted that they're no longer able to enjoy the use of your app.\n\nAdditional resources\n\n- [HelloWorld example](//github.com/googleads/googleads-mobile-unity/tree/main/samples/HelloWorld): A minimal implementation of all ad formats."]]