Skip to content

poingstudios/godot-admob-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

597 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Godot AdMob Plugin

VersionBadge StarsBadge DiscordBadge LicenseBadge
DownloadsBadge AssetLibraryBadge
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 Library (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();
	}
}

🎁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