修复MobileAds多次初始化影响游戏bug、修复报错
This commit is contained in:
parent
1a5d0ac88c
commit
799a2b32eb
|
|
@ -40,9 +40,9 @@ namespace WZ
|
||||||
{
|
{
|
||||||
if (_initialized) return;
|
if (_initialized) return;
|
||||||
MobileAds.RaiseAdEventsOnUnityMainThread = true;
|
MobileAds.RaiseAdEventsOnUnityMainThread = true;
|
||||||
|
_initialized = true;
|
||||||
MobileAds.Initialize(initStatus =>
|
MobileAds.Initialize(initStatus =>
|
||||||
{
|
{
|
||||||
_initialized = true;
|
|
||||||
if (_bannerAdUnits.Count > 0) LoadBanner();
|
if (_bannerAdUnits.Count > 0) LoadBanner();
|
||||||
if (_interstitialAdUnits.Count > 0) LoadInterstitial();
|
if (_interstitialAdUnits.Count > 0) LoadInterstitial();
|
||||||
if (_rewardedAdUnits.Count > 0) LoadRewarded();
|
if (_rewardedAdUnits.Count > 0) LoadRewarded();
|
||||||
|
|
|
||||||
|
|
@ -239,16 +239,18 @@ namespace WZ
|
||||||
|
|
||||||
public bool IvRulesShow(IvType ivadType)
|
public bool IvRulesShow(IvType ivadType)
|
||||||
{
|
{
|
||||||
//1.获取远程配置
|
//1.获取远程配置
|
||||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES");
|
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES");
|
||||||
if (string.IsNullOrEmpty(json))
|
if (string.IsNullOrEmpty(json))
|
||||||
{
|
{
|
||||||
|
LoggerUtils.Debug("[SDK] 获取远程配置IV_RULES是空 没有限制");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//2.解析配置
|
//2.解析配置
|
||||||
var dates = JsonConvert.DeserializeObject<IvRulesData[]>(json);
|
var dates = JsonConvert.DeserializeObject<IvRulesData[]>(json);
|
||||||
if (dates == null && dates.Length == 0)
|
if (dates == null && dates.Length == 0)
|
||||||
{
|
{
|
||||||
|
LoggerUtils.Debug("[SDK] 获取远程配置信息是空");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//3.获取IVADType对应的配置
|
//3.获取IVADType对应的配置
|
||||||
|
|
@ -262,23 +264,24 @@ namespace WZ
|
||||||
}
|
}
|
||||||
if (ivRulesData == null)
|
if (ivRulesData == null)
|
||||||
{
|
{
|
||||||
|
LoggerUtils.Debug("[SDK] 远程配置没有配置对应的IvType");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//4.判断skip(次安装跳过几次触发不展示广告)
|
//4.判断skip(次安装跳过几次触发不展示广告)
|
||||||
int skipLevel = ivRulesData.skipLevel;
|
int skipLevel = ivRulesData.skipLevel;
|
||||||
int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", 0);
|
int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", 0);
|
||||||
|
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 前N次不展示插屏, 本地次数是{currentSkipLevel}, 远程参数是{skipLevel}");
|
||||||
if (currentSkipLevel < skipLevel)
|
if (currentSkipLevel < skipLevel)
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[SDK] {ivadType} skipLevel limit");
|
|
||||||
PlayerPrefsUtils.SavePlayerPrefsInt($"{IvRulesKey.KEY_SKIPLEVEL}_{ivadType.ToString()}", 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.OverLevels.ContainsKey(ivadType.ToString()) ? IvRulesConst.OverLevels[ivadType.ToString()] : 0;
|
int currentOverLevel = IvRulesConst.OverLevels.ContainsKey(ivadType.ToString()) ? IvRulesConst.OverLevels[ivadType.ToString()] : 0;
|
||||||
|
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 当前间隔次数: 本地次数是{currentOverLevel}, 远程参数是{overLevel}");
|
||||||
if (currentOverLevel < overLevel)
|
if (currentOverLevel < overLevel)
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[SDK] {ivadType} overLevel limit");
|
|
||||||
IvRulesConst.OverLevels[ivadType.ToString()] = currentOverLevel + 1;
|
IvRulesConst.OverLevels[ivadType.ToString()] = currentOverLevel + 1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -287,10 +290,9 @@ namespace WZ
|
||||||
int interval = ivRulesData.interval;
|
int interval = ivRulesData.interval;
|
||||||
long currentInterval = IvRulesConst.Intervals.ContainsKey(ivadType.ToString()) ? IvRulesConst.Intervals[ivadType.ToString()] : 0;
|
long currentInterval = IvRulesConst.Intervals.ContainsKey(ivadType.ToString()) ? IvRulesConst.Intervals[ivadType.ToString()] : 0;
|
||||||
long localTimestamp = TimeUtils.GetLocalTimestamp();
|
long localTimestamp = TimeUtils.GetLocalTimestamp();
|
||||||
|
LoggerUtils.Debug($"[SDK] {ivadType.ToString()} 远程参数是: {interval}, CanShowFlag: {localTimestamp > (currentInterval + (interval * 1000L))}");
|
||||||
if (localTimestamp < currentInterval + (interval * 1000L))
|
if (localTimestamp < currentInterval + (interval * 1000L))
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[SDK] {ivadType} interval limit");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using BigoAds.Scripts.Api;
|
using BigoAds.Scripts.Api;
|
||||||
using NUnit.Framework.Constraints;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue