팝업 지면은 전면광고와 유사하게 앱을 완전히 덮으면서 노출됩니다. 팝업 지면은 위치에 따라 하단, 중앙 두가지 타입의 UI를 제공하고 있어 원하는 기획에 맞게 선택하여 연동할 수 있습니다.
다음 가이드를 통해 서비스에 팝업 광고를 적용할 수 있습니다.
final AdropPopupListener listener = AdropPopupListener(
onAdReceived: (ad) =>
debugPrint('Adrop Popup 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'),
onAdClicked: (ad) ({
ad.dispose();
}),
...
);
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'),
),
),
);
}
}
AdropRewardedView에 더 이상 액세스할 필요가 없으면 다음과 같이 Dispose해야 합니다.
@override
void dispose() {
super.dispose();
popupAd.dispose();
}
console에서 발급받은 unitId가 한 번이라도 request 가 들어가면 성공적으로 연결됩니다.