我想用官方包(版本 5.4.0,unity 版本为 2019.4.14)将谷歌广告实现到我的统一应用程序中:
https ://github.com/googleads/googleads-mobile-unity/releases
当我运行项目时在编辑器中,会显示测试广告。但是当我构建应用程序并将其安装在我的手机上时,它没有显示任何内容(我的 WiFi 连接良好并且我可以访问 Google 服务)。
我的广告经理:
using System;
using System.Collections;
using UnityEngine;
using GoogleMobileAds.Api;
public class AdsManager : MonoBehaviour
{
private static readonly string appId = "ca-app-pub-3940256099942544/3419835294";
private static readonly string bannerId = "ca-app-pub-3940256099942544/6300978111";
private static readonly string interstitialId = "ca-app-pub-3940256099942544/1033173712";
private static readonly string rewardedId = "ca-app-pub-3940256099942544/5224354917";
private static readonly string rewardedInterstitialId = "ca-app-pub-3940256099942544/5354046379";
private static readonly string nativeId = "ca-app-pub-3940256099942544/2247696110";
private InterstitialAd interstitialAd;
void Start()
{
MobileAds.Initialize(InitializationStatus => {});
this.RequestInterstitial();
}
public AdRequest CreateAdRequest() {
return new AdRequest.Builder().Build();
}
public void RequestInterstitial() {
Debug.Log("Requesting interstitial ad");
if(this.interstitialAd != null) {
this.interstitialAd.Destroy();
};
this.interstitialAd = new InterstitialAd(interstitialId);
this.interstitialAd.OnAdClosed += HandleOnInterstitialAdClosed;
this.interstitialAd.LoadAd(this.CreateAdRequest());
ShowInterstitial();
}
public void ShowInterstitial() {
if(this.interstitialAd.IsLoaded()) {
this.interstitialAd.Show();
} else {
this.RequestInterstitial();
}
}
public void HandleOnInterstitialAdClosed(object sender, EventArgs args)
{
Debug.Log("Closed interstitial ad");
}
}
我尝试使用 Android LogCat,但没有找到任何提及“请求插页式广告”的内容。我在编辑器中得到了这个日志,并且显示了测试广告。知道是什么问题吗?
谢谢