의견을 공유하고 Google 모바일 광고 SDK 로드맵을 구성하는 데 참여해 주세요. 2023년 5월 5일에 종료되기 전에 2023년 Google 모바일 광고 SDK 연례 설문조사에 참여하세요.

리워드 제공됨

컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.

보상형 광고는 상호작용하는 사용자에게 인앱 리워드를 제공하는 광고입니다. 이 가이드에는 Ad Manager 의 보상형 광고를 Flutter 앱에 통합하는 방법이 나와 있습니다.

항상 테스트 광고로 테스트

앱을 제작하고 테스트할 때는 운영 중인 실제 광고가 아닌 테스트 광고를 사용해야 합니다. 이렇게 하지 않으면 계정이 정지될 수 있습니다.

테스트 광고를 로드하는 가장 쉬운 방법은 보상형 광고의 테스트 전용 광고 단위 ID를 사용하는 것입니다.

  • /6499/example/rewarded

테스트 광고 단위는 모든 요청에 대해 테스트 광고를 반환하도록 구성되며 코딩, 테스트 및 디버깅 중에 앱에서 자유롭게 사용할 수 있습니다. 앱을 게시하기 전에 이 ID를 자체 광고 단위 ID로 바꿔야 합니다.

광고 로드

다음은 보상형 광고를 로드하는 예입니다.

class RewardedExampleState extends State<RewardedExample> {
  RewardedAd? _rewardedAd;

  // TODO: replace this test ad unit with your own ad unit.
  final adUnitId = '/6499/example/rewarded';

  /// Loads a rewarded ad.
  void loadAd() {
    RewardedAd.loadWithAdManagerAdRequest(
        adUnitId: adUnitId,
        adManagerAdRequest: const AdManagerAdRequest(),
        adLoadCallback: RewardedAdLoadCallback(
          // Called when an ad is successfully received.
          onAdLoaded: (ad) {
            debugPrint('$ad loaded.');
            // Keep a reference to the ad so you can show it later.
            _rewardedAd = ad;
          },
          // Called when an ad request failed.
          onAdFailedToLoad: (LoadAdError error) {
            debugPrint('RewardedAd failed to load: $error');
          },
        ));
  }
}

보상형 광고 이벤트

FullScreenContentCallback를 사용하면 광고 게재 또는 닫기 시점과 같은 수명 주기 이벤트를 수신할 수 있습니다. 이러한 이벤트에 대한 알림을 받으려면 광고를 게재하기 전에 RewardedAd.fullScreenContentCallback를 설정하세요. 이 예에서는 각 메서드를 구현하고 콘솔에 메시지를 기록합니다.

class RewardedExampleState extends State<RewardedExample> {
  RewardedAd? _rewardedAd;

  // TODO: replace this test ad unit with your own ad unit.
  final adUnitId = '/6499/example/rewarded';

  /// Loads a rewarded ad.
  void loadAd() {
    RewardedAd.loadWithAdManagerAdRequest(
        adUnitId: adUnitId,
        adManagerAdRequest: const AdManagerAdRequest(),
        adLoadCallback: RewardedAdLoadCallback(
          // 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.
            _rewardedAd = ad;
          },
          // Called when an ad request failed.
          onAdFailedToLoad: (LoadAdError error) {
            debugPrint('RewardedAd failed to load: $error');
          },
        ));
  }
}

디스플레이 광고

RewardedAd는 모든 앱 콘텐츠 위에 오버레이로 표시되며 정적으로 배치되므로 Flutter 위젯 트리에 추가할 수 없습니다. show()를 호출하여 광고를 표시할 시기를 선택할 수 있습니다. RewardedAd.show()는 사용자가 보상을 획득할 때 호출되는 OnUserEarnedRewardCallback를 사용합니다. 이를 구현하고 사용자에게 광고 시청에 대한 보상을 제공해야 합니다.

_rewardedAd.show(onUserEarnedReward: (AdWithoutView ad, RewardItem rewardItem) {
  // Reward the user for watching an ad.
});

show()가 호출되면 이 방식으로 표시된 Ad는 프로그래매틱 방식으로 삭제할 수 없으며 사용자의 입력이 필요합니다. RewardedAd는 한 번만 표시할 수 있습니다. 이후 표시할 호출은 onAdFailedToShowFullScreenContent를 트리거합니다.

광고에 더 이상 액세스할 필요가 없는 경우 삭제해야 합니다. dispose()를 호출하기 위한 권장사항은 FullScreenContentCallback.onAdDismissedFullScreenContentFullScreenContentCallback.onAdFailedToShowFullScreenContent 콜백에 있는 것입니다.

이제 완료됐습니다. 이제 앱에서 보상형 광고를 게재할 수 있습니다.