修复报错,firebase未初始化前不上报事件
This commit is contained in:
parent
1b38fceda1
commit
660d3490c8
|
@ -147,7 +147,7 @@ namespace WZ
|
|||
#region 插页广告功能
|
||||
public void LoadInterstitial()
|
||||
{
|
||||
_admobBannerAdManager?.Destroy();
|
||||
_admobInterstitialAdManager?.Destroy();
|
||||
_admobInterstitialAdManager = new AdmobInterstitialAdManager();
|
||||
_admobInterstitialAdManager.InitializeAdUnits(
|
||||
_interstitialAdUnits,
|
||||
|
@ -244,7 +244,7 @@ namespace WZ
|
|||
public bool IsSplashAvailable()
|
||||
{
|
||||
if (!_initialized) return false;
|
||||
return _admobBannerAdManager.GetAvailableAdUnits().Count > 0;
|
||||
return _admobSplashAdManager.GetAvailableAdUnits().Count > 0;
|
||||
}
|
||||
public void DisplaySplash()
|
||||
{
|
||||
|
@ -323,7 +323,7 @@ namespace WZ
|
|||
|
||||
public double GetNativeRevenue(string adUnitId)
|
||||
{
|
||||
return _admobBannerAdManager.GetAdRevenue(adUnitId);
|
||||
return _admobNativeAdManager.GetHighestPayingAdRevenue();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@ namespace WZ
|
|||
{
|
||||
string responseInfoJson = responseInfo.ToString();
|
||||
JObject responseInfoObj = JObject.Parse(responseInfoJson);
|
||||
JToken loadedAdapterResponse = responseInfoObj["Response Extras"];
|
||||
JToken loadedAdapterResponse = responseInfoObj["Adapter Responses"];
|
||||
|
||||
if (loadedAdapterResponse != null)
|
||||
{
|
||||
pubid = loadedAdapterResponse["mediation_group_name"]?.ToString();
|
||||
pubid = loadedAdapterResponse["Credentials"]?.ToString();
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace WZ
|
|||
_showFailedCallback?.Invoke();
|
||||
return;
|
||||
}
|
||||
AdsSDKManager.Instance.otherAdsOnShow = true;
|
||||
otherAdsOnShow = true;
|
||||
PlatformType result = GetBestPlatformType(false);
|
||||
BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Rewarded);
|
||||
if (result == PlatformType.AppLovin)
|
||||
|
@ -222,7 +222,6 @@ namespace WZ
|
|||
{
|
||||
if (isInterstitial)
|
||||
{
|
||||
LoggerUtils.Debug("yangwu max price");
|
||||
AdPriceInfo priceInfo = new AdPriceInfo(
|
||||
maxPrice: MaxAdsManager.Instance.GetInterstitialRevenue(),
|
||||
admobPrice: AdmobAdsManager.Instance.GetInterstitialRevenue(),
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace WZ
|
|||
|
||||
public bool IsRewardedAvailable()
|
||||
{
|
||||
if (!_initialized) return false;
|
||||
if (!_initialized || _rewardedAdManager == null) return false;
|
||||
return _rewardedAdManager.GetAvailableAdUnits().Count > 0;
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,7 @@ namespace WZ
|
|||
|
||||
public double GetRewardedRevenue()
|
||||
{
|
||||
if (!_initialized || _rewardedAdManager == null) return -1;
|
||||
return _rewardedAdManager.GetHighestPayingAdRevenue();
|
||||
}
|
||||
|
||||
|
@ -190,7 +191,7 @@ namespace WZ
|
|||
|
||||
public bool IsInterstitialAvailable()
|
||||
{
|
||||
if (!_initialized) return false;
|
||||
if (!_initialized || _interstitialAdManager == null) return false;
|
||||
return _interstitialAdManager.GetAvailableAdUnits().Count > 0;
|
||||
}
|
||||
|
||||
|
@ -203,6 +204,7 @@ namespace WZ
|
|||
|
||||
public double GetInterstitialRevenue()
|
||||
{
|
||||
if (!_initialized || _interstitialAdManager == null) return -1;
|
||||
return _interstitialAdManager.GetHighestPayingAdRevenue();
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace WZ
|
|||
private static object m_kwaiObj = "m_kwaiObj";
|
||||
public static PlatformType GetPlatformType(AdPriceInfo priceInfo)
|
||||
{
|
||||
#if UNITY_ANDROID && UNITY_EDITOR
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
||||
{
|
||||
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace WZ
|
|||
|
||||
public void LogEvent(string eventName)
|
||||
{
|
||||
if (!FireBaseRemoteConfigManager.Instance.IsInitialized) return;
|
||||
var superProperties = GetSuperProperties();
|
||||
if (superProperties.Count > 0)
|
||||
{
|
||||
|
@ -41,6 +42,7 @@ namespace WZ
|
|||
|
||||
public void LogEvent(string eventName, string key1, object value1)
|
||||
{
|
||||
if (!FireBaseRemoteConfigManager.Instance.IsInitialized) return;
|
||||
List<Parameter> parameters = new List<Parameter>();
|
||||
parameters.Add(GetParameter(key1, value1));
|
||||
|
||||
|
@ -54,6 +56,7 @@ namespace WZ
|
|||
|
||||
public void LogEvent(string eventName, Dictionary<string, object> dict)
|
||||
{
|
||||
if (!FireBaseRemoteConfigManager.Instance.IsInitialized) return;
|
||||
List<Parameter> parameters = new List<Parameter>();
|
||||
foreach (var item in dict)
|
||||
{
|
||||
|
@ -72,6 +75,7 @@ namespace WZ
|
|||
|
||||
public void LogEvent(string eventName, Dictionary<string, string> dict)
|
||||
{
|
||||
if (!FireBaseRemoteConfigManager.Instance.IsInitialized) return;
|
||||
List<Parameter> parameters = new List<Parameter>();
|
||||
foreach (var item in dict)
|
||||
{
|
||||
|
@ -162,6 +166,7 @@ namespace WZ
|
|||
/// <param name="number">第几次展示该格式的广告</param>
|
||||
public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, AdsType ad_format, double revenue, string position, int number)
|
||||
{
|
||||
if (!FireBaseRemoteConfigManager.Instance.IsInitialized) return;
|
||||
var impressionParameters = new[] {
|
||||
new Firebase.Analytics.Parameter("ad_platform", ad_platform),
|
||||
new Firebase.Analytics.Parameter("ad_source", ad_source),
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace WZ
|
|||
{
|
||||
public class FireBaseRemoteConfigManager : D_MonoSingleton<FireBaseRemoteConfigManager>
|
||||
{
|
||||
public bool IsInitialized { get; private set; }
|
||||
public void FetchRemoteConfig()
|
||||
{
|
||||
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
|
||||
|
@ -18,6 +19,7 @@ namespace WZ
|
|||
{
|
||||
FirebaseRemoteConfig.DefaultInstance.ActivateAsync().ContinueWithOnMainThread(task =>
|
||||
{
|
||||
IsInitialized = true;
|
||||
// 获取广告位信息
|
||||
AdConfigParser.Parse(GetRemoteConfigString("ad_config"));
|
||||
// 刷新广告位信息
|
||||
|
|
Loading…
Reference in New Issue