c# - 无法将 Heyzap 广告集成到我的 Unity 应用程序中
问题描述
正如标题所说,我正在尝试将广告包装器添加到我的项目中,但遇到了一些问题:
- 每当我运行中介套件时,Heyzap和Heyzap Cross Promo网络都已完全集成,所有选项都已勾选。但是,如果我尝试获取任何类型的添加,它会给我一个 NO_FILL 错误,我无法显示它。
- 初始化广告网络后,确实会正确初始化,这样就可以了。
- 但是,如果我尝试展示广告,比如interstitial,它将完全失败。
我已经检查了Heyzap 在这里放置的示例应用程序,它运行良好。我什至试着把它放到我自己的项目中,没有改变任何东西,我也遇到了同样的问题。
这是我写的课程:
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();
}
}
谁能看到我做错了什么?因为我不可以。
解决方案
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;
}
推荐阅读
- python - 如何将特定索引的列表元素更改为在列表列表中浮动(Python)?
- android - 如何检测一个奇怪的 android 天真的内存泄漏?
- django - 如何在颤动中上传图像
- android - 如何使用编辑文本和跨度制作文本编辑器?
- spring - 通过 https 调用我的应用程序是否会在运行时覆盖 SessionCreationPolicy?
- swift - 如何在我的 swift 项目中访问目标 c Pods 文件中声明为类扩展的方法?
- ios - 在 Swift 中按键和值对数组字典进行排序
- javascript - 想要在共享的谷歌电子表格的每个活动表上运行相同的脚本
- spring-security - 当仅应用 authenticated() 检查时,此 Spring Security antMatcher 配置是否应用于多个 URL 冗余?
- java - Maven 构建在 Flex PMD 报告报告生成阶段失败