Admob多个问题



我对admob有问题。首先,我添加了测试广告的代码和设置。小横幅出现在顶部,但当我尝试测试间隙时,间隙广告(点击按钮(会出现半秒钟并消失。我什么都试过了,但无能为力。

这是代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class AdManager : MonoBehaviour
{
private BannerView bannerView;
private InterstitialAd interstitial;
[System.Obsolete]
void Start()
{
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(initStatus => { });
this.RequestBanner();
this.RequestInterstitial();
}
private void RequestBanner()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544~3347511713";
#elif UNITY_IPHONE
string adUnitId = "";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
this.bannerView.LoadAd(request);
}

private void RequestInterstitial()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544~3347511713";
#elif UNITY_IPHONE
string adUnitId = "";
#else
string adUnitId = "unexpected_platform";
#endif
// Initialize an InterstitialAd.
this.interstitial = new InterstitialAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
this.interstitial.LoadAd(request);
}
public void Show_InterstitialAd()
{
if (this.interstitial.IsLoaded())
{
this.interstitial.Show();
}
else
{
print("Ad is not show!");
}
}
}

这是统一的设置:在此处输入图像描述在此处输入图像描述

当我点击按钮时,间隙出现0.5秒,然后消失。现在我尝试了我在youtube上看到的几乎所有东西,但都不起作用,作为我的新手,我真的但真的不知道我能做什么。

还有另一个问题,我试图在自己的移动设备上测试我的应用程序,统一测试中会出现顶部的横幅,但当我在设备上安装apk时,什么都没有。我在admob中添加了测试设备,什么都没有。试着采取摇晃的方法来展示横幅,什么都没有。这个广告让我发疯了。

需要帮助!!

谢谢!!!

我终于找到了解决这个问题的方法。有一种方法可以做到。如果你的应用程序没有显示广告,请记住,你必须创建一个空的gameObject,并将admob请求的代码放入其中。所以,无论你想要什么横幅,请记住你需要"请求并加载广告";以及";显示";谷歌有一个代号";你好世界";在github上具有工作功能。

这个youtube视频帮助了我:https://youtu.be/e-q_CPfu0M0

最新更新