This commit is contained in:
juncong lee 2025-09-04 17:19:28 +08:00
commit d1eab95510
3 changed files with 61 additions and 25 deletions

View File

@ -240,20 +240,20 @@ namespace WZ
public bool IvRulesShow(IvType ivadType)
{
//1.获取远程配置
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES");
if (string.IsNullOrEmpty(json))
{
LoggerUtils.Debug("[SDK] 获取远程配置IV_RULES是空 没有限制");
return true;
}
//2.解析配置
var dates = JsonConvert.DeserializeObject<IvRulesData[]>(json);
if (dates == null && dates.Length == 0)
{
LoggerUtils.Debug("[SDK] 获取远程配置信息是空");
return true;
}
//3.获取IVADType对应的配置
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES");
if (string.IsNullOrEmpty(json))
{
LoggerUtils.Debug("[SDK] 获取远程配置IV_RULES是空 没有限制");
return true;
}
//2.解析配置
var dates = JsonConvert.DeserializeObject<IvRulesData[]>(json);
if (dates == null && dates.Length == 0)
{
LoggerUtils.Debug("[SDK] 获取远程配置信息是空");
return true;
}
//3.获取IVADType对应的配置
IvRulesData ivRulesData = null;
foreach (var data in dates)
{
@ -270,19 +270,26 @@ namespace WZ
//4.判断skip(次安装跳过几次触发不展示广告)
int skipLevel = ivRulesData.skipLevel;
int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", 0);
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 前N次不展示插屏, 本地次数是{currentSkipLevel} 远程参数是{skipLevel}");
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 前N次不展示插屏, 本地次数是{currentSkipLevel + 1} 远程参数是{skipLevel}");
if (currentSkipLevel < skipLevel)
{
PlayerPrefsUtils.SavePlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", currentSkipLevel + 1);
return false;
}
//5.判断overLevel(每跳过几次触发)
//5.判断overLevel(每跳过几次触发) 第一次会展示 之后每展示一次间隔+1
int overLevel = ivRulesData.overLevel;
int currentOverLevel = IvRulesConst.OverLevels.ContainsKey(ivadType.ToString()) ? IvRulesConst.OverLevels[ivadType.ToString()] : 0;
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 当前间隔次数: 本地次数是{currentOverLevel} 远程参数是{overLevel}");
if (currentOverLevel < overLevel)
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 当前间隔次数: 本地次数是{currentOverLevel + 1} 远程参数是{overLevel}");
if (currentOverLevel != 0)
{
IvRulesConst.OverLevels[ivadType.ToString()] = currentOverLevel + 1;
if (currentOverLevel >= overLevel)
{
IvRulesConst.OverLevels[ivadType.ToString()] = 0;
}
else
{
IvRulesConst.OverLevels[ivadType.ToString()] += 1;
}
return false;
}
@ -295,8 +302,8 @@ namespace WZ
{
return false;
}
return true;
return true;
}
/// <summary>

View File

@ -106,7 +106,7 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
AdsSDKManager.Instance.ShowInterstitialAd(position, ivadType, (revenue) =>
{
//展示完一个插屏之后调用
IvRulesConst.OverLevels[ivadType.ToString()] = 0;
IvRulesConst.OverLevels[ivadType.ToString()] = 1;
IvRulesConst.Intervals[ivadType.ToString()] = TimeUtils.GetLocalTimestamp();
AdsSplashManager.Instance.backgroundTime = Time.realtimeSinceStartup;
callback?.Invoke(revenue);
@ -366,6 +366,7 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
return;
}
EFSdkManager.Instance.AddUrl(id, url);
EFSdkManager.Instance.SetOkspinShowPos(pos);
EFSdk.get().ShowWebView(id, url, pRect, pCam);
}

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using EFSDK;
using Firebase.Analytics;
using UnityEngine;
@ -14,6 +15,9 @@ namespace WZ
private Action<string> _webviewShowSuccessAction;
//保存的链接
private List<string> urls = new List<string>();
public void Init()
{
if (Application.isEditor)
@ -24,7 +28,6 @@ namespace WZ
{
if (actionType == EFSdk.ActionType.H5_Load_Succ)
{
//webview展示成功
_webviewShowSuccessAction?.Invoke(str);
}
});
@ -48,10 +51,10 @@ namespace WZ
/// <param name="callback">string 是互动广告的url</param>
public void SetHdH5ImpressionCallback()
{
EFSdk.get().SetHdH5ImpressionCallback((url) =>
EFSdk.get().SetHdH5ImpressionCallback((pid) =>
{
//判断链接不为空
if (string.IsNullOrEmpty(url))
if (string.IsNullOrEmpty(pid))
{
return;
}
@ -60,6 +63,8 @@ namespace WZ
int count = PlayerPrefsUtils.GetPlayerPrefsInt(KEY_OKSPIN_SHOW_COUNT, 0);
count++;
PlayerPrefsUtils.SavePlayerPrefsInt(KEY_OKSPIN_SHOW_COUNT, count);
string url = GetUrl(pid);
//互动广告只有okSpin
float revenue = FireBaseRemoteConfigManager.Instance.GetRemoteConfigFloat("rev_okspin", 0);
@ -82,5 +87,28 @@ namespace WZ
{
_webviewShowSuccessAction = action;
}
public void AddUrl(int id, string url)
{
if (!urls.Contains(url))
{
urls.Add(url);
}
}
private string GetUrl(string pid)
{
foreach (var url in urls)
{
if (url.Contains(pid))
{
return url;
}
}
return pid;
}
}
}