Когда я создаю свое приложение с Unity, все работает нормально.
У меня были сообщения как:
Dummy LoadAd
Но когда я выпускаю свою сборку на моем устройстве, я не получаю никакой рекламы.
Я опубликовал свое приложение в Play Store и протестировал на нескольких устройствах безрезультатно.
Моя версия единства - 2018.3.3f1. И код заблокирован в функциях AdMob.
Это мой код:
//request a banner
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-2202385704427937/3307508552";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
string adUnitId = "unexpected_platform";
#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());
}
//request a interstitial video
public void RequestInterstitial()
{
// These ad units are configured to always serve test ads.
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "ca-app-pub-2202385704427937/1308031170";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/4411468910";
#else
string adUnitId = "unexpected_platform";
#endif
// Clean up interstitial ad before creating a new one.
if (this.interstitial != null)
{
this.interstitial.Destroy();
}
// Create an interstitial.
this.interstitial = new InterstitialAd(adUnitId);
// Register for ad events.
this.interstitial.OnAdLoaded += this.HandleInterstitialLoaded;
this.interstitial.OnAdFailedToLoad +=
this.HandleInterstitialFailedToLoad;
this.interstitial.OnAdOpening += this.HandleInterstitialOpened;
this.interstitial.OnAdClosed += this.HandleInterstitialClosed;
this.interstitial.OnAdLeavingApplication +=
this.HandleInterstitialLeftApplication;
// Load an interstitial ad.
this.interstitial.LoadAd(this.CreateAdRequest());
}
//to show video
public void ShowInterstitial()
{
if (this.interstitial.IsLoaded())
{
this.interstitial.Show();
}
else
{
MonoBehaviour.print("Interstitial is not ready yet");
}
}