Admob广告没有展示,但玩家获得了奖励

问题描述

我制作了一款游戏,需要玩家在某些级别上完成游戏。我在其中放置了一个按钮,以便您可以通过观看奖励广告来解锁关卡。当我构建它并在我的android手机上运行它时,它没有显示任何广告。当我按下奖励视频按钮时,它没有显示广告,但播放器得到了奖励。我能做什么? 这是我的代码:-

using UnityEngine;
using admob;
using UnityEngine.SceneManagement;
public class AdManager : MonoBehavIoUr
{
    #region variables
    public static AdManager _instance;
    Admob ad;
    public static AdManager Instance
    {
        get
        {
            if (_instance == null)
            {
                _instance = GameObject.FindobjectOfType<AdManager>();
            }
            return _instance;
        }
    }
    string appID = "ca-app-pub-7156785453323105~3470918137";
    string bannerId = "ca-app-pub-7156785453323105/5968432427";
    string interId = "ca-app-pub-7156785453323105/8531673121";
    string rewardId = "ca-app-pub-7156785453323105/2374943403";
    #endregion

    private void Awake()
    {
        Debug.Log("Awake Called");
        initAdmob();
        DontDestroyOnLoad(this);
    }
    public void ShowIntrestialAd()
    {
        if (ad.isInterstitialReady())
        {
            ad.showInterstitial();
        }
        else
        {
            ad.loadInterstitial(interId);
        }
    }
    public void ShowRewardedAd()
    {
        if (ad.isRewardedVideoReady())
        {
            ad.showRewardedVideo();
        }
        else
        {
            ad.loadRewardedVideo(rewardId);
        }
    }
    public void ShowBanner()
    {
        Admob.Instance().showBannerRelative(bannerId,AdSize.SMART_BANNER,AdPosition.TOP_CENTER);
    }
    void onInterstitialEvent(string eventName,string msg)
    {
        Debug.Log("handler onAdmobEvent---" + eventName + "   " + msg);
        if (eventName == AdmobEvent.onAdLoaded)
        {
            Admob.Instance().showInterstitial();
        }
    }
    void onBannerEvent(string eventName,string msg)
    {
        Debug.Log("handler onAdmobBannerEvent---" + eventName + "   " + msg);
    }
    void onRewardedVideoEvent(string eventName,string msg)
    {
        Debug.Log("handler onRewardedVideoEvent---" + eventName + "  rewarded: " + msg);
        int unlockedLevel = PlayerPrefs.GetInt("unlockedLevel",1);
        if(unlockedLevel != 5)
        {
            PlayerPrefs.SetInt("unlockedLevel",unlockedLevel + 1);
        }
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildindex);
    }
    void initAdmob()
    {
#if UNITY_IOS
                // appID="ca-app-pub-3940256099942544~1458002511";
                //  bannerID="ca-app-pub-3940256099942544/2934735716";
                //  interstitialID="ca-app-pub-3940256099942544/4411468910";
                //  videoID="ca-app-pub-3940256099942544/1712485313";
                //  nativeBannerID = "ca-app-pub-3940256099942544/3986624511";
#elif UNITY_ANDROID
        //appID="ca-app-pub-3940256099942544~3347511713";
        // bannerID = "ca-app-pub-3940256099942544/6300978111";
        // interstitialID = "ca-app-pub-3940256099942544/1033173712";
        // videoID = "ca-app-pub-3940256099942544/5224354917";
        // nativeBannerID = "ca-app-pub-3940256099942544/2247696110";
#endif
        AdProperties adProperties = new AdProperties();
        adProperties.isTesting(false);
        adProperties.isAppMuted(true);
        adProperties.isUnderAgeOfConsent(false);
        adProperties.appVolume(100);
        adProperties.maxAdContentrating(AdProperties.maxAdContentrating_G);
        string[] keywords = { "diagram","league","brambling" };
        adProperties.keyworks(keywords);

        ad = Admob.Instance();
        ad.bannerEventHandler += onBannerEvent;
        ad.interstitialEventHandler += onInterstitialEvent;
        ad.rewardedVideoEventHandler += onRewardedVideoEvent;
        ad.initSDK(adProperties);//reqired,adProperties can been null
    }
}

我还导入了admob集成资产。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)