native 多次调用show的定时刷新问题
This commit is contained in:
parent
7af1810cf9
commit
d453b7b73d
|
@ -27,6 +27,7 @@ namespace WZ
|
|||
private Dictionary<string, int> _retryCounters = new Dictionary<string, int>();
|
||||
private Dictionary<string, float> _adStartLoadTimes = new Dictionary<string, float>();
|
||||
private Dictionary<string, ShowNativePosition> showingNativeAds = new();
|
||||
private Dictionary<string, bool> TimingRefreshDict = new();
|
||||
|
||||
public void InitializeAdUnits(List<string> adUnitIds)
|
||||
{
|
||||
|
@ -143,8 +144,8 @@ namespace WZ
|
|||
ad.OnAdPaid += (AdValue adValue) =>
|
||||
{
|
||||
LoggerUtils.Debug($"[Admob] Native ad paid {adValue.Value} {adValue.CurrencyCode}.");
|
||||
AdmobAdsManager.Instance.TrackAdImpression(ad?.GetResponseInfo()?.GetLoadedAdapterResponseInfo().AdSourceName??"",
|
||||
ad?.GetResponseInfo()?.GetLoadedAdapterResponseInfo().AdSourceInstanceId??"",
|
||||
AdmobAdsManager.Instance.TrackAdImpression(ad?.GetResponseInfo()?.GetLoadedAdapterResponseInfo().AdSourceName ?? "",
|
||||
ad?.GetResponseInfo()?.GetLoadedAdapterResponseInfo().AdSourceInstanceId ?? "",
|
||||
adValue,
|
||||
AdsType.Native,
|
||||
adUnitId);
|
||||
|
@ -275,6 +276,16 @@ namespace WZ
|
|||
|
||||
private void TimingRefresh(string adUnitId)
|
||||
{
|
||||
// 同一个id只允许触发一次定时刷新。 避免多次调用show ,多次来触发刷新
|
||||
if (TimingRefreshDict.TryGetValue(adUnitId, out var timingRefresh))
|
||||
{
|
||||
if (timingRefresh)
|
||||
{
|
||||
LoggerUtils.Debug($"[Admob] Native ad ({adUnitId}) timing refresh finished. 正在刷新中.不用重复刷新.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var nativeReflashGap = int.Parse(FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("Native_Reflash_Gap", "0"));
|
||||
|
||||
if (nativeReflashGap <= 0)
|
||||
|
@ -295,10 +306,15 @@ namespace WZ
|
|||
return;
|
||||
}
|
||||
|
||||
LoggerUtils.Debug($"[Admob] Native ad ({adUnitId}) timing refresh start. nativeReflashGap = {nativeReflashGap}");
|
||||
|
||||
TimingRefreshDict.AddIfNotExists(adUnitId, true);
|
||||
|
||||
WLoom.QueueOnMainThread(o =>
|
||||
{
|
||||
var refreshAdUnitId = (string)o;
|
||||
LoggerUtils.Debug($"[Admob] Native ad ({adUnitId}) timing refresh load start refreshAdUnitId : {refreshAdUnitId}.");
|
||||
var remove = TimingRefreshDict.Remove(refreshAdUnitId);
|
||||
LoggerUtils.Debug($"[Admob] Native ad ({adUnitId}) timing refresh load start refreshAdUnitId : {refreshAdUnitId}. TimingRefreshDict.Remove = {remove}");
|
||||
if (showingNativeAds.ContainsKey(refreshAdUnitId))
|
||||
{
|
||||
LoadAd(refreshAdUnitId, true);
|
||||
|
@ -332,10 +348,10 @@ namespace WZ
|
|||
public string GetHighestPayingAdUnit()
|
||||
{
|
||||
return _adRevenueCache
|
||||
.Where(kvp => IsAdAvailable(kvp.Key))
|
||||
.OrderByDescending(kvp => kvp.Value)
|
||||
.Select(kvp => kvp.Key)
|
||||
.FirstOrDefault();
|
||||
.Where(kvp => IsAdAvailable(kvp.Key))
|
||||
.OrderByDescending(kvp => kvp.Value)
|
||||
.Select(kvp => kvp.Key)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
// 获取价格最高的广告收益信息
|
||||
|
|
Loading…
Reference in New Issue