Godot all in one ads module for Android. (Customizable)
Godot all in one ads module for Android. (Customizable)
If you are using goodt 2.X copy build.gradle.template
and AndroidManifest.xml.template
from godot 3.1 (master branch) into $(GODOT_2_ROOT)/platform/android/
,
cd ${GODOT_ROOT}/modules/
git clone https://github.com/FrogSquare/GodotAds GodotAds
git clone https://github.com/FrogSquare/GodotSql GodotSql
and you must configure your module by editing ${GODOT_ROOT}/modules/GodotAds/config.py
build = {
"admob" : True, # add org/godotengine/godot/AdMob to the engine.cfg
"adcolony" : True, # add org/godotengine/godot/GDAdColony to the engine.cfg
"chartboost" : True, # add org/godotengine/godot/GDChartboost to the engine.cfg
"vungle" : True, # add org/godotengine/godot/GDVungle to the engine.cfg
"mopub" : True, # add org/godotengine/godot/GDMopub to the engine.cfg
"unity_ads" : True, # add org/godotengine/godot/GDUnityAds to the engine.cfg
}
sdk and dependency for (Chartboost and Vungle)
Download the sdk to ${GODOT_ROOT}/modules/GodotAds/libs/
Chartboost: Chartboost SDk Vungle: Vungle SDK UnityAds: Unity-ads SDK
[android]
modules="org/godotengine/godot/GodotAds,org/godotengine/godot/AdMob,org/godotengine/godot/GDAdColony,org/godotengine/godot/GDChartboost,org/godotengine/godot/GDVungle,org/godotengine/godot/GDMopub,org/godotengine/godot/GDUnityAds"
var gdads = Globals.get_singleton("GodotAds")
gdads.init(get_instance_ID())
gdads.set_debug(boolean) # set true for logs
var gdads = Engine.get_singleton("GodotAds")
gdads.init(get_instance_id())
calling init()
on GodotAds
is optional.
Initialize AdMob
var AdMob = Globals.get_singleton("AdMob")
var _dict = Dictionary()
_dict["BannerAd"] = false
_dict["InterstitialAd"] = false
_dict["RewardedVideoAd"] = false
_dict["BannerGravity"] = "BOTTOM" # or TOP
_dict["BannerAdId"] = "your banner ad id"
_dict["InterstitialAdId"] = "your interstitial ad id"
_dict["RewardedVideoAdId"] = "rewarded video ad id"
AdMob.init(_dict, get_instance_ID())
Initialize AdColony
var AdColony = Globals.get_singleton("GDAdColony")
var _dict = Dictionary()
_dict["app_id"] = "adcolotn app id"
_dict["zone_ids"] = "adcolony interstitial zone ids" # (e.g) "jkedbciujdcoidcj,iyhfecujncuofevef,ikyvejcnilnuvel"
_dict["reward_ids"] = "adcolony rewarded zone id" # (e.g) "jkedbciujdcoidcj,iyhfecujncuofevef,ikyvejcnilnuvel"
_dict["dialog"] = true # or false
AdColony.init(_dict, get_instance_ID())
Initialize Chartboost
var Chartboost = Globals.get_singleton("GDChartboost")
var _dict = Dictionary()
_dict["app_id"] = "Your chartboost app id"
_dict["app_signature"] = "your chartboost signature"
Chartboost.init(_dict, get_instance_ID())
Initialize Vungle
var Vungle = Globals.get_singleton("GDVungle")
var _dict = Dictionary()
_dict["app_id"] = "your vungle app"
Vungle.init(_dict, get_instance_ID())
Initialize MoPub
var Mopub = Globals.get_singleton("GDMopub")
var _dict = Dictionary()
_dict["BannerAd"] = true
_dict["InterstitialAd"] = true
_dict["BannerGravity"] = "BOTTOM" # or TOP
_dict["BannerAdId"] = "your banner unit id"
_dict["InterstitialAdId"] = "your interstitial unit id"
Mopub.init(_dict, get_instance_ID())
Initialize UnityAds
var Unityads = Globals.get_singleton("GDUnityAds")
var _dict = Dictionary()
_dict["GameId"] = "Your game ID"
Unityads.init(_dict, get_instance_ID())
adding the callback funtion so we can recive event log/states from the module
func _receive_message (tag, from, key, value):
if tag == "GodotAds" and from == "AdMob":
if key == "AdMob_Banner" and value == "loaded":
# Show banner here.
AdMob
AdMob.show_banner_ad(true) # show banner ad
AdMob.show_banner_ad(false) # hide banner ad
AdMob.show_interstitial_ad() # Show Interstitial Ad
AdMob.show_rewarded_video() # Show Rewarded Ad
AdMob.is_rewarded_video_loaded()
AdColony
AdColony.show(String zone_id) # Show AdColony for the zone id
Chartboost
Chartboost.show_interstitial_ad()
Chartboost.show_rewarded_video()
Vungle
Vungle.show()
MoPub
AdMob.show_banner_ad(true) # show banner ad
AdMob.show_banner_ad(false) # hide banner ad
AdMob.show_interstitial_ad() # Show Interstitial Ad
Unity Ads
Unityads.show("Location id")
adb -d logcat godot:V GoogleService:V FrogSquare:V DEBUG:V AndroidRuntime:V ValidateServiceOp:V *:S