admob.*

Type Library
Revision Release 2024.3703
Keywords ads, advertising, AdMob
Platforms Android, iOS

Overview

The AdMob plugin allows developers to monetize users through AdMob static interstitial ads, video interstitial ads, rewarded video ads, and banner ads.

Important

Check out new hasUserConsent admob.load() parameter to enable GDPR data collection restrictions.

The new UMP/CMP apis updateConsentForm, loadConsentForm, showConsentForm, and getConsentFormStatus are only available on Solar2D Sim 2023.3686+

Registration

Before you can use this plugin, you must register with AdMob.

Syntax

local admob = require( "plugin.admob" )

Functions

Events

Project Settings

To use this plugin, add an entry into the plugins table of build.settings. When added, the build server will integrate the plugin during the build phase.

settings =
{
    android =
    {
        applicationChildElements =
        {
            [[
                <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="[YOUR_ADMOB_APP_ID]"/>  -- replace with your app id. See: https://goo.gl/fQ2neu
            ]],
        },
    },
    iphone =
    {
        plist = {
            GADApplicationIdentifier = "[YOUR_ADMOB_APP_ID]",
            SKAdNetworkItems = {
                {
                    SKAdNetworkIdentifier = "cstr6suwn9.skadnetwork",
                },
            },
        },
    },
    plugins =
    {
        ["plugin.admob"] =
        {
            publisherId = "com.coronalabs"
        },
        -- See: http://docs.coronalabs.com/plugin/att
    },
}
Important

Add App Tracking Transparency plugin to your project as well.

Important

If you are building for Android, you should remove any legacy inclusion of the ["plugin.google.play.services"] plugin from your build.settings.

Note

For Android, the following permissions/features are automatically added when using this plugin:

  • "android.permission.INTERNET"
  • "android.permission.ACCESS_NETWORK_STATE"

Google AdMob Mediation setup

AdMob plugin can be used to serve ads from other networks to give your monetization a boost on Android.

To use this feature, you would have to connect each individual network manually using AdMob interface. List of available networks with links to set up instructions can be found here.

Most of the networks would have "Import the SDK and adapter" step. To implement it, add Gradle dependencies to special file corona.gradle within AndroidResource directory inside your Solar2D Project.

For example, to use Facebook and AppLoving networks contents of the AndroidResources/corona.gradle file should be:

dependencies {
    implementation 'com.google.ads.mediation:facebook:6.2.0.0'
    implementation 'com.google.ads.mediation:applovin:9.14.5.0'
}

Sample project