Compare commits
2 Commits
bb16c03f1f
...
495c02c0ee
| Author | SHA1 | Date |
|---|---|---|
|
|
495c02c0ee | |
|
|
46fa69b689 |
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace WZ
|
namespace WZ
|
||||||
{
|
{
|
||||||
|
|
@ -19,7 +20,10 @@ namespace WZ
|
||||||
|
|
||||||
public static class IvRulesConst
|
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>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -241,6 +241,8 @@ namespace WZ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region IvRules
|
||||||
|
|
||||||
public bool IvRulesShow(IvType ivadType)
|
public bool IvRulesShow(IvType ivadType)
|
||||||
{
|
{
|
||||||
//1.获取远程配置
|
//1.获取远程配置
|
||||||
|
|
@ -270,36 +272,51 @@ namespace WZ
|
||||||
}
|
}
|
||||||
//4.判断skip(次安装跳过几次触发不展示广告)
|
//4.判断skip(次安装跳过几次触发不展示广告)
|
||||||
int skipLevel = ivRulesData.skipLevel;
|
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)
|
if (currentSkipLevel < skipLevel)
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[SDK] skipLevel limit");
|
LoggerUtils.Debug($"[SDK] {ivadType} skipLevel limit");
|
||||||
PlayerPrefsUtils.SavePlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, currentSkipLevel + 1);
|
PlayerPrefsUtils.SavePlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", currentSkipLevel + 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//5.判断overLevel(没跳过几次触发)
|
//5.判断overLevel(每跳过几次触发)
|
||||||
int overLevel = ivRulesData.overLevel;
|
int overLevel = ivRulesData.overLevel;
|
||||||
int currentOverLevel = IvRulesConst.CurrentOverLevel;
|
int currentOverLevel = IvRulesConst.OverLevels.ContainsKey(ivadType.ToString()) ? IvRulesConst.OverLevels[ivadType.ToString()] : 0;
|
||||||
if (currentOverLevel < overLevel)
|
if (currentOverLevel < overLevel)
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[SDK] overLevel limit");
|
LoggerUtils.Debug($"[SDK] {ivadType} overLevel limit");
|
||||||
IvRulesConst.CurrentOverLevel++;
|
IvRulesConst.OverLevels[ivadType.ToString()] = currentOverLevel + 1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//6.判断interval(广告时间间隔)
|
//6.判断interval(广告时间间隔)
|
||||||
int interval = ivRulesData.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();
|
long localTimestamp = TimeUtils.GetLocalTimestamp();
|
||||||
|
|
||||||
if (localTimestamp < currentInterval + (interval * 1000L))
|
if (localTimestamp < currentInterval + (interval * 1000L))
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[SDK] interval limit");
|
LoggerUtils.Debug($"[SDK] {ivadType} interval limit");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
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 检查并刷新过期竞价
|
#region 检查并刷新过期竞价
|
||||||
private void CheckAndRefreshExpiredBids(AdsType _adsType)
|
private void CheckAndRefreshExpiredBids(AdsType _adsType)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,20 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
||||||
|
|
||||||
#region ad
|
#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)
|
public void ShowRewardAd(string position, Action<bool,double> callback = null)
|
||||||
{
|
{
|
||||||
bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady();
|
bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady();
|
||||||
|
|
@ -45,12 +59,35 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
||||||
{
|
{
|
||||||
if (isReward)
|
if (isReward)
|
||||||
{
|
{
|
||||||
//callback?.Invoke();
|
AdsSDKManager.Instance.ClearIvRules();
|
||||||
callback?.Invoke(true, revenue);
|
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)
|
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) =>
|
AdsSDKManager.Instance.ShowInterstitialAd(position, ivadType, (revenue) =>
|
||||||
{
|
{
|
||||||
//展示完一个插屏之后调用
|
//展示完一个插屏之后调用
|
||||||
IvRulesConst.CurrentOverLevel = 0;
|
IvRulesConst.OverLevels[ivadType.ToString()] = 0;
|
||||||
IvRulesConst.CurrentInterval = TimeUtils.GetLocalTimestamp();
|
IvRulesConst.Intervals[ivadType.ToString()] = TimeUtils.GetLocalTimestamp();
|
||||||
|
callback?.Invoke(revenue);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -79,10 +117,7 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRewardAdReady()
|
|
||||||
{
|
|
||||||
return AdsSDKManager.Instance.IsRewardAdReady();;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,9 +77,7 @@ namespace WZ
|
||||||
PlayerPrefsUtils.SavePlayerPrefsInt(KEY_OKSPIN_SHOW_COUNT, count);
|
PlayerPrefsUtils.SavePlayerPrefsInt(KEY_OKSPIN_SHOW_COUNT, count);
|
||||||
|
|
||||||
//互动广告只有okSpin
|
//互动广告只有okSpin
|
||||||
string h5ad_okspinrev = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("H5ad_okspinrev", "0");
|
float revenue = FireBaseRemoteConfigManager.Instance.GetRemoteConfigFloat("rev_okspin", 0);
|
||||||
double revenue = double.Parse(h5ad_okspinrev, System.Globalization.CultureInfo.InvariantCulture);
|
|
||||||
|
|
||||||
|
|
||||||
//adjust
|
//adjust
|
||||||
AdjustTrackEvent.Instance.TrackAdEvent(revenue, "H5ad_game", url, url);
|
AdjustTrackEvent.Instance.TrackAdEvent(revenue, "H5ad_game", url, url);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue