بینابینی پاداشدار نوعی قالب تبلیغاتی است که به شما امکان میدهد برای تبلیغاتی که بهطور خودکار در طول انتقال طبیعی برنامه ظاهر میشوند، پاداش ارائه دهید. برخلاف آگهیهای دارای پاداش، کاربران مجبور نیستند برای مشاهده یک بینابینی دارای پاداش، شرکت کنند. این راهنما نشان میدهد که چگونه میتوان تبلیغات بینستونی با پاداش AdMob را در یک برنامه Flutter ادغام کرد.
پیش نیازها
پلاگین Flutter 1.1.0 یا بالاتر.
شروع را کامل کنید . برنامه Flutter شما از قبل باید افزونه Google Mobile Ads Flutter را وارد کرده باشد.
همیشه با تبلیغات آزمایشی تست کنید
هنگام ساخت و آزمایش برنامه های خود، مطمئن شوید که از تبلیغات آزمایشی به جای تبلیغات زنده و تولیدی استفاده می کنید. عدم انجام این کار می تواند منجر به تعلیق حساب شما شود.
سادهترین راه برای بارگیری آگهیهای آزمایشی، استفاده از شناسه واحد آگهی آزمایشی اختصاصی ما برای آگهیهای بینستونی با پاداش است:
اندروید
ca-app-pub-3940256099942544/5354046379
iOS
ca-app-pub-3940256099942544/6978759866
واحدهای آگهی آزمایشی به گونهای پیکربندی شدهاند که برای هر درخواستی، آگهیهای آزمایشی را برگردانند، و شما میتوانید هنگام کدنویسی، آزمایش و اشکالزدایی از آنها در برنامههای خود استفاده کنید. فقط مطمئن شوید که قبل از انتشار برنامه خود، آنها را با شناسه واحد تبلیغاتی خود جایگزین کنید.
یک تبلیغ را بارگیری کنید
مثال زیر یک تبلیغ بینالمللی با پاداش را بارگیری میکند:
RewardedInterstitialAd.load(adUnitId:"_adUnitId",request:constAdRequest(),rewardedInterstitialAdLoadCallback:RewardedInterstitialAdLoadCallback(onAdLoaded:(RewardedInterstitialAdad){// Called when an ad is successfully received.debugPrint('Ad was loaded.');// Keep a reference to the ad so you can show it later._rewardedInterstitialAd=ad;},onAdFailedToLoad:(LoadAdErrorerror){// Called when an ad request failed.debugPrint('Ad failed to load with error: $error');},),);
_adUnitId با شناسه واحد تبلیغاتی خود جایگزین کنید.
رویدادهای تبلیغاتی بینابینی پاداش
از طریق استفاده از FullScreenContentCallback ، میتوانید به رویدادهای چرخه حیات گوش دهید، مانند زمانی که آگهی نشان داده میشود یا رد میشود. قبل از نمایش آگهی RewardedInterstitialAd.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.');},);
RewardedInterstitialAd به عنوان یک پوشش در بالای تمام محتوای برنامه نمایش داده می شود و به صورت ایستا قرار می گیرد. بنابراین، نمی توان آن را به درخت ویجت Flutter اضافه کرد. با فراخوانی show() میتوانید زمان نمایش آگهی را انتخاب کنید. RewardedInterstitialAd.show() یک OnUserEarnedRewardCallback می گیرد که زمانی که کاربر پاداشی دریافت می کند فراخوانی می شود. حتما این را اجرا کنید و برای تماشای یک تبلیغ به کاربر پاداش دهید.
هنگامی که show() فراخوانی شد، Ad که به این روش نمایش داده میشود نمیتواند از طریق برنامهریزی حذف شود و به ورودی کاربر نیاز دارد. یک RewardedInterstitialAd فقط یک بار می تواند نشان داده شود. تماسهای بعدی برای نمایش onAdFailedToShowFullScreenContent فعال میشوند.
یک آگهی زمانی که دیگر نیازی به دسترسی به آن نیست باید حذف شود. بهترین روش برای زمان فراخوانی dispose() در FullScreenContentCallback.onAdDismissedFullScreenContent و FullScreenContentCallback.onAdFailedToShowFullScreenContent است.
[اختیاری] تأیید اعتبار سمت سرور (SSV) تماس های برگشتی
برنامههایی که به دادههای اضافی در تماسهای تأیید سمت سرور نیاز دارند، باید از ویژگی داده سفارشی تبلیغات پاداش استفاده کنند. هر مقدار رشته تنظیم شده روی یک شیء تبلیغاتی پاداش داده شده به پارامتر query custom_data در SSV ارسال می شود. اگر مقدار داده سفارشی تنظیم نشده باشد، مقدار پارامتر query custom_data در پاسخ تماس SSV وجود نخواهد داشت.
نمونه کد زیر نحوه تنظیم گزینههای SSV را پس از بارگیری تبلیغ بینداستانی با پاداش نشان میدهد:
تاریخ آخرین بهروزرسانی 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\u003eRewarded interstitial ads are incentivized ads that appear automatically during natural app transitions, offering rewards to users without requiring opt-in.\u003c/p\u003e\n"],["\u003cp\u003eBefore displaying a rewarded interstitial ad, ensure you present users with an intro screen providing reward information and a skip option, complying with AdMob policies.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003eRewardedInterstitialAd\u003c/code\u003e object to load and display ads, handling ad events with \u003ccode\u003eFullScreenContentCallback\u003c/code\u003e and rewarding users in the \u003ccode\u003eOnUserEarnedRewardCallback\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAlways test with dedicated test ad unit IDs before publishing your app, replacing them with your own ad unit IDs in the production version.\u003c/p\u003e\n"],["\u003cp\u003eRemember to dispose of the ad properly using the \u003ccode\u003edispose()\u003c/code\u003e method within the appropriate callbacks to free up resources.\u003c/p\u003e\n"]]],["This guide details how to integrate rewarded interstitial ads into a Flutter app using AdMob. Key actions include loading an ad with `RewardedInterstitialAd.load` using a test ad unit ID, ensuring proper ad loading and failure callbacks are defined. Before display, an intro screen with clear reward messaging must be presented. Display the ad with `RewardedInterstitialAd.show`, which triggers a user reward callback. Lifecycle events are monitored via `FullScreenContentCallback`. After ad interaction it should be disposed of properly.\n"],null,["Select platform: [Android](/admob/android/rewarded-interstitial \"View this page for the Android platform docs.\") [iOS](/admob/ios/rewarded-interstitial \"View this page for the iOS platform docs.\") [Unity](/admob/unity/rewarded-interstitial \"View this page for the Unity platform docs.\") [Flutter](/admob/flutter/rewarded-interstitial \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nRewarded interstitial is a type of incentivized ad format that lets you offer\n[rewards](//support.google.com/admob/answer/7313578) for ads that appear\nautomatically during natural app transitions. Unlike rewarded ads, users aren't\nrequired to opt-in to view a rewarded interstitial. This guide shows how to\nintegrate rewarded interstitial ads from AdMob\ninto a Flutter app.\n\nPrerequisites\n\n- Flutter plugin 1.1.0 or higher.\n- Complete [Get Started](/admob/flutter/quick-start). Your Flutter app should already have the Google Mobile Ads Flutter plugin imported.\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\nrewarded interstitial ads: \n\nAndroid \n\n ca-app-pub-3940256099942544/5354046379\n\niOS \n\n ca-app-pub-3940256099942544/6978759866\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\nyour app.\n\nLoad an ad\n\nThe following example loads a rewarded interstitial ad: \n\n RewardedInterstitialAd.load(\n adUnitId: \"\u003cvar translate=\"no\"\u003e_adUnitId\u003c/var\u003e\",\n request: const AdRequest(),\n rewardedInterstitialAdLoadCallback: RewardedInterstitialAdLoadCallback(\n onAdLoaded: (RewardedInterstitialAd ad) {\n // Called when an ad is successfully received.\n debugPrint('Ad was loaded.');\n // Keep a reference to the ad so you can show it later.\n _rewardedInterstitialAd = ad;\n },\n onAdFailedToLoad: (LoadAdError error) {\n // Called when an ad request failed.\n debugPrint('Ad failed to load with error: $error');\n },\n ),\n ); \n https://github.com/googleads/googleads-mobile-flutter/blob/82c58b3202d8b9391e4d3ec39b045032e90cf331/packages/google_mobile_ads/example/lib/snippets/rewarded_interstitial_ad_snippets.dart#L33-L51\n\nReplace \u003cvar translate=\"no\"\u003e_adUnitId\u003c/var\u003e with your own ad unit ID.\n\nRewarded interstitial 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`RewardedInterstitialAd.fullScreenContentCallback` before showing the ad to\nreceive notifications for these events. This example implements each method and\nlogs a message to the console: \n\n ad.fullScreenContentCallback = FullScreenContentCallback(\n onAdShowedFullScreenContent: (ad) {\n // Called when the ad showed the full screen content.\n debugPrint('Ad showed full screen content.');\n },\n onAdFailedToShowFullScreenContent: (ad, err) {\n // Called when the ad failed to show full screen content.\n debugPrint('Ad failed to show full screen content with error: $err');\n // Dispose the ad here to free resources.\n ad.dispose();\n },\n onAdDismissedFullScreenContent: (ad) {\n // Called when the ad dismissed full screen content.\n debugPrint('Ad was dismissed.');\n // Dispose the ad here to free resources.\n ad.dispose();\n },\n onAdImpression: (ad) {\n // Called when an impression occurs on the ad.\n debugPrint('Ad recorded an impression.');\n },\n onAdClicked: (ad) {\n // Called when a click is recorded for an ad.\n debugPrint('Ad was clicked.');\n },\n ); \n https://github.com/googleads/googleads-mobile-flutter/blob/82c58b3202d8b9391e4d3ec39b045032e90cf331/packages/google_mobile_ads/example/lib/snippets/rewarded_interstitial_ad_snippets.dart#L57-L82\n\nDisplay ad **Key Point:** Before displaying a rewarded interstitial ad to users, you must present the user with an intro screen that provides clear reward messaging and an option to skip the ad before it starts. [Learn\n| more](//support.google.com/admob/answer/9884467).\n\nA `RewardedInterstitialAd` is displayed as an Overlay on top of all app content\nand is statically placed; thus, it can't be added to the Flutter widget tree.\nYou can choose when to show the ad by calling `show()`.\n`RewardedInterstitialAd.show()` takes an `OnUserEarnedRewardCallback`, which is\ninvoked when the user earns a reward. Be sure to implement this and reward the\nuser for watching an ad. \n\n _rewardedInterstitialAd?.show(\n onUserEarnedReward: (AdWithoutView view, RewardItem rewardItem) {\n debugPrint('Reward amount: ${rewardItem.amount}');\n },\n ); \n https://github.com/googleads/googleads-mobile-flutter/blob/82c58b3202d8b9391e4d3ec39b045032e90cf331/samples/admob/rewarded_interstitial_example/lib/main.dart#L108-L115\n\nOnce `show()` is called, an `Ad` displayed this way can't be removed\nprogrammatically and requires user input. A `RewardedInterstitialAd` can only\nbe shown once. Subsequent calls to show will trigger\n`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\n\\[Optional\\] Validate server-side verification (SSV) callbacks\n\nApps that require extra data in [server-side verification](/admob/flutter/ssv)\ncallbacks should use the custom data feature of rewarded ads. Any string value\nset on a rewarded ad object is passed to the `custom_data` query parameter of\nthe SSV callback. If no custom data value is set, the `custom_data` query\nparameter value won't be present in the SSV callback.\n\nThe following code sample demonstrates how to set the SSV options after the\nrewarded interstitial ad is loaded: \n\n RewardedInterstitialAd.load(\n adUnitId: \"\u003cvar translate=\"no\"\u003e_adUnitId\u003c/var\u003e\",\n request: AdRequest(),\n rewardedInterstitialAdLoadCallback: RewardedInterstitialAdLoadCallback(\n onAdLoaded: (ad) {\n ServerSideVerificationOptions _options =\n ServerSideVerificationOptions(\n customData: '\u003cvar translate=\"no\"\u003eSAMPLE_CUSTOM_DATA_STRING\u003c/var\u003e');\n ad.setServerSideOptions(_options);\n _rewardedInterstitialAd = ad;\n },\n onAdFailedToLoad: (error) {},\n ),\n ); \n https://github.com/googleads/googleads-mobile-flutter/blob/82c58b3202d8b9391e4d3ec39b045032e90cf331/packages/google_mobile_ads/example/lib/snippets/rewarded_interstitial_ad_snippets.dart#L88-L101\n\nReplace \u003cvar translate=\"no\"\u003eSAMPLE_CUSTOM_DATA_STRING\u003c/var\u003e with your custom data.\n\nComplete example on GitHub\n\n[Rewarded Interstitial](//github.com/googleads/googleads-mobile-flutter/tree/main/samples/admob/rewarded_interstitial_example)"]]