Flutter 전면 광고
전면 광고는 사용자 기기 화면의 전체에 보여지는 광고입니다. 일반적으로 화면의 전환, 혹은 특정이벤트 발생 후 자연스럽게 광고가 노출됩니다. 전면광고가 노출 될 때 사용자는 광고를 탭하여 대상으로 이동하거나 광고를 다고 앱으로 돌아갈 수 있습니다.
다음 가이드를 통해 서비스에 전면광고를 적용할 수 있습니다.
이미 등록된 광고 유닛이 있다면 1단계 부터 진행하세요.
0 단계: 콘솔에서 광고 유닛 등록하기
Adrop 콘솔에서 전면 광고 유닛을 생성합니다.
광고 유닛 리스트에서 생성된 유닛 아이디를 복사합니다.
1 단계: (선택 사항) 이벤트 리스너 선언하기
final AdropInterstitialListener listener = AdropInterstitialListener(
onAdReceived: (ad) =>
debugPrint('Adrop Interstitial Ad loaded with unitId ${ad.unitId}!'),
onAdFailedToReceive: (ad, errorCode) =>
debugPrint('error in ${ad.unitId} while loading: $errorCode'),
onAdFailedToShowFullScreen: (ad, errorCode) =>
debugPrint('error in ${ad.unitId} while showing: $errorCode'),
...
);
2단계: 전면 광고 노출하기
Ad type
Ad unit ID
Interstitial
PUBLIC_TEST_UNIT_ID_INTERSTITIAL
class YourComponent extends StatefulWidget {
const YourComponent({super.key});
@override
State<StatefulWidget> createState() => _YourComponentState();
}
class _YourComponentState extends State<YourComponent> {
final AdropInterstitialAd interstitialAd = AdropInterstitialAd(
// 0 단계에서 복사한 UNIT_ID를 입력해주세요. 테스트를 원한다면, 가이드 위의 테스트 유닛 아이디를 사용해 주세요.
unitId: 'YOUR_UNIT_ID or TEST_UNIT_ID',
listener: listener,
);
@override
void initState() {
super.initState();
interstitialAd.load();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: TextButton(
onPressed: () {
final isLoaded = interstitialAd.isLoaded ?? false;
if (isLoaded) {
interstitialAd.show();
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('interstitial ad is loading...'))
);
}
},
child: const Text('display ad'),
),
),
);
}
}
전면 광고 Dispose
AdropInterstitialView에 더 이상 액세스할 필요가 없으면 다음과 같이 Dispose해야 합니다.
@override
void dispose() {
super.dispose();
interstitialAd.dispose();
}
console에서 발급받은 unitId가 한 번이라도 request 가 들어가면 성공적으로 연결됩니다.

Last updated