[null,null,["最后更新时间 (UTC):2025-08-25。"],[[["\u003cp\u003eThis guide provides instructions for integrating rewarded ads from Google Ad Manager into a Flutter application.\u003c/p\u003e\n"],["\u003cp\u003eAlways test with the provided test ad unit ID \u003ccode\u003e/21775744923/example/rewarded\u003c/code\u003e during development to avoid account suspension.\u003c/p\u003e\n"],["\u003cp\u003eLoad a rewarded ad using \u003ccode\u003eRewardedAd.loadWithAdManagerAdRequest\u003c/code\u003e and handle ad events with \u003ccode\u003eFullScreenContentCallback\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eDisplay the rewarded ad using \u003ccode\u003eRewardedAd.show\u003c/code\u003e and reward the user within the \u003ccode\u003eonUserEarnedReward\u003c/code\u003e callback.\u003c/p\u003e\n"],["\u003cp\u003eRemember to dispose of the ad in the \u003ccode\u003eonAdDismissedFullScreenContent\u003c/code\u003e and \u003ccode\u003eonAdFailedToShowFullScreenContent\u003c/code\u003e callbacks.\u003c/p\u003e\n"]]],["This guide details how to integrate rewarded ads into a Flutter app using Ad Manager. Key actions include using the test ad unit ID `/21775744923/example/rewarded` during development, loading ads via `RewardedAd.loadWithAdManagerAdRequest`, and managing ad lifecycle events with `FullScreenContentCallback`. Displaying the ad requires calling `RewardedAd.show()` and implementing `onUserEarnedReward` to reward users. It's crucial to dispose of ads with `dispose()` when they are dismissed or fail to show and replace test IDs before publishing.\n"],null,["# Rewarded\n\nSelect platform: [Android](/ad-manager/mobile-ads-sdk/android/rewarded \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/rewarded \"View this page for the iOS platform docs.\") [Unity](/ad-manager/mobile-ads-sdk/unity/rewarded \"View this page for the Unity platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/flutter/rewarded \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nRewarded ads are ads that users have the option of interacting with [in exchange\nfor in-app rewards](//support.google.com/admanager/answer/7386053). This guide shows\nhow to integrate rewarded ads from Ad Manager into a Flutter app.\n\nAlways test with test ads\n-------------------------\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 ads:\n\n- `/21775744923/example/rewarded`\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----------\n\nThe following example loads a rewarded ad: \n\n RewardedAd.load(\n adUnitId: \"\u003cvar translate=\"no\"\u003e_adUnitId\u003c/var\u003e\",\n request: const AdManagerAdRequest(),\n rewardedAdLoadCallback: RewardedAdLoadCallback(\n onAdLoaded: (RewardedAd 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 _rewardedAd = 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/5dce0f8f948d1fd04a5e156d80ed0ea6e17f837c/packages/google_mobile_ads/example/lib/snippets/rewarded_ad_snippets.dart#L110-L128\n\nReplace \u003cvar translate=\"no\"\u003e_adUnitId\u003c/var\u003e with your own ad unit ID.\n\n### Rewarded 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`RewardedAd.fullScreenContentCallback` before showing the ad to receive\nnotifications for these events. This example implements each method and logs a\nmessage 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/5dce0f8f948d1fd04a5e156d80ed0ea6e17f837c/packages/google_mobile_ads/example/lib/snippets/rewarded_ad_snippets.dart#L56-L81\n\n| **Key Point:** Make sure to implement the `onRewardedAdUserEarnedReward` event to reward the user for watching an ad.\n\nDisplay ad\n----------\n\nA `RewardedAd` is displayed as an Overlay on top of all app content and is\nstatically placed; thus, it can't be added to the Flutter widget tree. You can\nchoose when to show the ad by calling `show()`.\n`RewardedAd.show()` takes an `OnUserEarnedRewardCallback`, which is invoked when\nthe user earns a reward. Be sure to implement this and reward the user for\nwatching an ad. \n\n _rewardedAd?.show(\n onUserEarnedReward:\n (AdWithoutView ad, RewardItem rewardItem) {\n debugPrint(\n 'Reward amount: ${rewardItem.amount}',\n );\n },\n ); \n https://github.com/googleads/googleads-mobile-flutter/blob/5dce0f8f948d1fd04a5e156d80ed0ea6e17f837c/samples/admob/rewarded_example/lib/main.dart#L146-L158\n\nOnce `show()` is called, an `Ad` displayed this way can't be removed\nprogrammatically and requires user input. A `RewardedAd` 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\n\\[Optional\\] Validate server-side verification (SSV) callbacks\n--------------------------------------------------------------\n\nApps that require extra data in [server-side verification](/ad-manager/mobile-ads-sdk/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 ad is loaded: \n\n RewardedAd.load(\n adUnitId: \"\u003cvar translate=\"no\"\u003e_adUnitId\u003c/var\u003e\",\n request: AdManagerAdRequest(),\n rewardedAdLoadCallback: RewardedAdLoadCallback(\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 _rewardedAd = ad;\n },\n onAdFailedToLoad: (error) {},\n ),\n ); \n https://github.com/googleads/googleads-mobile-flutter/blob/5dce0f8f948d1fd04a5e156d80ed0ea6e17f837c/packages/google_mobile_ads/example/lib/snippets/rewarded_ad_snippets.dart#L134-L147\n\nReplace \u003cvar translate=\"no\"\u003eSAMPLE_CUSTOM_DATA_STRING\u003c/var\u003e with your custom data."]]