Display splash ad on Apple

A splash ad refers to an advertisement that is displayed along with the app's logo for a short period of about 1 second when the app is first launched. Implement the Adrop SDK's splash ad screen to be the first screen displayed when the app starts, seamlessly exposing the ad before transitioning to the app's main screen. The size of the splash ad is 360px x 270px.


Step 1. Change LaunchScreen.storyboard

Add your logo image. We recommend a height of 180px for the area containing the logo image

Step 2. Update AppDelegate

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
    return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
}

Step 3. Create SceneDelegate

Replace 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) {
        guard let windowScene = (scene as? UIWindowScene) else { return }
        
        self.window = UIWindow(windowScene: windowScene)
        
        let splashViewController = AdropSplashViewController(unitId: "PUBLIC_TEST_UNIT_ID_SPLASH")
        splashViewController.backgroundColor = splashViewController.traitCollection.userInterfaceStyle == .dark ? .black : .white
        splashViewController.logoImage = UIImage(named: "your_logo_name")
        splashViewController.mainViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
        splashViewController.timeout = 0.5
        splashViewController.delegate = self
        
        self.window?.rootViewController = splashViewController
        self.window?.makeKeyAndVisible()
    }

    func sceneDidDisconnect(_ scene: UIScene) {}
    func sceneDidBecomeActive(_ scene: UIScene) {}
    func sceneWillResignActive(_ scene: UIScene) {}
    func sceneWillEnterForeground(_ scene: UIScene) {}
    func sceneDidEnterBackground(_ scene: UIScene) {}
}

extension SceneDelegate: AdropSplashAdDelegate {
    func onAdReceived(_ ad: AdropAds.AdropSplashAd) {
        print("onAdReceived \(ad.unitId)")
    }
    
    func onAdFailedToReceive(_ ad: AdropAds.AdropSplashAd, _ errorCode: AdropAds.AdropErrorCode) {
        print("onAdFailedToReceive: \(ad.unitId) error: \(AdropErrorCodeToString(code: errorCode))")
    }
    
    func onAdImpression(_ ad: AdropSplashAd) {
        print("onAdImpression: \(ad.unitId)")
    }
}

Step 4. Update 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>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
                <key>UISceneStoryboardFile</key>
                <string>Main</string>
            </dict>
        </array>
    </dict>
</dict>
...

Last updated