Home
Softono
godot-admob-plugin

godot-admob-plugin

Open source MIT GDScript
574
Stars
43
Forks
16
Issues
8
Watchers
1 week
Last Commit

About godot-admob-plugin

Godot AdMob Plugin provides native AdMob integration for Godot Engine on Android and iOS, supporting both GDScript and C. Developed by Poing Studios, it exposes a MobileAds singleton after enabling the plugin in Project Settings, enabling developers to initialize the AdMob SDK and load various ad formats including app open, banner, interstitial, rewarded, and rewarded interstitial ads. Installation is available through the Godot Asset Store for standard use or manually via downloadable ZIP files from the releases page for specific versions. The plugin handles platform-specific setup automatically, with manual download options available through the Tools menu if automatic dependency installation fails. Developers can request ads with ad unit IDs, handle callbacks for ad loading success or failure, and display ads using straightforward API calls. It is designed for game developers who want to monetize their Godot projects with Google's AdMob advertising platform without writing platform-specific native code. Th

Platforms

Web Self-hosted iOS Android

Languages

GDScript

Godot AdMob Plugin

VersionBadge StarsBadge DiscordBadge LicenseBadge
DownloadsBadge AssetStoreBadge
AndroidBadge iOSBadge GDScriptBadge CSharpBadge

The complete solution for AdMob integration in Godot using GDScript or C#.
Supports Android and iOS natively.

Plugin Usage

🎬 Watch Video Tutorial📖 Read Documentation


📦 Installation📋 Examples🙏 Support

📦 Installation

📥 Godot Asset Store (recommended)

  1. Find the AdMob plugin by Poing Studios \
  2. Click Download and Install.
Manual installation for custom versions
  1. Pick a specific version from tags.
  2. Download the poing-godot-admob-v*.zip file from the assets.
  3. Extract the ZIP file in the root of your project.

⚙️ Post-installation

  1. Enable the plugin in Project → Project Settings → Plugins.
  2. Setup Platform Dependencies:

[!TIP] If the automatic download fails, you can manually trigger it via Project → Tools → AdMob Manager → (Android/iOS) → Download & Install.

🙋‍♂️ How to use

After installation, the MobileAds singleton becomes available in any script.

📋 Examples

🏁Initialize AdMob

GDScript
func _ready() -> void:
    #just need to call once
    MobileAds.initialize()
C#
using PoingStudios.AdMob.Api;

public override void _Ready()
{
    //just need to call once
    MobileAds.Initialize();
}

📱App Open Ads

GDScript

Load

var app_open_ad : AppOpenAd
var app_open_ad_load_callback := AppOpenAdLoadCallback.new()

func _ready():
    app_open_ad_load_callback.on_ad_failed_to_load = on_app_open_ad_failed_to_load
    app_open_ad_load_callback.on_ad_loaded = on_app_open_ad_loaded

# button signal on scene
func _on_load_app_open_pressed() -> void:
    var unit_id : String
    if OS.get_name() == "Android":
        unit_id = "ca-app-pub-3940256099942544/9257395921"
        unit_id = "ca-app-pub-3940256099942544/5575463023"

    AppOpenAdLoader.new().load(unit_id, AdRequest.new(), app_open_ad_load_callback)

func on_app_open_ad_failed_to_load(adError : LoadAdError) -> void:
    print(adError.message)

func on_app_open_ad_loaded(app_open_ad : AppOpenAd) -> void:
    self.app_open_ad = app_open_ad

Show

# button signal on scene
func _on_show_pressed():
    if app_open_ad:
        app_open_ad.show()
C#

Load

using Godot;
using PoingStudios.AdMob.Api;
using PoingStudios.AdMob.Api.Core;
using PoingStudios.AdMob.Api.Listeners;

private AppOpenAd _appOpenAd;

// button signal on scene
private void OnLoadAppOpenPressed()
{
    string unitId = "";
    if (OS.GetName() == "Android")
    {
        unitId = "ca-app-pub-3940256099942544/9257395921";
    }
    else if (OS.GetName() == "iOS")
    {
        unitId = "ca-app-pub-3940256099942544/5575463023";
    }

    new AppOpenAdLoader().Load(unitId, new AdRequest(), new AppOpenAdLoadCallback
    {
        OnAdLoaded = ad => _appOpenAd = ad,
        OnAdFailedToLoad = err => GD.Print(err.Message)
    });
}

Show

// button signal on scene
private void OnShowPressed()
{
    if (_appOpenAd != null)
    {
        _appOpenAd.Show();
    }
}

🎏Banner Ads

GDScript

Load (will automatically show)

# button signal on scene
func _on_load_banner_pressed() -> void:
    var unit_id : String
    if OS.get_name() == "Android":
        unit_id = "ca-app-pub-3940256099942544/6300978111"
    elif OS.get_name() == "iOS":
        unit_id = "ca-app-pub-3940256099942544/2934735716"

    var ad_view := AdView.new(unit_id, AdSize.BANNER, AdPosition.Values.TOP)
    ad_view.load_ad(AdRequest.new())
C#

Load (will automatically show)

