보상형 전면 광고는 일종의 인센티브형 광고 형식으로, 리워드 적용 자연스러운 앱 전환 중에 자동으로 맞춤설정할 수 있습니다 보상형 광고와 달리 사용자는 수신 동의하지 않고도 보상형 전면 광고를 볼 수 있습니다. 이 가이드에서는 Ad Manager의 보상형 전면 광고 통합 구현해 보겠습니다.
기본 요건
- Flutter 플러그인 1.1.0 이상
- 시작하기를 모두 읽어보세요. 내 Flutter 앱에 이미 Google 모바일 광고 Flutter 플러그인이 있어야 합니다. 가져온 것입니다.
항상 테스트 광고로 테스트
앱을 빌드하고 테스트할 때는 만들 수 있습니다. 이렇게 하지 않으면 계정이 정지될 수 있습니다.
테스트 광고를 로드하는 가장 쉬운 방법은 보상형 전면 광고:
/21775744923/example/rewarded-interstitial
테스트 광고 단위는 모든 요청에 대해 테스트 광고를 반환하도록 구성되어 있습니다. 코딩, 테스트 및 디버깅 중에 앱에서 자유롭게 사용할 수 있습니다. 앱을 게시하기 전에 이 테스트 광고 단위 ID를 자체 광고 단위 ID로 바꿔야 합니다.
광고 로드
다음 예에서는 보상형 전면 광고를 로드합니다.
class RewardedInterstitialExampleState extends State<RewardedInterstitialExample> { RewardedInterstitialAd? _rewardeInterstitialdAd; // TODO: replace this test ad unit with your own ad unit. final adUnitId = '/21775744923/example/rewarded-interstitial'; /// Loads a rewarded ad. void loadAd() { RewardedInterstitialAd.loadWithAdManagerAdRequest( adUnitId: adUnitId, adManagerAdRequest: const AdManagerAdRequest(), adLoadCallback: RewardedInterstitialAdLoadCallback( // Called when an ad is successfully received. onAdLoaded: (ad) { debugPrint('$ad loaded.'); // Keep a reference to the ad so you can show it later. _rewardedInterstitialAd = ad; }, // Called when an ad request failed. onAdFailedToLoad: (LoadAdError error) { debugPrint('RewardedInterstitialAd failed to load: $error'); }, )); } }
보상형 전면 광고 이벤트
FullScreenContentCallback
를 사용하면 수명 주기를 수신 대기할 수 있습니다.
광고가 게재되거나 닫힐 때와 같은 이벤트가 있을 수 있습니다. 이러한 이벤트에 대한 알림을 받으려면 광고를 게재하기 전에 RewardedInterstitialAd.fullScreenContentCallback
을 설정하세요. 이 예에서는 각 메서드를 구현하고 콘솔에 메시지를 기록합니다.
class RewardedInterstitialExampleState extends State<RewardedInterstitialExample> { RewardedInterstitialAd? _rewardedInterstitialAd; // TODO: replace this test ad unit with your own ad unit. final adUnitId = '/21775744923/example/rewarded-interstitial'; /// Loads a rewarded ad. void loadAd() { RewardedInterstitialAd.loadWithAdManagerAdRequest( adUnitId: adUnitId, adManagerAdRequest: const AdManagerAdRequest(), adLoadCallback: RewardedInterstitialAdLoadCallback( // Called when an ad is successfully received. onAdLoaded: (ad) { ad.fullScreenContentCallback = FullScreenContentCallback( // Called when the ad showed the full screen content. onAdShowedFullScreenContent: (ad) {}, // Called when an impression occurs on the ad. onAdImpression: (ad) {}, // Called when the ad failed to show full screen content. onAdFailedToShowFullScreenContent: (ad, err) { // Dispose the ad here to free resources. ad.dispose(); }, // Called when the ad dismissed full screen content. onAdDismissedFullScreenContent: (ad) { // Dispose the ad here to free resources. ad.dispose(); }, // Called when a click is recorded for an ad. onAdClicked: (ad) {}); debugPrint('$ad loaded.'); // Keep a reference to the ad so you can show it later. _rewardedInterstitialAd = ad; }, // Called when an ad request failed. onAdFailedToLoad: (LoadAdError error) { debugprint('RewardedInterstitialAd failed to load: $error'); }, )); } }
디스플레이 광고
RewardedInterstitialAd
는 모든 앱 콘텐츠 위에 오버레이로 표시됩니다.
정적으로 배치됩니다. 따라서 Flutter 위젯 트리에 추가할 수 없습니다.
show()
를 호출하여 광고 게재 시기를 선택할 수 있습니다.
RewardedInterstitialAd.show()
는 OnUserEarnedRewardCallback
를 사용합니다.
사용자가 리워드를 받으면 호출됩니다. 이 이벤트를 구현하고 사용자에게 광고 시청에 대한 보상을 제공해야 합니다.
_rewardedInterstitialAd.show(onUserEarnedReward: (AdWithoutView ad, RewardItem rewardItem) { // Reward the user for watching an ad. });
show()
가 호출되면 이 방식으로 표시된 Ad
는 삭제할 수 없습니다.
사용자 입력이 필요합니다. RewardedInterstitialAd
는
한 번 표시됩니다. 이후 표시할 호출이 트리거됩니다.
onAdFailedToShowFullScreenContent
더 이상 액세스할 필요가 없는 광고는 폐기해야 합니다. 권장사항
dispose()
호출 시점은
FullScreenContentCallback.onAdDismissedFullScreenContent
및
FullScreenContentCallback.onAdFailedToShowFullScreenContent
콜백
작업이 끝났습니다. 이제 앱에서 보상형 전면 광고를 표시할 준비가 되었습니다.