Setting up an App Open Ad
App Open Ads have two possible flows designed to be used together: Cold start and Resuming from background.Cold start (Splash screen)
The first approach allows you monetise the loading screen of your app. When the user opens the app, the splash screen is displayed. While your app is loading, our SDK will load an Ad. If the ad is loaded in time you can control whether the ad is displayed before the home screen of your app is displayed. The example below is taken from our demo app:- In this simple example, we use a
SplashStateenumeration to communicate our state changes back to the UI, here this is done using a callback. - In our ViewModel we store an instance of
CIAppOpenAdManager. - Enabling App Open ads is achieved by using
enableAppOpen(placementID: String)in the SDK configuration builder. Passing in the placement ID which will be supplied to you by Content Ignite. - In this example we use a simple timeout to simulate the loading of the app and attempt to load an ad before the timeout is reached.
- Calling the
show()method onCIAppOpenManagerto show the ad.
AppRouter, an ObservableObject which in this example holds a variable to track if the splash screen has been completed, which is updated by calling `navigateToHome():
Resuming from background
For this approach we need to listen to the application ScenePhase. To achieve this, we use a property wrapper inside theApp class. Additionally we the AppRouter we saw earlier to update the view hierarchy: