Flutter용 인터스티셜 광고 통합
정적 광고와 동영상 포맷을 모두 지원하는 Unity 레벨플레이 SDK를 사용하여 전체 화면 인터스티셜 광고 Flutter 앱에 통합합니다.
읽는 시간 3분최근 업데이트: 9시간 전
레벨플레이 인터스티셜 광고 전체 화면 광고 유닛으로, 일반적으로 앱 라이프사이클 동안 자연스러운 전환 지점에서 게재됩니다. Unity 정적 삽입과 비디오 삽입을 모두 지원합니다.
필수 조건
- 레벨플레이 플러그인을 앱에 올바르게 통합했는지 확인합니다.
- 레벨플레이 초기화 API 사용하여 SDK를 초기화해야 합니다.
- 레벨플레이 대시보드에서 AdUnitID를 찾습니다.
인터스티셜 광고 만들기 및 이벤트 등록
onInitSuccess레벨플레이 SDK는 인터스티셜 광고 활동을 알려주는 여러 이벤트를 발생시킵니다. 이러한 이벤트를 수신하려면 광고 유닛의 리스너를 등록합니다. SDK를 초기화하기 전에 정보를 손실하지 않도록 리스너를 설정해야 합니다.
final LevelPlayInterstitialAd _interstitialAd = LevelPlayInterstitialAd(adUnitId: [YOUR_AD_UNIT]);@overridevoid initState() { super.initState(); _interstitialAd.setListener(this);}
인터스티셜 광고 리스너 설정
광고 전송에 대해 알리기 위해 코드에 를 구현하십시오.
LevelPlayInterstitialAdListener- 권장되는 베스트 프랙티스는 인터스티셜 광고 광고를 로드하기 전에 리스너를 설정하는 것입니다.
- 각 인터스티셜 광고 광고에는 고유한 리스너 구현이 있어야 합니다.
- 콜백은 메인 스레드 실행됩니다.
@override void onAdLoaded(LevelPlayAdInfo adInfo) { // Provided when the ad is successfully loaded } @override void onAdLoadFailed(LevelPlayAdError error) { // Provided when the ad fails to load. 광고 유닛 정보가 포함됩니다. } @override void onAdDisplayed(LevelPlayAdInfo adInfo) { // Provided when the ad is displayed. 이는 노출과 동일합니다. } @override void onAdDisplayFailed(LevelPlayAdError error, LevelPlayAdInfo adInfo) { // Provided when the ad fails to be displayed } @override void onAdClicked(LevelPlayAdInfo adInfo) { // Provided when the user clicks on the ad } @override void onAdClosed(LevelPlayAdInfo adInfo) { // Provided when the ad is closed } @override void onAdInfoChanged(LevelPlayAdInfo adInfo) { // Provided when the ad info is updated. 다른 광고가 로드되었을 때 사용 가능하며 더 높은 CPM/Rate를 포함합니다. }
인터스티셜 광고 로드
인터스티셜 광고를 로드하려면 를 사용합니다.
loadAd_interstitialAd.loadAd();
인터스티셜 광고 표시
showAdonAdLoaded- 공유하는 데 필요한 활동입니다.
- 플레이스먼트를 사용하는 경우 아래의 플레이스먼트 섹션에 표시된 대로 showAd API에서 플레이스먼트 이름을 전달합니다.
- 광고가 사용자 성공적으로 표시되면 로딩 단계를 반복하여 다른 광고를 로드할 수 있습니다.
// Show ad without placement _interstitialAd.showAd(); // Show ad with placement _interstitialAd.showAd(placement: [YOUR_PLACEMENT]);
광고가 준비되었는지 확인
표시 실패를 방지하고 광고가 올바르게 작동했는지 확인하기 위해 다음 API를 사용하여 API를 호출하는 것이 좋습니다.
showAd-
: 광고가 성공적으로 로드되고 광고 유닛이 제한되지 않거나 거짓이면 true를 반환합니다.
isAdReady -
: 유효한 플레이스먼트가 제한되면 true를 반환합니다. 플레이스먼트가 유효하지 않거나 제한이 없는 경우 이 API false를 반환합니다.
isPlacementCapped
// Check that ad is ready and that the placement is not capped if(_interstitialAd.isAdReady() && !LevelPlayInterstitialAd.isPlacementCapped([YOUR_PLACEMENT])) { _interstitialAd.showAd(placement:[YOUR_PLACEMENT]); }
Placements
Unity는 레벨플레이 대시보드에서 인터스티셜 광고의 플레이스먼트 속도 및 한도를 지원합니다.
인터스티셜 광고에 대한 플레이스먼트를 설정한 경우 특정 플레이스먼트에 광고를 게재하려면 메서드를 호출합니다.
showAd// Check that ad is ready and that the placement is not capped if(_interstitialAd.isAdReady() && !LevelPlayInterstitialAd.isPlacementCapped([YOUR_PLACEMENT])) { _interstitialAd.showAd(placement:[YOUR_PLACEMENT]); }
인터스티셜 광고 전체 구현 예시
// Start of the widget...final LevelPlayInterstitialAd _interstitialAd = LevelPlayInterstitialAd(adUnitId: 'YOUR_AD_UNIT_ID'); @override void initState() { super.initState(); _interstitialAd.setListener(this); _interstitialAd.loadAd(); } @override void onAdClicked(LevelPlayAdInfo adInfo) { // Implement your logic here... } @override void onAdClosed(LevelPlayAdInfo adInfo) { // Implement your logic here... } @override void onAdDisplayFailed(LevelPlayAdError error, LevelPlayAdInfo adInfo) { // Implement your logic here... } @override void onAdDisplayed(LevelPlayAdInfo adInfo) { // Implement your logic here... } @override void onAdInfoChanged(LevelPlayAdInfo adInfo) { // Implement your logic here... } @override void onAdLoadFailed(LevelPlayAdError error) { // Implement your logic here... } @override void onAdLoaded(LevelPlayAdInfo adInfo) { // Implement your logic here, for example showing the ad _interstitialAd.showAd(); } // Rest of the widget // End of widget...
레벨플레이 Mediation 데모 앱
통합 데모 애플리케이션 앱에 인터스티셜 광고 광고 유닛 API를 통합하는 방법을 보여 줍니다.
Integration Test Suite와의 연동을 확인합니다.
다음 단계
추가 인터스티셜 광고 광고 네트워크를 연동하거나 추가 광고 형식을 설정 Flutter 연동 가이드를 따르십시오.