App open ad
App open ads are a special ad format for monetizing app load screens. These ads can be closed at any time and are designed to be served:
- When the app is launched.
- When the app is brought to the foreground.
- When returning to the app from the background.
This guide covers the process of integrating ads shown when opening an iOS app. Besides code samples and instructions, it contains format-specific recommendations and links to additional resources.
Appearance
App Open Ads include a Go to the app button, which indicates to users that they're currently in your app and can close the ad. Here is an example of what this ad format may look like:
Prerequisite
- Follow the SDK integration steps described under Quick start.
- First, you need to initialize the advertising SDK.
- Make sure you're using the latest version of the Yandex Mobile Ads SDK, and if you're using mediation, the latest version of the unified build.
Terms
- Cold start: Launching the app when it isn't present in RAM, which creates a new app session.
- Hot start: Bringing the app from the background, where it's paused in RAM, into the foreground.
Implementation
- Initialize the SDK on app startup.
- Create and set up the
AppOpenAdLoaderad loader object. - Load an ad.
- Use the AppDelegate class method
applicationDidBecomeActive(_ application: UIApplication)to render ads at app open. - Before rendering the ad, set the
AppOpenAdDelegatead callback method delegate. - Serve the ad using the
showmethod.
Key steps
-
Initialize the SDK on app startup.
// wait for sdk initialization before loading ads YandexAds.initializeSDK(completionHandler: completionHandler) -
Create and set up the
AppOpenAdLoaderad loader object.You'll need the ad placement ID obtained in the Yandex Advertising Network interface (
AD_UNIT_ID).You can expand ad request parameters through
AdRequest, by passing user interests, contextual page data, location, or other additional info. Adding extra context to ad requests can greatly improve ad relevance. To learn more, see Ad targeting.private lazy var appOpenAdLoader: AppOpenAdLoader = { let loader = AppOpenAdLoader() return loader }() -
Load an ad.
Swift ConcurrencyCompletion handlerfunc loadAd() async { // Replace demo-appopenad-yandex with actual Ad Unit ID let request = AdRequest(adUnitID: "demo-appopenad-yandex") do { let ad = try await appOpenAdLoader.loadAd(with: request) appOpenAd = ad appOpenAd?.delegate = self } catch { // Ad failed to load. Attempting to load a new ad from here is strongly discouraged. } }func loadAd() { // Replace demo-appopenad-yandex with actual Ad Unit ID let request = AdRequest(adUnitID: "demo-appopenad-yandex") self.appOpenAdLoader.loadAd(with: request) { [weak self] result in switch result { case .success(let ad): self?.appOpenAd = ad self?.appOpenAd?.delegate = self case .failure: // Ad failed to load. Attempting to load a new ad from here is strongly discouraged. break } } } -
Use the
AppDelegateclass method to display ads when opening it.func applicationDidBecomeActive(_ application: UIApplication) -
Before rendering the ad, set the
AppOpenAdDelegatead callback method delegate.extension AppOpenAdController: AppOpenAdDelegate { func appOpenAd(_ appOpenAd: AppOpenAd, didFailToShow error: Error) { // Called when an ad failed to show. // Load next ad after fail to show with error loadAd() } func appOpenAdDidShow(_ appOpenAd: AppOpenAd) { // Called when ad did shown. } func appOpenAdDidDismiss(_ appOpenAd: AppOpenAd) { // Called when ad is dismissed. // Load next ad after dismiss loadAd() } func appOpenAdDidClick(_ appOpenAd: AppOpenAd) { // Called when a click is recorded for an ad. } func appOpenAd(_ appOpenAd: AppOpenAd, didTrackImpression impressionData: ImpressionData?) { // Called when an impression is recorded for an ad. } } -
Serve the ad using the
showmethod.self.appOpenAd?.show(from: self)Note
If the ad has already been served, calling the
show(from:)method will return a display error inAppOpenAdDelegate.appOpenAd(_:didFailToShowError:).
Features of app open ad integration
- All calls to Yandex Mobile Ads SDK methods must be made from the main thread.
- Ads may take a long time to load, so you should avoid increasing the cold start time if the ad hasn't loaded.
- Preload ads for subsequent hot start impressions in advance.
- We don't recommend loading app open ads simultaneously with other ad formats at app startup, as the app may be downloading essential operational data. Doing so could lead to excessive loads on your device and internet connection, resulting in longer ad load times.
- If an error occurs during loading (case
.failurein the completion handler or thecatchblock in Swift Concurrency), don't attempt to load a new ad. If there's no other option, limit the number of ad load retries. This will help avoid constant unsuccessful requests and connection issues if there are limitations.
Testing App Open Ad integration
Using demo ad units for ad testing
Use test ads to check your ad integration at app launch and during your testing process. To make sure that test ads are returned for each ad request, you can use a special demo ad placement ID.
Demo adUnitId: demo-appopenad-yandex.
Warning
Before publishing your app in the store, make sure to replace the demo placement ID with the real ID you obtained in the Yandex Advertising Network interface.
For the list of all available demo ad placement IDs, see Demo ad units for testing.
Testing ad integration
You can test your ad integration using the native Console tool.
To view detailed logs, call the YandexAds class's enableLogging method.
YandexAds.enableLogging()
To view SDK logs, go to the Console tool and set Subsystem = com.mobile.ads.ads.sdk. You can filter logs by category or error level.
If you're having problems integrating ads, you'll get a detailed report on the issues and recommendations for how to fix them.
Recommendations
-
We don't recommend showing App Open Ads before the app reaches the splash screen.
Showing the splash screen enhances the user experience, making it more intuitive. This way, the user will know that they opened the right app and won't be surprised or confused by the ad. On this screen, you can also warn users about the upcoming ad. To do this, use a loading indicator or a simple text message informing the user that they can continue viewing the app content after the ad.
-
If there's a delay between requesting and rendering the ad, the user might briefly open your app and then unexpectedly see an ad unrelated to the contents. This can negatively impact the user experience, so it's best to avoid such situations. One solution is to show the splash screen before displaying the main app content and to begin ad impressions from that screen. We don't recommend displaying an ad if the app has already opened content after the splash screen.
-
Wait for new users to open the app and use it a few times before starting to serve App Open Ad impressions. Show the ad only to users who meet specific criteria (for example, if they completed a particular level, opened the app a certain number of times, or don't participate in reward offers). We don't recommend displaying an ad immediately after the app is installed.
-
Adjust the frequency of impressions based on user behavior. We don't recommend serving an ad at every cold or hot app start.
-
Display ads only if the app has been running in the background for a certain time (for example, 30 seconds, 2 minutes, or 15 minutes).
-
Be sure to conduct tests, because each app is unique and requires its own approach to maximize revenue without sacrificing user retention or time spent in the app. User behavior and engagement may change over time, so we recommend periodically testing different display strategies for App Open Ads within your app.
Additional resources
- Link to GitHub.