React Native 스플래시 광고
스플래시 광고는 앱이 최초 실행될 때, 앱의 로고와 함께 화면 하단에 1초 내외의 짧은 시간동안 보여지는 광고를 말합니다. 앱 기동 시 Adrop SDK의 스플래시 광고 스크린이 가장 먼저 표시되도록 구현하여 자연스럽게 광고를 노출한 후 앱의 메인 화면으로 넘어갑니다.

디바이스별 자세한 사항은 아래 링크를 참고해주세요.
Android 스플래시 규격 확인하기 / iOS 스플래시 규격 확인하기
0 단계: 콘솔에서 광고 유닛 등록하기
Adrop 콘솔에서 팝업 광고 유닛을 생성합니다.

광고 유닛 리스트에서 생성된 유닛 아이디를 복사합니다.

1 단계 : 스플래시 광고 노출하기
Splash
PUBLIC_TEST_UNIT_ID_SPLASH
Step 1. Add resources
Replace your init activity, unit id
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="adrop_splash_ad_next_activity" translatable="false">{your_init_activity}</string> <!-- com.company.app.MainActivity -->
<string name="adrop_splash_ad_unit_id" translatable="false">{your_splash_unit_id}</string> <!-- PUBLIC_TEST_UNIT_ID_SPLASH for test -->
<integer name="adrop_splash_ad_max_timeout">1000</integer> <!-- (optional) default 1s -->
</resources>- values/theme.xml
replace parent to your application theme
<style
name="Theme.App.SplashTheme"
parent="Theme.AppCompat.NoActionBar"/>- values-v31/theme.xml
Add your logo image (288x288) to
drawableand replacewindowSplashScreenAnimatedIconReplace
windowSplashScreenBackgroundto your splash background color
<style "Theme.App.SplashTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">@drawable/your_logo</item>
<item name="windowSplashScreenBackground">#ffffff</item>
<item name="windowSplashScreenAnimationDuration">200</item>
<item name="postSplashScreenTheme">@style/Theme.App.SplashTheme.TranslucentStatus</item>
</style>
<style name="Theme.App.SplashTheme.TranslucentStatus" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
</style>Step 2. Update Androidmanifest.xml
Androidmanifest.xml<application>
...
<activity
android:name="io.adrop.ads.splash.AdropSplashAdActivity"
android:exported="true"
android:theme="@style/Theme.App.SplashTheme"
tools:replace="android:theme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
...
</application>Step 3. Add layout/activity_adrop_splash_ad.xml
layout/activity_adrop_splash_ad.xmlReplace your logo path and background color.
Do not remove
adrop_splash_ad_imageImageView for splash ad
Step 4. run android (debug)
react-native run-android --main-activity io.adrop.ads.splash.AdropSplashAdActivityStep 1. Change LaunchScreen.storyboard
LaunchScreen.storyboardAdd your logo image
Step 2. Update AppDelegate.mm
AppDelegate.mm...
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}
- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {}
...Step 3. Create SceneDelegate
SceneDelegateReplace your logo name, unit id. Customize background color, timeout if you want.
import UIKit
import AdropAds
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }
self.window = UIWindow(windowScene: windowScene)
// 스플래시 광고 요청 전에, Adrop instance를 초기화 해주세요.
// production 배포 시, 'true'를 사용하세요.
// 특정 국가에서 이 SDK를 사용하고 있다면,
// ISO 3166 alpha-2 국가 코드 array를 전달하세요.
// 타겟 링크가 열리는 브라우저 설정이 필요하다면, useInAppBrowser 값을 바꿔주세요.
Adrop.initialize(production: false, targetCountries: [], useInAppBrowser: false);
let splashViewController = AdropSplashAdViewController(unitId: "PUBLIC_TEST_UNIT_ID_SPLASH")
splashViewController.backgroundColor = splashViewController.traitCollection.userInterfaceStyle == .dark ? .black : .white
splashViewController.logoImage = UIImage(named: "splashLogo")
splashViewController.mainViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
splashViewController.delegate = self
self.window?.rootViewController = splashViewController
self.window?.makeKeyAndVisible()
}
...
}Step 4. Update Info.plist
Info.plist...
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
...적용 확인하기
console에서 발급받은 unitId가 한 번이라도 광고요청을 할 경우 성공적으로 연결됩니다.

Last updated