native广告关闭不掉问题

竞价插屏不受规则影响
This commit is contained in:
玉峰 2025-09-12 15:56:39 +08:00
parent 5c63386e36
commit d5ed16b469
6 changed files with 33 additions and 7 deletions

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using GoogleMobileAds.Api; using GoogleMobileAds.Api;
@ -328,7 +329,7 @@ namespace WZ
public void RemoveNative(string adUnitId) public void RemoveNative(string adUnitId)
{ {
_admobNativeAdManager.RemoveNative(adUnitId); StartCoroutine(_admobNativeAdManager.RemoveNative(adUnitId));
} }
public double GetNativeRevenue(string adUnitId) public double GetNativeRevenue(string adUnitId)

View File

@ -44,6 +44,8 @@ namespace WZ
{ {
return; return;
} }
_nativeAds.Remove(adUnitId);
NativeOverlayAd.Load(adUnitId, new AdRequest(), new NativeAdOptions(), (NativeOverlayAd ad, LoadAdError error) => NativeOverlayAd.Load(adUnitId, new AdRequest(), new NativeAdOptions(), (NativeOverlayAd ad, LoadAdError error) =>
{ {
@ -264,8 +266,9 @@ namespace WZ
_adRevenueCache.Clear(); _adRevenueCache.Clear();
} }
public void RemoveNative(string adUnitId) public IEnumerator RemoveNative(string adUnitId)
{ {
yield return new WaitForSeconds(0.2f);
if (adUnitId == null || string.IsNullOrEmpty(adUnitId)) if (adUnitId == null || string.IsNullOrEmpty(adUnitId))
{ {
foreach (var nativeOverlayAd in _nativeAds) foreach (var nativeOverlayAd in _nativeAds)
@ -274,7 +277,7 @@ namespace WZ
LoadAd(nativeOverlayAd.Key); LoadAd(nativeOverlayAd.Key);
} }
return; yield break;
} }
if (_nativeAds.TryGetValue(adUnitId, out var tempAd)) if (_nativeAds.TryGetValue(adUnitId, out var tempAd))

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Firebase.RemoteConfig; using Firebase.RemoteConfig;

View File

@ -100,12 +100,34 @@ public class RushSDKManager : D_MonoSingleton<RushSDKManager>
/// <param name="position"></param> /// <param name="position"></param>
/// <param name="ivadType"></param> /// <param name="ivadType"></param>
/// <param name="callback"></param> /// <param name="callback"></param>
public void ShowInterstitial(string position, IvType ivadType = IvType.IV1, Action<double> callback = null) public void ShowInterstitial(string position, IvType ivadType = IvType.IV1, Action<double> callback = null, bool ivRules = true)
{ {
AdsActionEvents.TrackAdPosition(AdsType.Interstitial, position); AdsActionEvents.TrackAdPosition(AdsType.Interstitial, position);
//插屏展示逻辑 //插屏展示逻辑
bool ivRulesShow = AdsSDKManager.Instance.IvRulesShow(ivadType); bool ivRulesShow = AdsSDKManager.Instance.IvRulesShow(ivadType);
if (ivRulesShow) if (!ivRules)
{
//激励竞价不能被规则限制
//是否有缓存
bool isInterstitialReady = AdsSDKManager.Instance.IsInterstitialReady();
if (isInterstitialReady)
{
AdsSDKManager.Instance.ShowInterstitialAd(position, ivadType, (revenue) =>
{
//展示完一个插屏之后调用
IvRulesConst.OverLevels[ivadType.ToString()] = 1;
IvRulesConst.Intervals[ivadType.ToString()] = TimeUtils.GetLocalTimestamp();
AdsSplashManager.Instance.backgroundTime = Time.realtimeSinceStartup;
callback?.Invoke(revenue);
});
}
else
{
AdsActionEvents.TrackAdFailToShow(AdsType.Interstitial, position, AdsShowFailType.NoFill);
callback?.Invoke(-1);
}
}
if (ivRulesShow && ivRules)
{ {
//是否有缓存 //是否有缓存
bool isInterstitialReady = AdsSDKManager.Instance.IsInterstitialReady(); bool isInterstitialReady = AdsSDKManager.Instance.IsInterstitialReady();

View File

@ -1 +1 @@
Build from HY-LSZNWIN10 at 2025/9/10 16:37:43 Build from HY-LSZNWIN10 at 2025/9/12 11:10:11

View File

@ -1 +0,0 @@
1.0.02025.9.8第一版上线记录。