Flutter 팝업 광고

1

Unit ID 설정하기

Ad type
Ad unit ID

Popup (bottom)

PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM

Popup Video (bottom 16:9)

PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM_VIDEO_16_9

Popup Video (bottom 9:16)

PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM_VIDEO_9_16

Popup (center)

PUBLIC_TEST_UNIT_ID_POPUP_CENTER

Popup Video (center 16:9)

PUBLIC_TEST_UNIT_ID_POPUP_CENTER_VIDEO_16_9

Popup Video (center 9:16)

PUBLIC_TEST_UNIT_ID_POPUP_CENTER_VIDEO_9_16

2

팝업 광고 구현하기

class YourComponent extends StatefulWidget {
  const YourComponent({super.key});

  @override
  State<StatefulWidget> createState() => _YourComponentState();
}

class _YourComponentState extends State<YourComponent> {
  final AdropPopupAd rewardedAd = AdropPopupAd(
    // 0 단계에서 복사한 UNIT_ID를 입력해주세요. 테스트를 원한다면, 가이드 위의 테스트 유닛 아이디를 사용해 주세요.
    unitId: 'YOUR_UNIT_ID or TEST_UNIT_ID', 
    listener: listener,
    closeTextColor: your_color        // optional Color
    hideForTodayTextColor: your_color // optional Color
    backgroundColor: your_color       // optional Color
  );

  @override
  void initState() {
    super.initState();
    popupAd.load();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: TextButton(
          onPressed: () {
            final isLoaded = popupAd.isLoaded ?? false;
            if (isLoaded) {
              popupAd.show();
            } else {
              ScaffoldMessenger.of(context).showSnackBar(
                const SnackBar(content: Text('popup ad is loading...'))
              );
            }
          },
          child: const Text('display ad'),
        ),
      ),
    );
  }
}

Last updated