using Godot;
using PoingStudios.AdMob.Api;
using PoingStudios.AdMob.Api.Core;

// button signal on scene
private void OnLoadBannerPressed()
{
    string unitId = "";
    if (OS.GetName() == "Android")
    {
        unitId = "ca-app-pub-3940256099942544/6300978111";
    }
    else if (OS.GetName() == "iOS")
    {
        unitId = "ca-app-pub-3940256099942544/2934735716";
    }

    var adView = new AdView(unitId, AdSize.Banner, AdPosition.Top);
    adView.LoadAd(new AdRequest());
}

📺Interstitial Ads

GDScript

Load

var interstitial_ad : InterstitialAd
var interstitial_ad_load_callback := InterstitialAdLoadCallback.new()
func _ready():
    interstitial_ad_load_callback.on_ad_failed_to_load = on_interstitial_ad_failed_to_load
    interstitial_ad_load_callback.on_ad_loaded = on_interstitial_ad_loaded

# button signal on scene
func _on_load_interstitial_pressed() -> void:
    var unit_id : String
    if OS.get_name() == "Android":
        unit_id = "ca-app-pub-3940256099942544/1033173712"
    elif OS.get_name() == "iOS":
        unit_id = "ca-app-pub-3940256099942544/4411468910"

    InterstitialAdLoader.new().load(unit_id, AdRequest.new(), interstitial_ad_load_callback)

func on_interstitial_ad_failed_to_load(adError : LoadAdError) -> void:
    print(adError.message)

func on_interstitial_ad_loaded(interstitial_ad : InterstitialAd) -> void:
    self.interstitial_ad = interstitial_ad

Show

# button signal on scene
func _on_show_pressed():
    if interstitial_ad:
        interstitial_ad.show()
C#

Load

using Godot;
using PoingStudios.AdMob.Api;
using PoingStudios.AdMob.Api.Core;
using PoingStudios.AdMob.Api.Listeners;

private InterstitialAd _interstitialAd;

// button signal on scene
private void OnLoadInterstitialPressed()
{
    string unitId = "";
    if (OS.GetName() == "Android")
    {
        unitId = "ca-app-pub-3940256099942544/1033173712";
    }
    else if (OS.GetName() == "iOS")
    {
        unitId = "ca-app-pub-3940256099942544/4411468910";
    }

    new InterstitialAdLoader().Load(unitId, new AdRequest(), new InterstitialAdLoadCallback
    {
        OnAdLoaded = ad => _interstitialAd = ad,
        OnAdFailedToLoad = err => GD.Print(err.Message)
    });
}

Show

// button signal on scene
private void OnShowPressed()
{
    if (_interstitialAd != null)
    {
        _interstitialAd.Show();
    }
}

🖼️Native Overlay Ads

GDScript

Load

var native_overlay_ad: NativeOverlayAd

# button signal on scene
func _on_load_native_pressed() -> void:
    var unit_id := "ca-app-pub-3940256099942544/2247696110" if OS.get_name() == "Android" else "ca-app-pub-3940256099942544/3986624511"

    var ad_request := AdRequest.new()
    var options := NativeAdOptions.new()

    NativeOverlayAd.load(unit_id, ad_request, options, _on_ad_load_finished)

func _on_ad_load_finished(ad: NativeOverlayAd, error: LoadAdError) -> void:
    if error:
        print("Native ad failed to load: ", error.message)
        return

    native_overlay_ad = ad
    _render_native_ad()

Render

func _render_native_ad() -> void:
    var style := NativeTemplateStyle.new()
    style.template_id = NativeTemplateStyle.MEDIUM
    native_overlay_ad.render_template(style, AdPosition.BOTTOM)
C#

Load

using Godot;
using PoingStudios.AdMob.Api;
using PoingStudios.AdMob.Api.Core;

private NativeOverlayAd _nativeOverlayAd;

// button signal on scene
private void OnLoadNativePressed()
{
    string unitId = OS.GetName() == "Android" 
        ? "ca-app-pub-3940256099942544/2247696110" 
        : "ca-app-pub-3940256099942544/3986624511";

    var adRequest = new AdRequest();
    var options = new NativeAdOptions();

    NativeOverlayAd.Load(unitId, adRequest, options, OnAdLoadFinished);
}

private void OnAdLoadFinished(NativeOverlayAd ad, LoadAdError error)
{
    if (error != null)
    {
        GD.Print("Native ad failed to load: " + error.Message);
        return;
    }

    _nativeOverlayAd = ad;
    RenderNativeAd();
}

Render

private void RenderNativeAd()
{
    var style = new NativeTemplateStyle();
    style.TemplateId = NativeTemplateStyle.Medium;
    _nativeOverlayAd.RenderTemplate(style, AdPosition.Bottom);
}

🎁Rewarded Ads

GDScript

Load

var rewarded_ad : RewardedAd
var rewarded_ad_load_callback := RewardedAdLoadCallback.new()

func _ready():
    rewarded_ad_load_callback.on_ad_failed_to_load = on_rewarded_ad_failed_to_load
    rewarded_ad_load_callback.on_ad_loaded = on_rewarded_ad_loaded

