Quantcast
Channel: Questions in topic: "ads"
Viewing all articles
Browse latest Browse all 1416

Admob setup

$
0
0
Hi guys! I'm new to programming and I'm suffering cause I can't set up AdMob but I followed every step and I don't know what's wrong with this. I have a script but in the game it doesn't show any ads. (Maybe the problem is that I didn't set up the app-ads.txt file but I don't have a website and I think its not a reason to not show ads). I hope somebody can help me. Thanks! Here is the script: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; using GoogleMobileAds.Api; public class AdMobScript : MonoBehaviour { string App_ID = "ca-app-pub-1698739946462575~8377893712"; string Interstitial_AD_ID = "ca-app-pub-1698739946462575/2294032790"; private InterstitialAd interstitial; // Start is called before the first frame update void Start() { MobileAds.Initialize(App_ID); } public void RequestInterstitial() { // Initialize an InterstitialAd. this.interstitial = new InterstitialAd(Interstitial_AD_ID); // Called when an ad request has successfully loaded. this.interstitial.OnAdLoaded += HandleOnAdLoaded; // Called when an ad request failed to load. this.interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad; // Called when an ad is shown. this.interstitial.OnAdOpening += HandleOnAdOpened; // Called when the ad is closed. this.interstitial.OnAdClosed += HandleOnAdClosed; // Called when the ad click caused the user to leave the application. this.interstitial.OnAdLeavingApplication += HandleOnAdLeavingApplication; AdRequest request = new AdRequest.Builder().Build(); this.interstitial.LoadAd(request); } public void ShowInterstitialAd() { if (this.interstitial.IsLoaded()) { this.interstitial.Show(); } } public void HandleOnAdLoaded(object sender, EventArgs args) { MonoBehaviour.print("HandleAdLoaded event received"); } public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { MonoBehaviour.print("HandleFailedToReceiveAd event received with message: " + args.Message); } public void HandleOnAdOpened(object sender, EventArgs args) { MonoBehaviour.print("HandleAdOpened event received"); } public void HandleOnAdClosed(object sender, EventArgs args) { MonoBehaviour.print("HandleAdClosed event received"); } public void HandleOnAdLeavingApplication(object sender, EventArgs args) { MonoBehaviour.print("HandleAdLeavingApplication event received"); } }

Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>