Setting up an App Open Ad - Compose
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:enableAppOpen(placementID: String) in the SDK configuration builder. Passing in the placement ID which will be supplied to you by Content Ignite.
From the UI we can control when the ad is shown by responding to the state updates:
Resuming from background
For this approach we need to listen to application lifecycle callbacks. The recommended approach is to create a class which inherits Application. Then implement both the DefaultLifecycleObserver and Application.ActivityLifecycleCallbacks interfaces.App class implement onCreate() and register the Activity Lifecycle Callbacks:
onStart() which gets called when the app resumes from the background, and we use the CIAppOpenAdManager to show the ad if one is available and otherwise load the ad for the next opportunity.