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, int> _retryCounters = new Dictionary<string, int>();
|
||||||
private Dictionary<string, float> _adStartLoadTimes = new Dictionary<string, float>();
|
private Dictionary<string, float> _adStartLoadTimes = new Dictionary<string, float>();
|
||||||
private Dictionary<string, ShowNativePosition> showingNativeAds = new();
|
private Dictionary<string, ShowNativePosition> showingNativeAds = new();
|
||||||
|
private Dictionary<string, bool> TimingRefreshDict = new();
|
||||||
|
|
||||||
public void InitializeAdUnits(List<string> adUnitIds)
|
public void InitializeAdUnits(List<string> adUnitIds)
|
||||||
{
|
{
|
||||||
|
@ -143,8 +144,8 @@ namespace WZ
|
||||||
ad.OnAdPaid += (AdValue adValue) =>
|
ad.OnAdPaid += (AdValue adValue) =>
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[Admob] Native ad paid {adValue.Value} {adValue.CurrencyCode}.");
|
LoggerUtils.Debug($"[Admob] Native ad paid {adValue.Value} {adValue.CurrencyCode}.");
|
||||||
AdmobAdsManager.Instance.TrackAdImpression(ad?.GetResponseInfo()?.GetLoadedAdapterResponseInfo().AdSourceName??"",
|
AdmobAdsManager.Instance.TrackAdImpression(ad?.GetResponseInfo()?.GetLoadedAdapterResponseInfo().AdSourceName ?? "",
|
||||||
ad?.GetResponseInfo()?.GetLoadedAdapterResponseInfo().AdSourceInstanceId??"",
|
ad?.GetResponseInfo()?.GetLoadedAdapterResponseInfo().AdSourceInstanceId ?? "",
|
||||||
adValue,
|
adValue,
|
||||||
AdsType.Native,
|
AdsType.Native,
|
||||||
adUnitId);
|
adUnitId);
|
||||||
|
@ -275,6 +276,16 @@ namespace WZ
|
||||||
|
|
||||||
private void TimingRefresh(string adUnitId)
|
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"));
|
var nativeReflashGap = int.Parse(FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("Native_Reflash_Gap", "0"));
|
||||||
|
|
||||||
if (nativeReflashGap <= 0)
|
if (nativeReflashGap <= 0)
|
||||||
|
@ -295,10 +306,15 @@ namespace WZ
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoggerUtils.Debug($"[Admob] Native ad ({adUnitId}) timing refresh start. nativeReflashGap = {nativeReflashGap}");
|
||||||
|
|
||||||
|
TimingRefreshDict.AddIfNotExists(adUnitId, true);
|
||||||
|
|
||||||
WLoom.QueueOnMainThread(o =>
|
WLoom.QueueOnMainThread(o =>
|
||||||
{
|
{
|
||||||
var refreshAdUnitId = (string)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))
|
if (showingNativeAds.ContainsKey(refreshAdUnitId))
|
||||||
{
|
{
|
||||||
LoadAd(refreshAdUnitId, true);
|
LoadAd(refreshAdUnitId, true);
|
||||||
|
|
Loading…
Reference in New Issue