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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue