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