Cognito KMM Template
  • Welcome
  • Getting Started
    • Quickstart: Getting Started
    • Prerequisites
    • Installation
    • Creating New App
  • Architecture
    • Overview
    • Modules
    • Data Flow
  • Feautures
    • Http Client
    • DataStore
    • Analytics
    • AdMob Integration
    • Crash Reporting
    • Built in Settings Page
  • Handle View States
    • StatelessSurface<T> Composable
    • Handle a screen with 3 states
  • Sequential Content with IndefiniteSurface
  • Handle multiple predefined states
  • Showing Paginated Data
  • Handling list data
Powered by GitBook
On this page
  1. Feautures

AdMob Integration

shared/src/commonMain/kotlin/modules/common/ads/ads.kt

Integrating AdMob with Your Application

Overview:

This document outlines the steps involved in integrating AdMob into your KMM application to display interstitial ads.

Prerequisites:

  • A Google AdMob account is required.

  • A KMM project set up.

  • The google-services.json file provided by Google placed in the root directory of your Android application module.

Integration:

  1. Ad Unit ID: Obtain the Ad Unit ID from your AdMob account and store it in Credentials file shared/src/commonMain/kotlin/configs/Credentials.kt.

  2. AdMob Implementation:

    • Create a composable function that utilizes the interstitialAd function:

    Kotlin

    @Composable
    fun ShowInterstitialAd() {
        val ad = interstitialAd(adUnitId)
    
        ad.show()
    }
  3. interstitialAd Function:

    • The interstitialAd function is defined in the shared/src/commonMain/kotlin/modules/common/ads/ads.kt file.

    • It's responsible for creating and handling the interstitial ad.

    • The specific implementation might vary depending on the AdMob library you're using, but it typically involves:

      • Creating an interstitial ad object.

      • Loading the ad.

      • Showing the ad when ready.

      • Handling ad events (e.g., impression, click, close).

Additional Considerations:

  • Refer to the AdMob documentation for detailed information on specific implementation steps and best practices.

  • Test your AdMob integration thoroughly to ensure proper ad display and tracking.

By following these steps and leveraging the interstitialAd function, you can effectively integrate AdMob into your KMM application to display interstitial ads and generate revenue.

PreviousAnalyticsNextCrash Reporting

Last updated 8 months ago