# button signal on scene
func _on_load_rewarded_pressed() -> void:
    var unit_id : String
    if OS.get_name() == "Android":
        unit_id = "ca-app-pub-3940256099942544/5224354917"
    elif OS.get_name() == "iOS":
        unit_id = "ca-app-pub-3940256099942544/1712485313"

    RewardedAdLoader.new().load(unit_id, AdRequest.new(), rewarded_ad_load_callback)

func on_rewarded_ad_failed_to_load(adError : LoadAdError) -> void:
    print(adError.message)

func on_rewarded_ad_loaded(rewarded_ad : RewardedAd) -> void:
    self.rewarded_ad = rewarded_ad

Show

# button signal on scene
func _on_show_pressed():
    if rewarded_ad:
        rewarded_ad.show()
C#

Load

using Godot;
using PoingStudios.AdMob.Api;
using PoingStudios.AdMob.Api.Core;
using PoingStudios.AdMob.Api.Listeners;

private RewardedAd _rewardedAd;

// button signal on scene
private void OnLoadRewardedPressed()
{
    string unitId = "";
    if (OS.GetName() == "Android")
    {
        unitId = "ca-app-pub-3940256099942544/5224354917";
    }
    else if (OS.GetName() == "iOS")
    {
        unitId = "ca-app-pub-3940256099942544/1712485313";
    }

    new RewardedAdLoader().Load(unitId, new AdRequest(), new RewardedAdLoadCallback
    {
        OnAdLoaded = ad => _rewardedAd = ad,
        OnAdFailedToLoad = err => GD.Print(err.Message)
    });
}

Show

// button signal on scene
private void OnShowPressed()
{
    if (_rewardedAd != null)
    {
        _rewardedAd.Show(new OnUserEarnedRewardListener
        {
            OnUserEarnedReward = reward => GD.Print($"Reward: {reward.Amount} {reward.Type}")
        });
    }
}

🎁📺Rewarded Interstitial Ads

GDScript

Load

var rewarded_interstitial_ad : RewardedInterstitialAd
var rewarded_interstitial_ad_load_callback := RewardedInterstitialAdLoadCallback.new()

func _ready():
    rewarded_interstitial_ad_load_callback.on_ad_failed_to_load = on_rewarded_interstitial_ad_failed_to_load
    rewarded_interstitial_ad_load_callback.on_ad_loaded = on_rewarded_interstitial_ad_loaded

# button signal on scene
func _on_load_rewarded_interstitial_pressed() -> void:
    var unit_id : String
    if OS.get_name() == "Android":
        unit_id = "ca-app-pub-3940256099942544/5354046379"
    elif OS.get_name() == "iOS":
        unit_id = "ca-app-pub-3940256099942544/6978759866"

    RewardedInterstitialAdLoader.new().load(unit_id, AdRequest.new(), rewarded_interstitial_ad_load_callback)

func on_rewarded_interstitial_ad_failed_to_load(adError : LoadAdError) -> void:
    print(adError.message)

func on_rewarded_interstitial_ad_loaded(rewarded_interstitial_ad : RewardedInterstitialAd) -> void:
    self.rewarded_interstitial_ad = rewarded_interstitial_ad

Show

# button signal on scene
func _on_show_pressed():
    if rewarded_interstitial_ad:
        rewarded_interstitial_ad.show(on_user_earned_reward_listener)
C#

Load

using Godot;
using PoingStudios.AdMob.Api;
using PoingStudios.AdMob.Api.Core;
using PoingStudios.AdMob.Api.Listeners;

private RewardedInterstitialAd _rewardedInterstitialAd;

// button signal on scene
private void OnLoadRewardedInterstitialPressed()
{
    string unitId = "";
    if (OS.GetName() == "Android")
    {
        unitId = "ca-app-pub-3940256099942544/5354046379";
    }
    else if (OS.GetName() == "iOS")
    {
        unitId = "ca-app-pub-3940256099942544/6978759866";
    }

    new RewardedInterstitialAdLoader().Load(unitId, new AdRequest(), new RewardedInterstitialAdLoadCallback
    {
        OnAdLoaded = ad => _rewardedInterstitialAd = ad,
        OnAdFailedToLoad = err => GD.Print(err.Message)
    });
}

Show

// button signal on scene
private void OnShowPressed()
{
    if (_rewardedInterstitialAd != null)
    {
        _rewardedInterstitialAd.Show(new OnUserEarnedRewardListener
        {
            OnUserEarnedReward = reward => GD.Print($"Reward: {reward.Amount} {reward.Type}")
        });
    }
}

📎 Useful links

📄 Documentation

For complete documentation including mediation setup: Official Documentation.

Alternatively, check AdMob's original docs for Android or iOS.

🙏 Support

If you find our work valuable and would like to support us, consider contributing via these platforms:

PatreonBadge

KofiBadge

PaypalBadge

Your support helps us continue to improve and maintain this plugin. Thank you for being a part of our community!

🆘 Getting help

DiscussionsBadge DiscordHelpBadge

⭐ Star History

If you appreciate our work, don't forget to give us a star on GitHub! ⭐

Star History Chart