刷新数据
This commit is contained in:
parent
de243ca1cc
commit
3d4d79b52f
|
@ -44,7 +44,7 @@ namespace WZ
|
|||
if (_bannerAdUnits.Count > 0) LoadBanner();
|
||||
if (_interstitialAdUnits.Count > 0) LoadInterstitial();
|
||||
if (_rewardedAdUnits.Count > 0) LoadRewarded();
|
||||
AdsSplashManager.Instance.InitSplash();
|
||||
if(_splashAdUnits.Count > 0) AdsSplashManager.Instance.InitSplash();
|
||||
_initialized = true;
|
||||
LoggerUtils.Debug("[Admob] init success");
|
||||
});
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace WZ
|
|||
|
||||
// 延迟重试加载
|
||||
_loadCallbacks[adUnitId] = () => LoadAd(adUnitId);
|
||||
TimerUtils.DelayExecute((float)retryDelay, () => _loadCallbacks[adUnitId]?.Invoke());
|
||||
TimerUtils.Instance.DelayExecute((float)retryDelay, () => _loadCallbacks[adUnitId]?.Invoke());
|
||||
onAdLoadFailed?.Invoke(adUnitId, msg.GetCode(), msg.GetMessage());
|
||||
});
|
||||
|
||||
|
|
|
@ -46,6 +46,14 @@ namespace WZ
|
|||
}
|
||||
}
|
||||
|
||||
public void RefreshAdsData()
|
||||
{
|
||||
foreach (var network in _adNetworks)
|
||||
{
|
||||
network.RefreshAdsData();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRewardAdReady()
|
||||
{
|
||||
return _adNetworks.Any(network => network.IsRewardedAvailable());
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace WZ
|
|||
if (state == AppState.Foreground)
|
||||
{
|
||||
LoggerUtils.Debug("[AppOpen] 进入前台");
|
||||
CheckSplashAdlash(false);
|
||||
StartCoroutine(DelayedAction());
|
||||
}
|
||||
else if (state == AppState.Background)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace WZ
|
|||
|
||||
// 延迟重试加载
|
||||
_loadCallbacks[adUnitId] = () => LoadAd(adUnitId);
|
||||
TimerUtils.DelayExecute((float)retryDelay, () => _loadCallbacks[adUnitId]?.Invoke());
|
||||
TimerUtils.Instance.DelayExecute((float)retryDelay, () => _loadCallbacks[adUnitId]?.Invoke());
|
||||
onAdLoadFailed?.Invoke(adUnitId, code, msg);
|
||||
});
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace WZ
|
|||
|
||||
// 延迟重试加载
|
||||
_loadCallbacks[adUnitId] = () => LoadAd(adUnitId);
|
||||
TimerUtils.DelayExecute((float)retryDelay, () => _loadCallbacks[adUnitId]?.Invoke());
|
||||
TimerUtils.Instance.DelayExecute((float)retryDelay, () => _loadCallbacks[adUnitId]?.Invoke());
|
||||
onAdLoadFailed?.Invoke(adUnitId, code, msg);
|
||||
});
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace WZ
|
|||
LoggerUtils.Debug("[Max] OnRewardedAdLoadFailedEvent errorInfo" + errorInfo.Message);
|
||||
_rewardRetryAttempt++;
|
||||
double retryDelay = Math.Pow(2, Math.Min(6, _rewardRetryAttempt));
|
||||
TimerUtils.DelayExecute((float)retryDelay, LoadRewarded);
|
||||
TimerUtils.Instance.DelayExecute((float)retryDelay, LoadRewarded);
|
||||
AdsActionEvents.TrackAdFailToLoad(Platfrom, "","",AdsType.Rewarded,Time.realtimeSinceStartup - _rvStartLoadTime,errorInfo.Message);
|
||||
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ namespace WZ
|
|||
LoggerUtils.Debug("[Max] OnInterstitialLoadFailedEvent :" + errorInfo);
|
||||
_interRetryAttempt++;
|
||||
double retryDelay = Math.Pow(2, Math.Min(6, _interRetryAttempt));
|
||||
TimerUtils.DelayExecute((float)retryDelay, LoadInterstitial);
|
||||
TimerUtils.Instance.DelayExecute((float)retryDelay, LoadInterstitial);
|
||||
AdsActionEvents.TrackAdFailToLoad(Platfrom, "","",AdsType.Interstitial,Time.realtimeSinceStartup - _ivStartLoadTime,errorInfo.Message);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,28 +7,22 @@ using Newtonsoft.Json;
|
|||
using UnityEngine;
|
||||
using WZ;
|
||||
|
||||
public class AppSDKManager : MonoBehaviour
|
||||
{
|
||||
public static AppSDKManager Instance;
|
||||
|
||||
public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
||||
{
|
||||
//包名
|
||||
public const string PackageName = "com.rush.cash.earn.fast.real.money.game";
|
||||
|
||||
private void Awake()
|
||||
public void Init(Action action)
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
FileParse.Parse();
|
||||
// AdConfigParser.Parse();
|
||||
AdmobAdsManager.Instance.RefreshAdsData();
|
||||
AdmobAdsManager.Instance.Initialize();
|
||||
FireBaseSDKManager.Instance.Init();
|
||||
AdjustManager.Instance.Init();
|
||||
ShuShuMangage.Instance.Init();
|
||||
|
||||
AdsSDKManager.Instance.InitSDK(null);
|
||||
EFSdkManager.Instance.Init();
|
||||
}
|
||||
|
||||
public void Init(Action action)
|
||||
{
|
||||
AdsSDKManager.Instance.InitSDK(action);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -18,6 +18,10 @@ namespace WZ
|
|||
{
|
||||
FirebaseRemoteConfig.DefaultInstance.ActivateAsync().ContinueWithOnMainThread(task =>
|
||||
{
|
||||
// 获取广告位信息
|
||||
AdConfigParser.Parse(GetRemoteConfigString("ad_config"));
|
||||
// 刷新广告位信息
|
||||
AdsSDKManager.Instance.RefreshAdsData();
|
||||
// adjust卸载监控
|
||||
|
||||
/* 执行到这时,表示firebase接入正常,能获取到远端在线参数 */
|
||||
|
|
|
@ -5,61 +5,18 @@ using UnityEngine;
|
|||
|
||||
namespace WZ
|
||||
{
|
||||
public class TimerUtils : MonoBehaviour
|
||||
public class TimerUtils :D_MonoSingleton<TimerUtils>
|
||||
{
|
||||
private static TimerUtils _instance;
|
||||
|
||||
public static void Initialize()
|
||||
public void DelayExecute(float delay, System.Action action)
|
||||
{
|
||||
if (_instance != null) return;
|
||||
GameObject timerObject = new GameObject("TimerUtils");
|
||||
timerObject.hideFlags = HideFlags.HideInHierarchy;
|
||||
DontDestroyOnLoad(timerObject);
|
||||
_instance = timerObject.AddComponent<TimerUtils>();
|
||||
}
|
||||
|
||||
public static void DelayExecute(float delay, System.Action action)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
Debug.LogWarning("TimerUtils not initialized. Call TimerUtils.Initialize() first.");
|
||||
return;
|
||||
}
|
||||
|
||||
_instance.StartCoroutine(DelayExecuteCoroutine(delay, action));
|
||||
}
|
||||
|
||||
public static void StopAllDelayedActions()
|
||||
{
|
||||
if (_instance != null)
|
||||
{
|
||||
_instance.StopAllCoroutines();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
if (_instance != null)
|
||||
{
|
||||
Destroy(_instance.gameObject);
|
||||
_instance = null;
|
||||
}
|
||||
StartCoroutine(DelayExecuteCoroutine(delay, action));
|
||||
}
|
||||
|
||||
private static IEnumerator DelayExecuteCoroutine(float delay, System.Action action)
|
||||
private IEnumerator DelayExecuteCoroutine(float delay, System.Action action)
|
||||
{
|
||||
yield return new WaitForSeconds(delay);
|
||||
action?.Invoke();
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
// 清理静态引用,防止内存泄漏
|
||||
if (_instance == this)
|
||||
{
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue