بینابینی
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
پلتفرم را انتخاب کنید: Android iOS Unity Flutter تبلیغات بینابینی تبلیغات تمام صفحه ای هستند که رابط برنامه میزبان خود را پوشش می دهند. آنها معمولاً در نقاط انتقال طبیعی در جریان یک برنامه نمایش داده می شوند، مانند بین فعالیت ها یا در طول مکث بین سطوح در یک بازی. هنگامی که یک برنامه یک تبلیغ بینابینی را نشان می دهد، کاربر این انتخاب را دارد که یا روی تبلیغ ضربه زده و به مقصد خود ادامه دهد یا آن را ببندد و به برنامه بازگردد.
این راهنما نحوه ادغام تبلیغات بینابینی را در برنامه Flutter توضیح می دهد.
همیشه با تبلیغات آزمایشی تست کنید
هنگام ساخت و آزمایش برنامه های خود، مطمئن شوید که از تبلیغات آزمایشی به جای تبلیغات زنده و تولیدی استفاده می کنید. عدم انجام این کار می تواند منجر به تعلیق حساب شما شود.
سادهترین راه برای بارگیری آگهیهای آزمایشی، استفاده از شناسه واحد آگهی آزمایشی اختصاصی ما برای موارد میاناثر است:
اندروید
ca-app-pub-3940256099942544/1033173712
iOS
ca-app-pub-3940256099942544/4411468910
واحدهای آگهی آزمایشی به گونهای پیکربندی شدهاند که برای هر درخواستی، آگهیهای آزمایشی را برگردانند، و شما میتوانید هنگام کدنویسی، آزمایش و اشکالزدایی از آنها در برنامههای خود استفاده کنید. فقط مطمئن شوید که قبل از انتشار برنامه خود، آنها را با شناسه واحد تبلیغاتی خود جایگزین کنید.
یک تبلیغ را بارگیری کنید
مثال زیر یک تبلیغ بینابینی را بارگیری می کند:
_adUnitId با شناسه واحد تبلیغاتی خود جایگزین کنید.
رویدادهای تبلیغاتی بینابینی
از طریق استفاده از FullScreenContentCallback
، میتوانید به رویدادهای چرخه حیات گوش دهید، مانند زمانی که آگهی نشان داده میشود یا رد میشود. قبل از نمایش آگهی InterstitialAd.fullScreenContentCallback
را تنظیم کنید تا اعلانهای این رویدادها را دریافت کنید. این مثال هر روش را پیاده سازی می کند:
ad.fullScreenContentCallback = FullScreenContentCallback(
onAdShowedFullScreenContent: (ad) {
// Called when the ad showed the full screen content.
debugPrint('Ad showed full screen content.');
},
onAdFailedToShowFullScreenContent: (ad, err) {
// Called when the ad failed to show full screen content.
debugPrint('Ad failed to show full screen content with error: $err');
// Dispose the ad here to free resources.
ad.dispose();
},
onAdDismissedFullScreenContent: (ad) {
// Called when the ad dismissed full screen content.
debugPrint('Ad was dismissed.');
// Dispose the ad here to free resources.
ad.dispose();
},
onAdImpression: (ad) {
// Called when an impression occurs on the ad.
debugPrint('Ad recorded an impression.');
},
onAdClicked: (ad) {
// Called when a click is recorded for an ad.
debugPrint('Ad was clicked.');
},
);
نمایش یک تبلیغ بینابینی
InterstitialAd
به عنوان یک Overlay
در بالای تمام محتوای برنامه نمایش داده می شود و به صورت ایستا قرار می گیرد. بنابراین، نمی توان آن را به درخت ویجت Flutter اضافه کرد. با فراخوانی show()
میتوانید زمان نمایش آگهی را انتخاب کنید.
_interstitialAd?.show();
هنگامی که show()
فراخوانی شد، Ad
که به این روش نمایش داده میشود نمیتواند از نظر برنامهریزی رد شود و به ورودی کاربر نیاز دارد. یک InterstitialAd
فقط یک بار می تواند نشان داده شود. تماسهای بعدی برای نمایش onAdFailedToShowFullScreenContent
فعال میشوند.
یک آگهی زمانی که دیگر نیازی به دسترسی به آن نیست باید حذف شود. بهترین روش برای زمان فراخوانی dispose()
در FullScreenContentCallback.onAdDismissedFullScreenContent
و FullScreenContentCallback.onAdFailedToShowFullScreenContent
است.
همین! اکنون برنامه شما برای نمایش تبلیغات بینابینی آماده است.
مراحل بعدی
مثال کامل در GitHub
بینابینی
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-23 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-08-23 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eInterstitial ads are full-screen ads displayed at natural transition points in an app, giving users the choice to interact or close them.\u003c/p\u003e\n"],["\u003cp\u003eThis guide provides instructions on integrating interstitial ads into Flutter apps using the google_mobile_ads package.\u003c/p\u003e\n"],["\u003cp\u003eAlways test with dedicated test ad unit IDs provided to avoid account suspension before publishing your app with your own ad unit IDs.\u003c/p\u003e\n"],["\u003cp\u003eUtilize \u003ccode\u003eFullScreenContentCallback\u003c/code\u003e to manage ad lifecycle events like display, dismissal, and errors and to properly dispose of the ad.\u003c/p\u003e\n"],["\u003cp\u003eDisplay the loaded interstitial ad by calling \u003ccode\u003eshow()\u003c/code\u003e, keeping in mind that it can only be shown once and dismissed by user interaction.\u003c/p\u003e\n"]]],["Interstitial ads are full-screen ads shown at natural app transitions. To integrate them into a Flutter app, use test ad unit IDs (Android: `ca-app-pub-3940256099942544/1033173712`, iOS: `ca-app-pub-3940256099942544/4411468910`) during development. Load an ad using `InterstitialAd.load`, handling success or failure. Utilize `FullScreenContentCallback` to manage ad lifecycle events like showing or dismissal. Display the ad with `show()`, noting it's a one-time action. Finally, dispose of the ad in `onAdDismissedFullScreenContent` and `onAdFailedToShowFullScreenContent`.\n"],null,["Select platform: [Android](/admob/android/interstitial \"View this page for the Android platform docs.\") [iOS](/admob/ios/interstitial \"View this page for the iOS platform docs.\") [Unity](/admob/unity/interstitial \"View this page for the Unity platform docs.\") [Flutter](/admob/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 between activities or during the pause between levels in a game. When an\napp shows an interstitial ad, the user has the choice to either tap on the ad\nand continue to its destination or close it and return to the app.\n\nThis guide explains how to integrate interstitial ads into a Flutter app.\n\nAlways test with test ads\n\nWhen building and testing your apps, make sure you use test ads rather than\nlive, production ads. Failure to do so can lead to suspension of your account.\n\nThe easiest way to load test ads is to use our dedicated test ad unit ID for\ninterstitials: \n\nAndroid \n\n ca-app-pub-3940256099942544/1033173712\n\niOS \n\n ca-app-pub-3940256099942544/4411468910\n\nThe test ad units are configured to return test ads for every request, and\nyou're free to use them in your own apps while coding, testing, and debugging.\nJust make sure you replace them with your own ad unit IDs before publishing your\napp.\n\nLoad an ad\n\nThe following example loads an interstitial ad: \n\n```gdscript\nclass InterstitialExampleState extends State\u003cInterstitialExample\u003e {\n InterstitialAd? _interstitialAd;\n\n // TODO: replace this test ad unit with your own ad unit.\n final adUnitId = Platform.isAndroid\n ? 'ca-app-pub-3940256099942544/1033173712'\n : 'ca-app-pub-3940256099942544/4411468910';\n\n /// Loads an interstitial ad.\n void loadAd() {\n InterstitialAd.load(\n adUnitId: adUnitId,\n request: const AdRequest(),\n adLoadCallback: InterstitialAdLoadCallback(\n // Called when an ad is successfully received.\n onAdLoaded: (ad) {\n debugPrint('$ad loaded.');\n // Keep a reference to the ad so you can show it later.\n _interstitialAd = ad;\n },\n // Called when an ad request failed.\n onAdFailedToLoad: (LoadAdError error) {\n debugPrint('InterstitialAd failed to load: $error');\n },\n ));\n }\n}\n```\n\nInterstitial ad events\n\nThrough the use of `FullScreenContentCallback`, you can listen for lifecycle\nevents, such as when the ad is shown or dismissed. Set\n`InterstitialAd.fullScreenContentCallback` before showing the ad to receive\nnotifications for these events. This example implements each method: \n\n```gdscript\nclass InterstitialExampleState extends State\u003cInterstitialExample\u003e {\n InterstitialAd? _interstitialAd;\n\n // TODO: replace this test ad unit with your own ad unit.\n final adUnitId = Platform.isAndroid\n ? 'ca-app-pub-3940256099942544/1033173712'\n : 'ca-app-pub-3940256099942544/4411468910';\n\n /// Loads an interstitial ad.\n void loadAd() {\n InterstitialAd.load(\n adUnitId: adUnitId,\n request: const AdRequest(),\n adLoadCallback: InterstitialAdLoadCallback(\n // Called when an ad is successfully received.\n onAdLoaded: (ad) {\n ad.fullScreenContentCallback = FullScreenContentCallback(\n // Called when the ad showed the full screen content.\n onAdShowedFullScreenContent: (ad) {},\n // Called when an impression occurs on the ad.\n onAdImpression: (ad) {},\n // Called when the ad failed to show full screen content.\n onAdFailedToShowFullScreenContent: (ad, err) {\n // Dispose the ad here to free resources.\n ad.dispose();\n },\n // Called when the ad dismissed full screen content.\n onAdDismissedFullScreenContent: (ad) {\n // Dispose the ad here to free resources.\n ad.dispose();\n },\n // Called when a click is recorded for an ad.\n onAdClicked: (ad) {});\n\n debugPrint('$ad loaded.');\n // Keep a reference to the ad so you can show it later.\n _interstitialAd = ad;\n },\n // Called when an ad request failed.\n onAdFailedToLoad: (LoadAdError error) {\n debugPrint('InterstitialAd failed to load: $error');\n },\n ));\n }\n}\n```\n\nDisplay an interstitial ad\n\nAn `InterstitialAd` is displayed as an [`Overlay`](//api.flutter.dev/flutter/widgets/Overlay-class.html)\non top of all app content and is statically placed; thus, it can't be added to\nthe Flutter widget tree. You can choose when to show the ad by calling `show()`. \n\n```scdoc\n_interstitiaAd.show();\n```\n\nOnce `show()` is called, an `Ad` displayed this way can't be dismissed\nprogrammatically and requires user input. An `InterstitialAd` can only be shown\nonce. Subsequent calls to show will trigger `onAdFailedToShowFullScreenContent`.\n\nAn ad must be disposed when access to it is no longer needed. The best practice\nfor when to call `dispose()` is in the\n`FullScreenContentCallback.onAdDismissedFullScreenContent` and\n`FullScreenContentCallback.onAdFailedToShowFullScreenContent` callbacks.\n\nThat's it! Your app is now ready to display interstitial ads.\n\nNext steps\n\n- See [Interstitial best\n practices](//www.youtube.com/watch?v=r2RgFD3Apyo&index=5&list=PLOU2XLYxmsIKX0pUJV3uqp6N3NeHwHh0c) and [interstitial ad guidance](//support.google.com/admob/answer/6066980).\n- Check out an [Interstitial ads case\n study](//admob.google.com/home/resources/freaking-math-powers-revenue-increase-with-google-admob-support/).\n- If you haven't already, create your own interstitial ad unit in the [AdMob\n UI](//apps.admob.com/).\n\nComplete example on GitHub\n\n[Interstitial](//github.com/googleads/googleads-mobile-flutter/tree/main/samples/admob/interstitial_example)"]]