AdMob ad don't show(unity)

此生再无相见时 提交于 2020-12-13 04:20:37

问题


When I am using unity, the console shows Dummy LoadAD, Dummy Show, etc. But when I test it on my phone it does show any AD. I set these two functions on two-button. bannerAD button does not show bannerAD. videoAD button will close my app

There's my code

using UnityEngine;
using GoogleMobileAds.Api;
using System;
using UnityEngine.UI;


public class admanageger : MonoBehaviour
{
    public Text adstatus;
    BannerView bannerView;
    RewardedAd rewardedAd;
    string appID = "ca-app-pub-#####~#####";
    // Start is called before the first frame update
    private void Awake()
    {

    }
    void Start()
    {
         MobileAds.Initialize(appID);

    }
    public void showbannerAD()
{
#if UNITY_ANDROID
        string adUnitId = "ca-app-pub-####/####";
#elif UNITY_IPHONE
            string adUnitId = "ca-app-pub-###/#####";
#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);
    }
    public void showvideoAD()
    {
#if UNITY_ANDROID
            string adUnitId = "ca-app-pub-#####/####";
#elif UNITY_IPHONE
            string adUnitId = "ca-app-pub-#####/#####";
#else
            string adUnitId = "unexpected_platform";
#endif
            this.rewardedAd = new RewardedAd(adUnitId);

            // Create an empty ad request.
            AdRequest request = new AdRequest.Builder().Build();
        // Load the rewarded ad with the request.
         this.rewardedAd.LoadAd(request);
        this.rewardedAd.Show();

    }
}

Am I do something wrong or and setting need about Admob?


回答1:


AdMob won't show any ads on Unity Editor. You should always test your Ad related stuff by building and testing on your phone.



来源:https://stackoverflow.com/questions/63578879/admob-ad-dont-showunity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!