- Home /
my admob banner not showing,
i just want to request banner, this my script
private BannerView bannerView;
private AdRequest CreateAdRequest()
{
return new AdRequest.Builder()
.Build();
}
public void RequestBanner()
{
// These ad units are configured to always serve test ads.
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "ca-app-pub-3879637095276799/8119636209";
#endif
// Clean up banner ad before creating a new one.
if (this.bannerView != null)
{
this.bannerView.Destroy();
}
// Create a 320x50 banner at the top of the screen.
this.bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Top);
// Register for ad events.
this.bannerView.OnAdLoaded += this.HandleAdLoaded;
this.bannerView.OnAdFailedToLoad += this.HandleAdFailedToLoad;
this.bannerView.OnAdOpening += this.HandleAdOpened;
this.bannerView.OnAdClosed += this.HandleAdClosed;
this.bannerView.OnAdLeavingApplication += this.HandleAdLeftApplication;
// Load a banner ad.
this.bannerView.LoadAd(this.CreateAdRequest());
bannerView.Show();
}
#region Banner callback handlers
public void HandleAdLoaded(object sender, EventArgs args)
{
MonoBehaviour.print("HandleAdLoaded event received");
}
public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
MonoBehaviour.print("HandleFailedToReceiveAd event received with message: " + args.Message);
}
public void HandleAdOpened(object sender, EventArgs args)
{
MonoBehaviour.print("HandleAdOpened event received");
}
public void HandleAdClosed(object sender, EventArgs args)
{
MonoBehaviour.print("HandleAdClosed event received");
}
public void HandleAdLeftApplication(object sender, EventArgs args)
{
MonoBehaviour.print("HandleAdLeftApplication event received");
}
#endregion
i have download plugin and anything, but still not showing,, maybe can you give me a simple project in which there is a plugin, simple script to request banner, I've tried to solve this problem in two days, but still can't work, pleae help,,,,
Answer by Grish_tad · Dec 21, 2018 at 08:39 AM
hi @WhisperXD you need to use testAds for testing ads before publishing.
private AdRequest CreateAdRequest()
{
return new AdRequest.Builder()
.AddTestDevice("[your device id]")
.Build();
}
for more see here
Your answer
Follow this Question
Related Questions
Google Mobile Ads Interstitial ads is not showing in unity 2 Answers
Do Dummy notifications mean admob ads will load when launched? 0 Answers
Admob Banner Ads not shown but are clickable 1 Answer
Google Unity AdMob Plugin doesn't support custom position for banners 0 Answers
Admob banner drops fps from 60 to 40 3 Answers