无法将Heyzap广告集成到我的Unity应用程序中

时间:2018-04-26 07:24:41

标签: c# unity3d ads heyzap

正如标题所说,我正在尝试将广告包装添加到我的项目中,但我遇到了一些问题:

  • 每当我运行中介套件时, Heyzap Heyzap Cross Promo 网络都会完全集成,所有选项都会被勾选。但是,如果我尝试获取任何类型的添加,它将给我一个NO_FILL错误,我无法显示它。
  • 在初始化广告网络时,do会正确初始化,这样就可以了。
  • 但是,如果我尝试展示广告,请说插页式广告,则会完全失败。

我已经查看了Heyzap提出的示例应用程序here,它完美无缺。我甚至尝试将它放入我自己的项目中,而不是改变任何东西,我遇到了同样的问题。

这是我写的课程:

using Heyzap;
using UnityEngine;

public static class AdManager {
    public static void InitialiseAdNetwork() 
    {
        HeyzapAds.NetworkCallbackListener networkCallbackListener = delegate(string network, string callback) {
            Debug.Log("The " + network + " network has been " + callback);
        };
        HeyzapAds.SetNetworkCallbackListener(networkCallbackListener);
        HeyzapAds.Start("myID", HeyzapAds.FLAG_DISABLE_AUTOMATIC_FETCHING);

        HZInterstitialAd.SetDisplayListener(delegate(string adState, string adTag) {
            Debug.Log("INTERSTITIAL: " + adState + " Tag : " + adTag);
        });
        HZIncentivizedAd.SetDisplayListener(delegate(string adState, string adTag) {
            Debug.Log("INCENTIVIZED: " + adState + " Tag : " + adTag);
        });
    } 
    public static void ShowMediationSuite()
    {
        HeyzapAds.ShowMediationTestSuite();
    }

    public static void ShowInterstitialAd() 
    {
        HZInterstitialAd.Fetch();
    }
}

任何人都可以看到我做错了吗?因为我不能。

1 个答案:

答案 0 :(得分:0)

From your code it looks to me that you are not calling to show the AD, but just fetch the AD. For an interstitial AD, you need to call the following line:

HZInterstitialAd.Show ();

You will only be able to show the AD after a Fetch () call has completed. You can find out when Fetch () has completed successfully by either (1) setting up your delegates to check for it or (2) checking if an AD is available using a method such as HZInterstitialAd.IsAvailable ().

Method (1) - Shows AD immediately after Fetch () has completed - note that this is specific for HeyZap Interstitial ADs and would not work for other AD types (video, etc) or for non-HeyZap networks if you are using mediation:

HZInterstitialAd.SetDisplayListener(delegate(string adState, string adTag) {
    Debug.Log("INTERSTITIAL: " + adState + " Tag : " + adTag);

    if ( adState.Equals("available") ) {
        HZInterstitialAd.Show ();
    }
});

Method (2) - How you do this method really depends on your architecture. For example, you might add a Try method to your AdManager and have the caller decide what to do if an AD is not ready:

public static bool TryShowInterstitialAd() 
{
    if (HZInterstitialAd.IsAvailable ()) {
        HZInterstitialAd.Show ();
        return true;
    }

    return false;
}
相关问题