加日志,在隐藏一次

This commit is contained in:
luojian 2025-09-18 17:37:37 +08:00
parent c89fe09c1a
commit 37e00c0bed
1 changed files with 31 additions and 6 deletions

View File

@ -233,10 +233,33 @@ namespace WZ
// and anchored to the bottom of the screne. // and anchored to the bottom of the screne.
ad.RenderTemplate(style, new AdSize(position.Width, position.Height), position.X, position.Y); ad.RenderTemplate(style, new AdSize(position.Width, position.Height), position.X, position.Y);
var showNativePosition = showingNativeAds[adUnitId];
var lastAdResponseId = lastAd?.GetResponseInfo()?.GetResponseId();
var lastShowAdResponseId = lastShowAd?.GetResponseInfo()?.GetResponseId();
var lastShowAdResponseId2 = showNativePosition?.NativeOverlayAd?.GetResponseInfo()?.GetResponseId();
var showAdResponseId = ad.GetResponseInfo()?.GetResponseId();
LoggerUtils.Debug(
$"[Admob] Native ad ShowAd [showingNativeAds] {adUnitId} , lastAdResponseId = {lastAdResponseId} , lastShowAdResponseId = {lastShowAdResponseId} , lastShowAdResponseId2 = {lastShowAdResponseId2} , showAdResponseId = {showAdResponseId}");
showingNativeAds[adUnitId] = new ShowNativePosition(ad, position); showingNativeAds[adUnitId] = new ShowNativePosition(ad, position);
ad.Show(); ad.Show();
lastAd?.Hide();
lastShowAd?.Hide(); try
{
lastAd?.Hide();
lastShowAd?.Hide();
showNativePosition?.NativeOverlayAd?.Hide();
}
catch (Exception e)
{
LoggerUtils.Error($"[Admob] Native ad Hide fail {adUnitId} , e : {e.Message}");
}
TimingRefresh(adUnitId); TimingRefresh(adUnitId);
} }
} }
@ -365,8 +388,9 @@ namespace WZ
{ {
foreach (var key in showingNativeAds.Keys.ToList()) foreach (var key in showingNativeAds.Keys.ToList())
{ {
LoggerUtils.Debug($"[Admob] Native ad removing NativeAd {adUnitId}"); var ad = showingNativeAds[key].NativeOverlayAd;
showingNativeAds[key].NativeOverlayAd.Hide(); LoggerUtils.Debug($"[Admob] Native ad removing [showingNativeAds] {adUnitId} , ad {ad.GetResponseInfo()?.GetResponseId()}");
ad.Hide();
// 从字典中删除元素 // 从字典中删除元素
showingNativeAds.Remove(key); showingNativeAds.Remove(key);
LoadAd(key); LoadAd(key);
@ -377,8 +401,9 @@ namespace WZ
if (showingNativeAds.TryGetValue(adUnitId, out var tempAd)) if (showingNativeAds.TryGetValue(adUnitId, out var tempAd))
{ {
LoggerUtils.Debug($"[Admob] Native ad removing NativeAd {adUnitId}"); var ad = tempAd.NativeOverlayAd;
tempAd.NativeOverlayAd.Hide(); LoggerUtils.Debug($"[Admob] Native ad removing [showingNativeAds] {adUnitId} , ad {ad.GetResponseInfo()?.GetResponseId()}");
ad.Hide();
showingNativeAds.Remove(adUnitId); showingNativeAds.Remove(adUnitId);
LoadAd(adUnitId); LoadAd(adUnitId);
} }