跳转到内容

Interstitial Ads

此内容尚不支持你的语言。

Loading an Interstitial Ad

The following code shows you how to attach listeners and load the first interstitial ad:

const INTERSTITIAL_AD_UNIT_IDS = {
"android" : "«Android-ad-unit-ID»",
"ios" : "«iOS-ad-unit-ID»"
}
func _initialize_interstitial_ads():
var platform = OS.get_name().to_lower() # "android", "ios", etc.
var ad_unit_id = adUnitsDict.get(platform)
var inter_listener = AppLovinMAX.InterstitialAdEventListener.new()
inter_listener.on_ad_loaded = Callable(self, "_on_interstitial_ad_loaded")
inter_listener.on_ad_load_failed = Callable(self, "_on_interstitial_ad_load_failed")
inter_listener.on_ad_displayed = Callable(self, "_on_interstitial_ad_displayed")
inter_listener.on_ad_display_failed = Callable(self, "_on_interstitial_ad_display_failed")
inter_listener.on_ad_clicked = Callable(self, "_on_interstitial_ad_clicked")
inter_listener.on_ad_hidden = Callable(self, "_on_interstitial_ad_hidden")
AppLovinMAX.set_interstitial_ad_listener(inter_listener)
func _load_interstitial_ad():
var platform = OS.get_name().to_lower() # "android", "ios", etc.
var ad_unit_id = adUnitsDict.get(platform)
AppLovinMAX.load_interstitial_ad(ad_unit_id)
### Interstitial Ad Callbacks
func _on_interstitial_ad_loaded(ad_unit_id: String, ad_info: AppLovinMAX.AdInfo):
# Interstitial ad is ready to be shown. AppLovinMAX.isRewardedAdReady(ad_unit_id) will now return 'true'
print("Interstitial ad loaded from" + ad_info.network_name)
func _on_interstitial_ad_load_failed(ad_unit_id: String, errorInfo: AppLovinMAX.ErrorInfo):
func _on_interstitial_ad_displayed(ad_unit_id: String, ad_info: AppLovinMAX.AdInfo):
func _on_interstitial_ad_display_failed(ad_unit_id: String, errorInfo: AppLovinMAX.ErrorInfo, ad_info: AppLovinMAX.AdInfo):
func _on_interstitial_ad_clicked(ad_unit_id: String, ad_info: AppLovinMAX.AdInfo):
func _on_interstitial_ad_hidden(ad_unit_id: String, ad_info: AppLovinMAX.AdInfo):

Showing an Interstitial Ad

To show an interstitial ad, call show_interstitial_ad():

var platform = OS.get_name().to_lower() # "android", "ios", etc.
var ad_unit_id = INTERSTITIAL_AD_UNIT_IDS.get(platform)
if AppLovinMAX.is_interstitial_ready(ad_unit_id):
AppLovinMAX.show_interstitial_ad(ad_unit_id)