IvRules
This commit is contained in:
parent
a42f123e7a
commit
46fa69b689
|
@ -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<string, int> OverLevels = new Dictionary<string, int>();
|
||||
|
||||
//广告最小时间间隔
|
||||
public static Dictionary<string, long> Intervals = new Dictionary<string, long>();
|
||||
}
|
||||
}
|
|
@ -253,6 +253,7 @@ namespace WZ
|
|||
AdRewardCallback = null;
|
||||
}
|
||||
|
||||
#region IvRules
|
||||
/// <summary>
|
||||
/// 根据IvRules判断是否可以展示插屏
|
||||
/// </summary>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 看激励广告之后调用
|
||||
/// </summary>
|
||||
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)
|
||||
|
|
|
@ -36,6 +36,20 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
|
||||
#region ad
|
||||
|
||||
/// <summary>
|
||||
/// 是否已缓存激励广告
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsRewardAdReady()
|
||||
{
|
||||
return AdsSDKManager.Instance.IsRewardAdReady();;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展示激励广告
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="callback"></param>
|
||||
public void ShowRewardAd(string position, Action<bool,double> callback = null)
|
||||
{
|
||||
bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady();
|
||||
|
@ -45,12 +59,35 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
{
|
||||
if (isReward)
|
||||
{
|
||||
//callback?.Invoke();
|
||||
AdsSDKManager.Instance.ClearIvRules();
|
||||
callback?.Invoke(true, revenue);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback?.Invoke(false, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
callback?.Invoke(false, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否已缓存插屏
|
||||
/// </summary>
|
||||
public bool IsInterstitialAdReady()
|
||||
{
|
||||
return AdsSDKManager.Instance.IsInterstitialReady();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展示插屏广告
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="ivadType"></param>
|
||||
/// <param name="callback"></param>
|
||||
public void ShowInterstitial(string position, IvType ivadType = IvType.IV1, Action<double> callback = null)
|
||||
{
|
||||
//插屏展示逻辑
|
||||
|
@ -64,8 +101,9 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
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<AppSDKManager>
|
|||
}
|
||||
}
|
||||
|
||||
public bool IsRewardAdReady()
|
||||
{
|
||||
return AdsSDKManager.Instance.IsRewardAdReady();;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue