스플래시 광고는 앱이 시작될 때 스플래시 화면에 표시되는 광고입니다. 앱 로고와 함께 광고가 표시되어 자연스러운 사용자 경험을 제공합니다.
앱 시작 시 자연스러운 광고 노출
앱 로고와 함께 브랜드 이미지 유지
고정 광고 크기: 360dp × 270dp (Android), 360px × 270px (iOS)
이미지 광고 지원
개발 중에는 테스트 유닛 ID를 사용하세요: PUBLIC_TEST_UNIT_ID_SPLASH
구현 방법
Flutter 앱의 스플래시 광고는 네이티브 플랫폼 설정을 통해 구현됩니다. 스플래시 광고는 Flutter 엔진이 완전히 초기화되기 전에 표시되므로, Android와 iOS 네이티브 레벨에서 설정해야 합니다.
Flutter 앱은 Flutter가 로드되기 전에 표시되는 네이티브 스플래시 화면을 사용합니다. Adrop 스플래시 광고는 이 네이티브 스플래시 흐름과 통합됩니다.
Android 설정
1단계: strings.xml 설정
android/app/src/main/res/values/strings.xml에 다음 설정을 추가합니다.
android/app/src/main/res/values/strings.xml
< resources >
<!-- 앱 이름 -->
< string name = "app_name" > My App </ string >
<!-- 스플래시 광고 유닛 ID -->
< string name = "adrop_splash_ad_unit_id" translatable = "false" > YOUR_SPLASH_UNIT_ID </ string >
<!-- 스플래시 종료 후 이동할 Activity -->
< string name = "adrop_splash_ad_next_activity" translatable = "false" > com.yourcompany.yourapp.MainActivity </ string >
</ resources >
테스트 시에는 YOUR_SPLASH_UNIT_ID 대신 PUBLIC_TEST_UNIT_ID_SPLASH를 사용하세요.
2단계: 스플래시 로고 이미지 추가
앱 로고를 android/app/src/main/res/drawable/ 폴더에 추가합니다.
android/app/src/main/res/drawable/splash_logo.png
권장 크기: 288dp × 288dp (@2x: 576px, @3x: 864px)
3단계: AndroidManifest.xml 설정
AdropSplashAdActivity를 런처 액티비티로 설정합니다.
android/app/src/main/AndroidManifest.xml
< manifest xmlns:android = "http://schemas.android.com/apk/res/android" >
< application
android:name = "${applicationName}"
android:label = "@string/app_name"
android:icon = "@mipmap/ic_launcher" >
<!-- 스플래시 광고 Activity -->
< activity
android:name = "io.adrop.ads.splash.AdropSplashAdActivity"
android:theme = "@style/LaunchTheme"
android:exported = "true" >
< intent-filter >
< action android:name = "android.intent.action.MAIN" />
< category android:name = "android.intent.category.LAUNCHER" />
</ intent-filter >
</ activity >
<!-- 메인 Activity (Flutter) -->
< activity
android:name = ".MainActivity"
android:exported = "false"
android:launchMode = "singleTop"
android:taskAffinity = ""
android:theme = "@style/LaunchTheme"
android:configChanges = "orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated = "true"
android:windowSoftInputMode = "adjustResize" >
< meta-data
android:name = "io.flutter.embedding.android.NormalTheme"
android:resource = "@style/NormalTheme" />
</ activity >
</ application >
</ manifest >
AdropSplashAdActivity에는 android:exported="true"가 필수입니다. MainActivity에서 런처 intent-filter를 제거하세요.
4단계: 스플래시 테마 설정
android/app/src/main/res/values/styles.xml에 스플래시 테마를 추가하거나 업데이트합니다.
android/app/src/main/res/values/styles.xml
< resources >
<!-- 스플래시 화면이 있는 런치 테마 -->
< style name = "LaunchTheme" parent = "Theme.SplashScreen" >
< item name = "windowSplashScreenBackground" > @android:color/white </ item >
< item name = "windowSplashScreenAnimatedIcon" > @drawable/splash_logo </ item >
< item name = "postSplashScreenTheme" > @style/NormalTheme </ item >
</ style >
<!-- 일반 테마 -->
< style name = "NormalTheme" parent = "Theme.MaterialComponents.DayNight.NoActionBar" >
< item name = "android:windowBackground" > ?android:colorBackground </ item >
</ style >
</ resources >
5단계: 레이아웃 커스터마이징 (선택사항)
커스텀 레이아웃을 사용하려면 android/app/src/main/res/layout/에 activity_adrop_splash_ad.xml을 생성합니다.
android/app/src/main/res/layout/activity_adrop_splash_ad.xml
<? xml version = "1.0" encoding = "utf-8" ?>
< RelativeLayout
xmlns:android = "http://schemas.android.com/apk/res/android"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:background = "#ffffff"
android:paddingHorizontal = "24dp"
android:fitsSystemWindows = "true" >
<!-- 앱 로고 (중앙) -->
< ImageView
android:src = "@drawable/splash_logo"
android:layout_width = "288dp"
android:layout_height = "288dp"
android:scaleType = "fitXY"
android:layout_centerInParent = "true" />
<!-- 광고 영역 (하단) - 필수 -->
< ImageView
android:id = "@+id/adrop_splash_ad_image"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_centerHorizontal = "true"
android:layout_alignParentBottom = "true" />
</ RelativeLayout >
android:id="@+id/adrop_splash_ad_image"가 있는 ImageView는 필수입니다. 이 뷰에 광고가 표시됩니다.
6단계: 표시 시간 설정 (선택사항)
기본 표시 시간을 변경하려면 android/app/src/main/res/values/integers.xml을 생성합니다.
android/app/src/main/res/values/integers.xml
< resources >
<!-- 광고 요청 타임아웃 (밀리초, 500~3000) -->
< integer name = "adrop_splash_ad_request_timeout" > 1000 </ integer >
<!-- 광고 표시 시간 (밀리초, 500~3000) -->
< integer name = "adrop_splash_ad_max_timeout" > 2000 </ integer >
</ resources >
7단계: AdropSplashAd 리스너 구현 (선택사항)
스플래시 광고 이벤트를 수신하려면 Application 클래스에서 리스너를 설정합니다.
import android.app.Application
import io.adrop.ads.Adrop
import io.adrop.ads.splash.AdropSplashAd
import io.adrop.ads.splash.AdropSplashAdListener
import io.adrop.ads.model.AdropErrorCode
class MainApplication : Application () {
private lateinit var splashAd: AdropSplashAd
override fun onCreate () {
super . onCreate ()
// SDK 초기화
Adrop. initialize ( this , production = false )
// 스플래시 광고 설정
splashAd = AdropSplashAd ( this ) { splashAd ->
// shouldSkip: 스플래시 광고를 건너뛸지 결정
// true를 반환하면 광고를 건너뛰고 바로 메인 화면으로 이동
checkShouldSkipSplash ()
}
splashAd.splashAdListener = object : AdropSplashAdListener {
override fun onAdReceived (ad: AdropSplashAd ) {
println ( "스플래시 광고 수신 성공" )
}
override fun onAdFailedToReceive (ad: AdropSplashAd , errorCode: AdropErrorCode ) {
println ( "스플래시 광고 수신 실패: $errorCode " )
}
override fun onAdImpression (ad: AdropSplashAd ) {
println ( "스플래시 광고 노출" )
}
override fun onAdClose (ad: AdropSplashAd , impressed: Boolean ) {
println ( "스플래시 광고 닫힘 - impressed: $impressed " )
}
}
}
private fun checkShouldSkipSplash (): Boolean {
// 예: 딥링크로 진입하거나 특정 조건에서 스플래시 건너뛰기
return false
}
}
shouldSkip이 true를 반환하면 광고가 로드되지 않고 바로 메인 화면으로 이동합니다.
iOS 설정
1단계: AppDelegate 설정
ios/Runner/AppDelegate.swift를 업데이트하여 스플래시 광고를 표시합니다.
ios/Runner/AppDelegate.swift
import UIKit
import Flutter
import AdropAds
@main
@objc class AppDelegate : FlutterAppDelegate {
var splashAdViewController: AdropSplashAdViewController ?
override func application (
_ application : UIApplication,
didFinishLaunchingWithOptions launchOptions : [UIApplication.LaunchOptionsKey: Any ] ?
) -> Bool {
GeneratedPluginRegistrant. register ( with : self )
// Adrop SDK 초기화
Adrop. initialize ( production : false )
return super . application (application, didFinishLaunchingWithOptions : launchOptions)
}
}
2단계: SceneDelegate 설정 (iOS 13+)
SceneDelegate를 사용하는 앱의 경우 ios/Runner/SceneDelegate.swift를 업데이트합니다.
ios/Runner/SceneDelegate.swift
import UIKit
import Flutter
import AdropAds
class SceneDelegate : UIResponder , UIWindowSceneDelegate {
var window: UIWindow ?
func scene (
_ scene : UIScene,
willConnectTo session : UISceneSession,
options connectionOptions : UIScene.ConnectionOptions
) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow ( windowScene : windowScene)
# if DEBUG
let splashUnitId = "PUBLIC_TEST_UNIT_ID_SPLASH"
# else
let splashUnitId = "YOUR_PRODUCTION_SPLASH_UNIT_ID"
# endif
// 스플래시 광고 뷰 컨트롤러 생성
let splashViewController = AdropSplashAdViewController (
unitId : splashUnitId,
logoImage : UIImage ( named : "splash_logo" )
)
splashViewController. delegate = self
splashViewController. displayDuration = 3.0
window ? . rootViewController = splashViewController
window ? . makeKeyAndVisible ()
}
}
// MARK: - AdropSplashAdDelegate
extension SceneDelegate : AdropSplashAdDelegate {
func onAdClose ( impressed : Bool ) {
print ( "스플래시 광고 닫힘 - impressed: \( impressed ) " )
}
func onAdReceived ( _ ad : AdropSplashAd) {
print ( "스플래시 광고 수신 완료" )
}
func onAdFailedToReceive ( _ ad : AdropSplashAd, _ errorCode : AdropErrorCode) {
print ( "스플래시 광고 수신 실패: \( errorCode ) " )
}
func onAdImpression ( _ ad : AdropSplashAd) {
print ( "스플래시 광고 노출" )
}
}
3단계: 로고 이미지 추가
iOS 에셋에 앱 로고를 추가합니다:
Xcode를 열고 Runner/Assets.xcassets로 이동
splash_logo라는 이름의 새 Image Set 추가
로고 이미지 추가 (@1x, @2x, @3x)
권장 크기: 200×200 ~ 300×300 포인트
4단계: Info.plist 설정 (선택사항)
SceneDelegate를 사용하는 경우 Info.plist에 scene 설정이 있는지 확인합니다:
< key > UIApplicationSceneManifest </ key >
< dict >
< key > UIApplicationSupportsMultipleScenes </ key >
< false />
< key > UISceneConfigurations </ key >
< dict >
< key > UIWindowSceneSessionRoleApplication </ key >
< array >
< dict >
< key > UISceneConfigurationName </ key >
< string > Default Configuration </ string >
< key > UISceneDelegateClassName </ key >
< string > $(PRODUCT_MODULE_NAME).SceneDelegate </ string >
</ dict >
</ array >
</ dict >
</ dict >
AdropSplashAdDelegate
메서드 필수 설명 onAdClose(impressed:)선택 스플래시 광고가 닫힐 때 호출. impressed는 광고가 표시되었는지 여부 onAdReceived(_:)선택 광고 수신 성공 시 호출 onAdFailedToReceive(_:_:)선택 광고 수신 실패 시 호출 onAdImpression(_:)선택 광고 노출 기록 시 호출
모범 사례
1. 적절한 타이머 설정
더 나은 사용자 경험을 위해 합리적인 타임아웃 값을 설정합니다.
<!-- Android: integers.xml -->
< integer name = "adrop_splash_ad_request_timeout" > 1000 </ integer >
< integer name = "adrop_splash_ad_max_timeout" > 2000 </ integer >
// iOS
splashViewController. displayDuration = 3.0
2. 로고 이미지 최적화
로딩 시간을 최소화하기 위해 적절한 크기로 앱 로고를 준비합니다.
Android:
drawable-mdpi/splash_logo.png (192px × 192px)
drawable-hdpi/splash_logo.png (288px × 288px)
drawable-xhdpi/splash_logo.png (384px × 384px)
drawable-xxhdpi/splash_logo.png (576px × 576px)
drawable-xxxhdpi/splash_logo.png (768px × 768px)
iOS:
splash_logo@1x.png (200px × 200px)
splash_logo@2x.png (400px × 400px)
splash_logo@3x.png (600px × 600px)
3. 실패 처리
광고 로딩이 실패해도 앱이 정상적으로 시작되도록 합니다.
func onAdFailedToReceive ( _ ad : AdropSplashAd, _ errorCode : AdropErrorCode) {
print ( "광고 로드 실패: \( errorCode ) " )
// AdropSplashAdViewController가 자동으로 onAdClose 호출
}
4. 테스트/프로덕션 환경 구분
# if DEBUG
let splashUnitId = "PUBLIC_TEST_UNIT_ID_SPLASH"
let isProduction = false
# else
let splashUnitId = "YOUR_PRODUCTION_SPLASH_UNIT_ID"
let isProduction = true
# endif
Adrop. initialize ( production : isProduction)
테스트
테스트 유닛 ID
개발 중에는 테스트 유닛 ID를 사용합니다.
PUBLIC_TEST_UNIT_ID_SPLASH
프로덕션 릴리스에는 반드시 Adrop 콘솔에서 생성한 실제 유닛 ID를 사용하세요. 테스트 유닛 ID로는 광고 수익이 발생하지 않습니다.
문제 해결
스플래시 화면이 표시되지 않음 (Android)
AndroidManifest.xml에서 AdropSplashAdActivity가 LAUNCHER로 설정되어 있는지 확인
android:exported="true" 설정 확인
SDK 초기화가 완료되었는지 확인
adrop_service.json이 android/app/src/main/assets 폴더에 있는지 확인
window.rootViewController가 올바르게 설정되어 있는지 확인
Info.plist에 SceneDelegate가 설정되어 있는지 확인
SDK 초기화가 완료되었는지 확인
adrop_service.json이 Xcode 프로젝트에 추가되어 있는지 확인
네트워크 연결 상태 확인
유닛 ID가 올바른지 확인
테스트 환경에서 production: false 설정 확인
onAdFailedToReceive의 에러 코드 확인
adrop_splash_ad_next_activity가 올바르게 설정되어 있는지 확인 (Android)
onAdClose 델리게이트 구현 확인 (iOS)
FlutterViewController가 제대로 생성되었는지 확인
커스텀 레이아웃이 적용되지 않음 (Android)
파일 이름이 정확히 activity_adrop_splash_ad.xml인지 확인
@+id/adrop_splash_ad_image ID가 있는 ImageView가 있는지 확인
클린 빌드 후 다시 실행 (Build > Clean Project > Rebuild)
다음 단계