diff --git a/Assets/Script/Common/IvRulesData.cs b/Assets/Script/Common/IvRulesData.cs index 00926e9..277b57b 100644 --- a/Assets/Script/Common/IvRulesData.cs +++ b/Assets/Script/Common/IvRulesData.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace WZ { @@ -19,7 +20,10 @@ namespace WZ public static class IvRulesConst { - public static int CurrentOverLevel = 0; //每跳过几次触发 - public static long CurrentInterval = 0; //广告最小时间间隔 + //每跳过几次触发 + public static Dictionary OverLevels = new Dictionary(); + + //广告最小时间间隔 + public static Dictionary Intervals = new Dictionary(); } } \ No newline at end of file diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs b/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs index ac0b9f8..703de34 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs @@ -253,6 +253,7 @@ namespace WZ AdRewardCallback = null; } + #region IvRules /// /// 根据IvRules判断是否可以展示插屏 /// @@ -286,36 +287,50 @@ namespace WZ } //4.判断skip(次安装跳过几次触发不展示广告) int skipLevel = ivRulesData.skipLevel; - int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, 0); + int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", 0); if (currentSkipLevel < skipLevel) { - LoggerUtils.Debug($"[SDK] skipLevel limit"); - PlayerPrefsUtils.SavePlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, currentSkipLevel + 1); + LoggerUtils.Debug($"[SDK] {ivadType} skipLevel limit"); + PlayerPrefsUtils.SavePlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", currentSkipLevel + 1); return false; } - //5.判断overLevel(没跳过几次触发) + //5.判断overLevel(每跳过几次触发) int overLevel = ivRulesData.overLevel; - int currentOverLevel = IvRulesConst.CurrentOverLevel; + int currentOverLevel = IvRulesConst.OverLevels.ContainsKey(ivadType.ToString()) ? IvRulesConst.OverLevels[ivadType.ToString()] : 0; if (currentOverLevel < overLevel) { - LoggerUtils.Debug($"[SDK] overLevel limit"); - IvRulesConst.CurrentOverLevel++; + LoggerUtils.Debug($"[SDK] {ivadType} overLevel limit"); + IvRulesConst.OverLevels[ivadType.ToString()] = currentOverLevel + 1; return false; } //6.判断interval(广告时间间隔) int interval = ivRulesData.interval; - long currentInterval = IvRulesConst.CurrentInterval; + long currentInterval = IvRulesConst.Intervals.ContainsKey(ivadType.ToString()) ? IvRulesConst.Intervals[ivadType.ToString()] : 0; long localTimestamp = TimeUtils.GetLocalTimestamp(); if (localTimestamp < currentInterval + (interval * 1000L)) { - LoggerUtils.Debug($"[SDK] interval limit"); + LoggerUtils.Debug($"[SDK] {ivadType} interval limit"); return false; } return true; } + + /// + /// 看激励广告之后调用 + /// + public void ClearIvRules() + { + var localTimestamp = TimeUtils.GetLocalTimestamp(); + foreach (var key in IvRulesConst.Intervals.Keys.ToList()) + { + IvRulesConst.Intervals[key] = localTimestamp; + } + } + + #endregion #region 检查并刷新过期竞价 private void CheckAndRefreshExpiredBids(AdsType _adsType) diff --git a/Assets/Script/SDKManager/AppSDKManager.cs b/Assets/Script/SDKManager/AppSDKManager.cs index db140b1..835a60d 100644 --- a/Assets/Script/SDKManager/AppSDKManager.cs +++ b/Assets/Script/SDKManager/AppSDKManager.cs @@ -36,6 +36,20 @@ public class AppSDKManager : D_MonoSingleton #region ad + /// + /// 是否已缓存激励广告 + /// + /// + public bool IsRewardAdReady() + { + return AdsSDKManager.Instance.IsRewardAdReady();; + } + + /// + /// 展示激励广告 + /// + /// + /// public void ShowRewardAd(string position, Action callback = null) { bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady(); @@ -45,12 +59,35 @@ public class AppSDKManager : D_MonoSingleton { if (isReward) { - //callback?.Invoke(); + AdsSDKManager.Instance.ClearIvRules(); callback?.Invoke(true, revenue); } + else + { + callback?.Invoke(false, 0); + } }); } + else + { + callback?.Invoke(false, 0); + } } + + /// + /// 是否已缓存插屏 + /// + public bool IsInterstitialAdReady() + { + return AdsSDKManager.Instance.IsInterstitialReady(); + } + + /// + /// 展示插屏广告 + /// + /// + /// + /// public void ShowInterstitial(string position, IvType ivadType = IvType.IV1, Action callback = null) { //插屏展示逻辑 @@ -64,8 +101,9 @@ public class AppSDKManager : D_MonoSingleton AdsSDKManager.Instance.ShowInterstitialAd(position, ivadType, (revenue) => { //展示完一个插屏之后调用 - IvRulesConst.CurrentOverLevel = 0; - IvRulesConst.CurrentInterval = TimeUtils.GetLocalTimestamp(); + IvRulesConst.OverLevels[ivadType.ToString()] = 0; + IvRulesConst.Intervals[ivadType.ToString()] = TimeUtils.GetLocalTimestamp(); + callback?.Invoke(revenue); }); } else @@ -79,10 +117,7 @@ public class AppSDKManager : D_MonoSingleton } } - public bool IsRewardAdReady() - { - return AdsSDKManager.Instance.IsRewardAdReady();; - } + #endregion diff --git a/Assets/Script/SDKManager/EFSdkManager/EFSdkManager.cs b/Assets/Script/SDKManager/EFSdkManager/EFSdkManager.cs index 5f9f1fe..eb245ed 100644 --- a/Assets/Script/SDKManager/EFSdkManager/EFSdkManager.cs +++ b/Assets/Script/SDKManager/EFSdkManager/EFSdkManager.cs @@ -77,9 +77,7 @@ namespace WZ PlayerPrefsUtils.SavePlayerPrefsInt(KEY_OKSPIN_SHOW_COUNT, count); //互动广告只有okSpin - string h5ad_okspinrev = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("H5ad_okspinrev", "0"); - double revenue = double.Parse(h5ad_okspinrev, System.Globalization.CultureInfo.InvariantCulture); - + float revenue = FireBaseRemoteConfigManager.Instance.GetRemoteConfigFloat("rev_okspin", 0); //adjust AdjustTrackEvent.Instance.TrackAdEvent(revenue, "H5ad_game", url, url);