修改命名空间&开屏广告
This commit is contained in:
parent
8b7054ef00
commit
b7b1b2c9f4
|
@ -5,10 +5,9 @@ using System.IO;
|
|||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Google.MiniJSON;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.Common.FileParse
|
||||
namespace WZ
|
||||
{
|
||||
|
||||
public static class FileParse
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
|
||||
namespace Script.Common
|
||||
namespace WZ
|
||||
{
|
||||
/// <summary>
|
||||
/// 提供广告SDK功能的统一接口
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace Script.Common
|
||||
namespace WZ
|
||||
{
|
||||
[System.Serializable]
|
||||
public class IvRulesData
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Script.Common
|
||||
namespace WZ
|
||||
{
|
||||
[System.Serializable]
|
||||
public class RevenueData
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.Common
|
||||
namespace WZ
|
||||
{
|
||||
|
||||
public static class StaticValue
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AdjustSdk;
|
||||
using Script.Utils;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using WZ;
|
||||
|
||||
public class AdjustManager : NormalSingleton<AdjustManager>
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections;
|
||||
using Script.Utils;
|
||||
|
||||
using UnityEngine;
|
||||
using WZ;
|
||||
|
||||
public class AdjustNetwork : NormalSingleton<AdjustNetwork>
|
||||
{
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
using AdjustSdk;
|
||||
using Firebase.RemoteConfig;
|
||||
using Newtonsoft.Json;
|
||||
using Script.Common;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.Utils;
|
||||
using WZ;
|
||||
|
||||
|
||||
public class AdjustTrackEvent : NormalSingleton<AdjustTrackEvent>
|
||||
{
|
||||
|
|
|
@ -2,15 +2,10 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using GoogleMobileAds.Api;
|
||||
using Script.Common;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.SDKManager.AdsSDKManager.Utils;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
|
||||
public class AdmobAdsManager : NormalSingleton<AdmobAdsManager>, IAdService
|
||||
|
@ -52,8 +47,6 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
|||
if (_bannerAdUnits.Count > 0) LoadBanner();
|
||||
if (_interstitialAdUnits.Count > 0) LoadInterstitial();
|
||||
if (_rewardedAdUnits.Count > 0) LoadRewarded();
|
||||
if (_splashAdUnits.Count > 0) LoadSplash();
|
||||
|
||||
_initialized = true;
|
||||
LoggerUtils.Debug("[Admob] init success");
|
||||
});
|
||||
|
@ -268,14 +261,16 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
|||
|
||||
}
|
||||
|
||||
private void OnSplashAdDismissed(string adSource,string adUnitId,double revenue)
|
||||
private void OnSplashAdDismissed(string adSource, string adUnitId, double revenue)
|
||||
{
|
||||
AdsActionEvents.TrackAdClosed(Platfrom, adSource, adUnitId, AdsType.Splash, "", revenue);
|
||||
AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke();
|
||||
}
|
||||
|
||||
private void OnSplashAdError(string adUnitId, int errorCode, string errorMsg)
|
||||
{
|
||||
AdsActionEvents.TrackAdFailToShow(Platfrom,AdsType.Splash,errorMsg,"");
|
||||
AdsActionEvents.TrackAdFailToShow(Platfrom, AdsType.Splash, errorMsg, "");
|
||||
AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke();
|
||||
}
|
||||
|
||||
private void OnSplashAdClicked(string adSource,string adUnitId,double revenue)
|
||||
|
@ -294,7 +289,6 @@ namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
|||
#region 原生广告功能
|
||||
public void LoadNative()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public double GetNativeRevenue()
|
||||
{
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using GoogleMobileAds.Api;
|
||||
using System;
|
||||
using Script.Utils;
|
||||
using Script.SDKManager.AdsSDKManager.AdmobAdsManager.Utils;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
public class AdmobBannerAdManager
|
||||
{
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GoogleMobileAds.Api;
|
||||
using Script.SDKManager.AdsSDKManager.AdmobAdsManager.Utils;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.Utils;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
public class AdmobInterstitialAdManager
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
public class AdmobNativeAdManager : MonoBehaviour
|
||||
{
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GoogleMobileAds.Api;
|
||||
using Script.SDKManager.AdsSDKManager.AdmobAdsManager.Utils;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.Utils;
|
||||
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
public class AdmobRewardedAdManager
|
||||
{
|
||||
|
|
|
@ -2,13 +2,9 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GoogleMobileAds.Api;
|
||||
using Script.SDKManager.AdsSDKManager.AdmobAdsManager.Utils;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
public class AdmobSplashAdManager
|
||||
{
|
||||
|
|
|
@ -2,11 +2,10 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using GoogleMobileAds.Api;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.AdmobAdsManager.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public class AdmobUtils
|
||||
{
|
||||
|
|
|
@ -3,378 +3,394 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Firebase.RemoteConfig;
|
||||
using Newtonsoft.Json;
|
||||
using Script.Common;
|
||||
using Script.SDKManager.AdsSDKManager.AdmobAdsManager;
|
||||
using Script.SDKManager.AdsSDKManager.BigoAdsManager;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.SDKManager.AdsSDKManager.MaxAdsManager;
|
||||
using Script.SDKManager.AdsSDKManager.TpnAdsManager;
|
||||
using Script.SDKManager.AdsSDKManager.Utils;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
public class AdsSDKManager : NormalSingleton<AdsSDKManager>
|
||||
namespace WZ
|
||||
{
|
||||
private List<IAdService> _adNetworks = new List<IAdService>();
|
||||
/// <summary>
|
||||
/// 看完广告的回调
|
||||
/// </summary>
|
||||
private Action<double> AdRewardCallback;
|
||||
|
||||
/// <summary>
|
||||
/// 广告竞价开关:激励、插屏、全屏Native广告竞价
|
||||
/// </summary>
|
||||
public bool IsMoreAdsBidding = false;
|
||||
|
||||
public void InitSDK()
|
||||
public class AdsSDKManager : NormalSingleton<AdsSDKManager>
|
||||
{
|
||||
// 初始化广告平台状态
|
||||
BidPlatformManager.Instance.InitializePlatformStates(AdConfigParser.GetAdExpireInSec());
|
||||
InitializeAdNetworks();
|
||||
}
|
||||
private List<IAdService> _adNetworks = new List<IAdService>();
|
||||
// 是否有激励视频或者插屏广告在展示
|
||||
public bool otherAdsOnShow = false;
|
||||
/// <summary>
|
||||
/// 看完广告的回调
|
||||
/// </summary>
|
||||
private Action<double> AdRewardCallback;
|
||||
|
||||
private void InitializeAdNetworks()
|
||||
{
|
||||
_adNetworks.Add(AdmobAdsManager.Instance);
|
||||
_adNetworks.Add(BigoAdsManager.Instance);
|
||||
_adNetworks.Add(TpnAdsManager.Instance);
|
||||
_adNetworks.Add(MaxAdsManager.Instance);
|
||||
/// <summary>
|
||||
/// 广告竞价开关:激励、插屏、全屏Native广告竞价
|
||||
/// </summary>
|
||||
public bool IsMoreAdsBidding = false;
|
||||
|
||||
foreach (var network in _adNetworks)
|
||||
public Action OnSplashAdCloseCallback;
|
||||
|
||||
public void InitSDK(Action action)
|
||||
{
|
||||
network.Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRewardAdReady()
|
||||
{
|
||||
return _adNetworks.Any(network => network.IsRewardedAvailable());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展示激励广告
|
||||
/// </summary>
|
||||
/// <param name="callback"></param>
|
||||
public void ShowRewardAd(string _adPos, Action<bool> _rewardCallback = null, Action _showFailedCallback = null)
|
||||
{
|
||||
AdsActionEvents.TrackAdPosition(AdsType.Rewarded, _adPos);
|
||||
if (!IsRewardAdReady())
|
||||
{
|
||||
_showFailedCallback?.Invoke();
|
||||
return;
|
||||
OnSplashAdCloseCallback = action;
|
||||
// 初始化广告平台状态
|
||||
BidPlatformManager.Instance.InitializePlatformStates(AdConfigParser.GetAdExpireInSec());
|
||||
InitializeAdNetworks();
|
||||
}
|
||||
|
||||
PlatformType result = GetBestPlatformType(false);
|
||||
BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Rewarded);
|
||||
if (result == PlatformType.AppLovin)
|
||||
{
|
||||
MaxAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
||||
}
|
||||
else if (result == PlatformType.Admob)
|
||||
{
|
||||
AdmobAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
||||
}
|
||||
else if (result == PlatformType.Bigo)
|
||||
{
|
||||
BigoAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
||||
}
|
||||
else if (result == PlatformType.Topon)
|
||||
{
|
||||
TpnAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
||||
}
|
||||
else if (result == PlatformType.Kwai)
|
||||
private void InitializeAdNetworks()
|
||||
{
|
||||
_adNetworks.Add(AdmobAdsManager.Instance);
|
||||
_adNetworks.Add(BigoAdsManager.Instance);
|
||||
_adNetworks.Add(TpnAdsManager.Instance);
|
||||
_adNetworks.Add(MaxAdsManager.Instance);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_showFailedCallback?.Invoke();
|
||||
}
|
||||
AdPlayCountManager.IncrementAdPlayCount(AdsType.Rewarded);
|
||||
CheckAndRefreshExpiredBids(AdsType.Rewarded);
|
||||
}
|
||||
|
||||
public bool IsInterstitialReady()
|
||||
{
|
||||
return _adNetworks.Any(network => network.IsInterstitialAvailable());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展示激励广告
|
||||
/// </summary>
|
||||
/// <param name="callback"></param>
|
||||
public void ShowInterstitialAd(string _adPos, IvType _IvType = IvType.IV1, Action _closeCallback = null)
|
||||
{
|
||||
AdsActionEvents.TrackAdPosition(AdsType.Interstitial, _adPos);
|
||||
if (!IsRewardAdReady())
|
||||
{
|
||||
_closeCallback?.Invoke();
|
||||
_closeCallback = null;
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformType result = GetBestPlatformType(true);
|
||||
BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Interstitial);
|
||||
if (result == PlatformType.AppLovin)
|
||||
{
|
||||
MaxAdsManager.Instance.DisplayInterstitial(_adPos, _IvType,_closeCallback);
|
||||
}
|
||||
else if (result == PlatformType.Admob)
|
||||
{
|
||||
AdmobAdsManager.Instance.DisplayInterstitial(_adPos, _IvType,_closeCallback);
|
||||
}
|
||||
else if (result == PlatformType.Bigo)
|
||||
{
|
||||
BigoAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback);
|
||||
}
|
||||
else if (result == PlatformType.Topon)
|
||||
{
|
||||
TpnAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback);
|
||||
}
|
||||
else if (result == PlatformType.Kwai)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_closeCallback?.Invoke();
|
||||
}
|
||||
|
||||
AdPlayCountManager.IncrementAdPlayCount(AdsType.Interstitial);
|
||||
// 刷新其他类型广告
|
||||
CheckAndRefreshExpiredBids(AdsType.Interstitial);
|
||||
}
|
||||
|
||||
private PlatformType GetBestPlatformType(bool isInterstitial)
|
||||
{
|
||||
if (isInterstitial)
|
||||
{
|
||||
AdPriceInfo priceInfo = new AdPriceInfo(
|
||||
maxPrice: MaxAdsManager.Instance.GetInterstitialRevenue(),
|
||||
admobPrice: AdmobAdsManager.Instance.GetInterstitialRevenue(),
|
||||
bigoPrice: BigoAdsManager.Instance.GetInterstitialRevenue(),
|
||||
// todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置
|
||||
kwaiPrice: 0,
|
||||
toponAdUnitId: TpnAdsManager.Instance.topon_interstitial_units
|
||||
);
|
||||
return AdsBidResult.GetPlatformType(priceInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdPriceInfo priceInfo = new AdPriceInfo(
|
||||
maxPrice: MaxAdsManager.Instance.GetRewardedRevenue(),
|
||||
admobPrice: AdmobAdsManager.Instance.GetRewardedRevenue(),
|
||||
bigoPrice: BigoAdsManager.Instance.GetRewardedRevenue(),
|
||||
// todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置
|
||||
kwaiPrice: 0,
|
||||
toponAdUnitId: TpnAdsManager.Instance.topon_rewarded_units
|
||||
);
|
||||
return AdsBidResult.GetPlatformType(priceInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查并刷新过期竞价
|
||||
private void CheckAndRefreshExpiredBids(AdsType _adsType)
|
||||
{
|
||||
Dictionary<PlatformType, List<AdsType>> expiredBids = BidPlatformManager.Instance.GetExpiredBids();
|
||||
|
||||
foreach (var kvp in expiredBids)
|
||||
{
|
||||
PlatformType platformName = kvp.Key;
|
||||
foreach (AdsType adType in kvp.Value)
|
||||
foreach (var network in _adNetworks)
|
||||
{
|
||||
if (_adsType == adType)
|
||||
network.Initialize();
|
||||
}
|
||||
AdsSplashManager.Instance.InitSplash();
|
||||
}
|
||||
|
||||
public bool IsRewardAdReady()
|
||||
{
|
||||
return _adNetworks.Any(network => network.IsRewardedAvailable());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展示激励广告
|
||||
/// </summary>
|
||||
/// <param name="callback"></param>
|
||||
public void ShowRewardAd(string _adPos, Action<bool> _rewardCallback = null, Action _showFailedCallback = null)
|
||||
{
|
||||
AdsActionEvents.TrackAdPosition(AdsType.Rewarded, _adPos);
|
||||
if (!IsRewardAdReady())
|
||||
{
|
||||
_showFailedCallback?.Invoke();
|
||||
return;
|
||||
}
|
||||
PlatformType result = GetBestPlatformType(false);
|
||||
BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Rewarded);
|
||||
if (result == PlatformType.AppLovin)
|
||||
{
|
||||
MaxAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
||||
}
|
||||
else if (result == PlatformType.Admob)
|
||||
{
|
||||
AdmobAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
||||
}
|
||||
else if (result == PlatformType.Bigo)
|
||||
{
|
||||
BigoAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
||||
}
|
||||
else if (result == PlatformType.Topon)
|
||||
{
|
||||
TpnAdsManager.Instance.DisplayRewarded(_adPos, _rewardCallback, _showFailedCallback);
|
||||
}
|
||||
else if (result == PlatformType.Kwai)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_showFailedCallback?.Invoke();
|
||||
}
|
||||
AdPlayCountManager.IncrementAdPlayCount(AdsType.Rewarded);
|
||||
CheckAndRefreshExpiredBids(AdsType.Rewarded);
|
||||
}
|
||||
|
||||
public bool IsInterstitialReady()
|
||||
{
|
||||
return _adNetworks.Any(network => network.IsInterstitialAvailable());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展示激励广告
|
||||
/// </summary>
|
||||
/// <param name="callback"></param>
|
||||
public void ShowInterstitialAd(string _adPos, IvType _IvType = IvType.IV1, Action _closeCallback = null)
|
||||
{
|
||||
AdsActionEvents.TrackAdPosition(AdsType.Interstitial, _adPos);
|
||||
if (!IsRewardAdReady())
|
||||
{
|
||||
_closeCallback?.Invoke();
|
||||
_closeCallback = null;
|
||||
return;
|
||||
}
|
||||
otherAdsOnShow = true;
|
||||
PlatformType result = GetBestPlatformType(true);
|
||||
BidPlatformManager.Instance.RecordBidSuccess(result, AdsType.Interstitial);
|
||||
if (result == PlatformType.AppLovin)
|
||||
{
|
||||
MaxAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback);
|
||||
}
|
||||
else if (result == PlatformType.Admob)
|
||||
{
|
||||
AdmobAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback);
|
||||
}
|
||||
else if (result == PlatformType.Bigo)
|
||||
{
|
||||
BigoAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback);
|
||||
}
|
||||
else if (result == PlatformType.Topon)
|
||||
{
|
||||
TpnAdsManager.Instance.DisplayInterstitial(_adPos, _IvType, _closeCallback);
|
||||
}
|
||||
else if (result == PlatformType.Kwai)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_closeCallback?.Invoke();
|
||||
}
|
||||
|
||||
AdPlayCountManager.IncrementAdPlayCount(AdsType.Interstitial);
|
||||
// 刷新其他类型广告
|
||||
CheckAndRefreshExpiredBids(AdsType.Interstitial);
|
||||
}
|
||||
|
||||
#region 开屏广告
|
||||
public bool IsSplashAvailable()
|
||||
{
|
||||
return _adNetworks.Any(network => network.IsSplashAvailable());
|
||||
}
|
||||
|
||||
public void ShowSplashAd()
|
||||
{
|
||||
AdmobAdsManager.Instance.DisplaySplash();
|
||||
}
|
||||
|
||||
public void LoadSplashAd()
|
||||
{
|
||||
AdmobAdsManager.Instance.LoadSplash();
|
||||
}
|
||||
#endregion
|
||||
|
||||
private PlatformType GetBestPlatformType(bool isInterstitial)
|
||||
{
|
||||
if (isInterstitial)
|
||||
{
|
||||
AdPriceInfo priceInfo = new AdPriceInfo(
|
||||
maxPrice: MaxAdsManager.Instance.GetInterstitialRevenue(),
|
||||
admobPrice: AdmobAdsManager.Instance.GetInterstitialRevenue(),
|
||||
bigoPrice: BigoAdsManager.Instance.GetInterstitialRevenue(),
|
||||
// todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置
|
||||
kwaiPrice: 0,
|
||||
toponAdUnitId: TpnAdsManager.Instance.topon_interstitial_units
|
||||
);
|
||||
return AdsBidResult.GetPlatformType(priceInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdPriceInfo priceInfo = new AdPriceInfo(
|
||||
maxPrice: MaxAdsManager.Instance.GetRewardedRevenue(),
|
||||
admobPrice: AdmobAdsManager.Instance.GetRewardedRevenue(),
|
||||
bigoPrice: BigoAdsManager.Instance.GetRewardedRevenue(),
|
||||
// todo : 这里的kwaiPrice暂时设置为0,后续需要根据实际情况设置
|
||||
kwaiPrice: 0,
|
||||
toponAdUnitId: TpnAdsManager.Instance.topon_rewarded_units
|
||||
);
|
||||
return AdsBidResult.GetPlatformType(priceInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查并刷新过期竞价
|
||||
private void CheckAndRefreshExpiredBids(AdsType _adsType)
|
||||
{
|
||||
Dictionary<PlatformType, List<AdsType>> expiredBids = BidPlatformManager.Instance.GetExpiredBids();
|
||||
|
||||
foreach (var kvp in expiredBids)
|
||||
{
|
||||
PlatformType platformName = kvp.Key;
|
||||
foreach (AdsType adType in kvp.Value)
|
||||
{
|
||||
LoggerUtils.Debug($"{platformName} 平台 {adType} 广告竞价已过期,重新加载广告");
|
||||
RefreshPlatformAds(platformName, adType);
|
||||
if (_adsType == adType)
|
||||
{
|
||||
LoggerUtils.Debug($"{platformName} 平台 {adType} 广告竞价已过期,重新加载广告");
|
||||
RefreshPlatformAds(platformName, adType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void RefreshPlatformAds(PlatformType platformName, AdsType adType)
|
||||
{
|
||||
switch (platformName)
|
||||
private void RefreshPlatformAds(PlatformType platformName, AdsType adType)
|
||||
{
|
||||
case PlatformType.Admob:
|
||||
RefreshAdmobAds(adType);
|
||||
break;
|
||||
case PlatformType.Topon:
|
||||
RefreshTopOnAds(adType);
|
||||
break;
|
||||
case PlatformType.AppLovin:
|
||||
RefreshMaxAds(adType);
|
||||
break;
|
||||
case PlatformType.Bigo:
|
||||
RefreshBigoAds(adType);
|
||||
break;
|
||||
case PlatformType.Kwai:
|
||||
RefreshKwaiAds(adType);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshAdmobAds(AdsType adType)
|
||||
{
|
||||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
AdmobAdsManager.Instance.LoadRewarded();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
AdmobAdsManager.Instance.LoadInterstitial();
|
||||
break;
|
||||
case AdsType.Banner:
|
||||
AdmobAdsManager.Instance.LoadBanner();
|
||||
break;
|
||||
case AdsType.Native:
|
||||
AdmobAdsManager.Instance.LoadNative();
|
||||
break;
|
||||
case AdsType.Splash:
|
||||
AdmobAdsManager.Instance.LoadSplash();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新TopOn广告
|
||||
private void RefreshTopOnAds(AdsType adType)
|
||||
{
|
||||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
TpnAdsManager.Instance.LoadRewarded();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
TpnAdsManager.Instance.LoadInterstitial();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新Max广告
|
||||
private void RefreshMaxAds(AdsType adType)
|
||||
{
|
||||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
MaxAdsManager.Instance.LoadRewarded();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
MaxAdsManager.Instance.LoadInterstitial();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新Bigo广告
|
||||
private void RefreshBigoAds(AdsType adType)
|
||||
{
|
||||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
BigoAdsManager.Instance.LoadRewarded();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
BigoAdsManager.Instance.LoadInterstitial();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshKwaiAds (AdsType adType)
|
||||
{
|
||||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
// todo: 刷新激励广告
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
// todo: 刷新插屏广告
|
||||
KwaiAdsManager.Instance.LoadInterstitialAd();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 广告看完回调
|
||||
/// </summary>
|
||||
public void OnRewardAdCallback(double price)
|
||||
{
|
||||
AdRewardCallback?.Invoke(price);
|
||||
AdRewardCallback = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据IvRules判断是否可以展示插屏
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IvRulesShow(IvType ivadType)
|
||||
{
|
||||
//1.获取远程配置
|
||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES");
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//2.解析配置
|
||||
var dates = JsonConvert.DeserializeObject<IvRulesData[]>(json);
|
||||
if (dates == null && dates.Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//3.获取IVADType对应的配置
|
||||
IvRulesData ivRulesData = null;
|
||||
foreach (var data in dates)
|
||||
{
|
||||
if (data.type == (int)ivadType)
|
||||
switch (platformName)
|
||||
{
|
||||
ivRulesData = data;
|
||||
case PlatformType.Admob:
|
||||
RefreshAdmobAds(adType);
|
||||
break;
|
||||
case PlatformType.Topon:
|
||||
RefreshTopOnAds(adType);
|
||||
break;
|
||||
case PlatformType.AppLovin:
|
||||
RefreshMaxAds(adType);
|
||||
break;
|
||||
case PlatformType.Bigo:
|
||||
RefreshBigoAds(adType);
|
||||
break;
|
||||
case PlatformType.Kwai:
|
||||
RefreshKwaiAds(adType);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ivRulesData == null)
|
||||
|
||||
private void RefreshAdmobAds(AdsType adType)
|
||||
{
|
||||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
AdmobAdsManager.Instance.LoadRewarded();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
AdmobAdsManager.Instance.LoadInterstitial();
|
||||
break;
|
||||
case AdsType.Banner:
|
||||
AdmobAdsManager.Instance.LoadBanner();
|
||||
break;
|
||||
case AdsType.Native:
|
||||
AdmobAdsManager.Instance.LoadNative();
|
||||
break;
|
||||
case AdsType.Splash:
|
||||
AdmobAdsManager.Instance.LoadSplash();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新TopOn广告
|
||||
private void RefreshTopOnAds(AdsType adType)
|
||||
{
|
||||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
TpnAdsManager.Instance.LoadRewarded();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
TpnAdsManager.Instance.LoadInterstitial();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新Max广告
|
||||
private void RefreshMaxAds(AdsType adType)
|
||||
{
|
||||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
MaxAdsManager.Instance.LoadRewarded();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
MaxAdsManager.Instance.LoadInterstitial();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新Bigo广告
|
||||
private void RefreshBigoAds(AdsType adType)
|
||||
{
|
||||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
BigoAdsManager.Instance.LoadRewarded();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
BigoAdsManager.Instance.LoadInterstitial();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshKwaiAds(AdsType adType)
|
||||
{
|
||||
switch (adType)
|
||||
{
|
||||
case AdsType.Rewarded:
|
||||
// todo: 刷新激励广告
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
break;
|
||||
case AdsType.Interstitial:
|
||||
// todo: 刷新插屏广告
|
||||
KwaiAdsManager.Instance.LoadInterstitialAd();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 广告看完回调
|
||||
/// </summary>
|
||||
public void OnRewardAdCallback(double price)
|
||||
{
|
||||
AdRewardCallback?.Invoke(price);
|
||||
AdRewardCallback = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据IvRules判断是否可以展示插屏
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IvRulesShow(IvType ivadType)
|
||||
{
|
||||
//1.获取远程配置
|
||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES");
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//2.解析配置
|
||||
var dates = JsonConvert.DeserializeObject<IvRulesData[]>(json);
|
||||
if (dates == null && dates.Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//3.获取IVADType对应的配置
|
||||
IvRulesData ivRulesData = null;
|
||||
foreach (var data in dates)
|
||||
{
|
||||
if (data.type == (int)ivadType)
|
||||
{
|
||||
ivRulesData = data;
|
||||
}
|
||||
}
|
||||
if (ivRulesData == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//4.判断skip(次安装跳过几次触发不展示广告)
|
||||
int skipLevel = ivRulesData.skipLevel;
|
||||
int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, 0);
|
||||
if (currentSkipLevel < skipLevel)
|
||||
{
|
||||
LoggerUtils.Debug($"[SDK] skipLevel limit");
|
||||
PlayerPrefsUtils.SavePlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, currentSkipLevel + 1);
|
||||
return false;
|
||||
}
|
||||
//5.判断overLevel(没跳过几次触发)
|
||||
int overLevel = ivRulesData.overLevel;
|
||||
int currentOverLevel = IvRulesConst.CurrentOverLevel;
|
||||
if (currentOverLevel < overLevel)
|
||||
{
|
||||
LoggerUtils.Debug($"[SDK] overLevel limit");
|
||||
IvRulesConst.CurrentOverLevel++;
|
||||
return false;
|
||||
}
|
||||
|
||||
//6.判断interval(广告时间间隔)
|
||||
int interval = ivRulesData.interval;
|
||||
long currentInterval = IvRulesConst.CurrentInterval;
|
||||
long localTimestamp = TimeUtils.GetLocalTimestamp();
|
||||
|
||||
if (localTimestamp < currentInterval + (interval * 1000L))
|
||||
{
|
||||
LoggerUtils.Debug($"[SDK] interval limit");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//4.判断skip(次安装跳过几次触发不展示广告)
|
||||
int skipLevel = ivRulesData.skipLevel;
|
||||
int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, 0);
|
||||
if (currentSkipLevel < skipLevel)
|
||||
{
|
||||
LoggerUtils.Debug($"[SDK] skipLevel limit");
|
||||
PlayerPrefsUtils.SavePlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, currentSkipLevel + 1);
|
||||
return false;
|
||||
}
|
||||
//5.判断overLevel(没跳过几次触发)
|
||||
int overLevel = ivRulesData.overLevel;
|
||||
int currentOverLevel = IvRulesConst.CurrentOverLevel;
|
||||
if (currentOverLevel < overLevel)
|
||||
{
|
||||
LoggerUtils.Debug($"[SDK] overLevel limit");
|
||||
IvRulesConst.CurrentOverLevel++;
|
||||
return false;
|
||||
}
|
||||
|
||||
//6.判断interval(广告时间间隔)
|
||||
int interval = ivRulesData.interval;
|
||||
long currentInterval = IvRulesConst.CurrentInterval;
|
||||
long localTimestamp = TimeUtils.GetLocalTimestamp();
|
||||
|
||||
if (localTimestamp < currentInterval + (interval * 1000L))
|
||||
{
|
||||
LoggerUtils.Debug($"[SDK] interval limit");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,203 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Firebase.RemoteConfig;
|
||||
using GoogleMobileAds.Api;
|
||||
using GoogleMobileAds.Common;
|
||||
using UnityEngine;
|
||||
|
||||
namespace WZ
|
||||
{
|
||||
|
||||
|
||||
public class AdsSplashManager : MonoBehaviour
|
||||
{
|
||||
public static AdsSplashManager Instance { get; private set; }
|
||||
public float backgroundTime = 0;
|
||||
private int timeoutDuration = 5;
|
||||
private bool _coldLaunch = true;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
public void InitSplash()
|
||||
{
|
||||
timeoutDuration = GetSplashConfigItem().loadtime;
|
||||
StartCoroutine(LoadSplashAdAdWithTimeout());
|
||||
}
|
||||
|
||||
private void OnAppStateChanged(AppState state)
|
||||
{
|
||||
if (_coldLaunch)
|
||||
{
|
||||
_coldLaunch = false;
|
||||
return;
|
||||
}
|
||||
if (state == AppState.Foreground)
|
||||
{
|
||||
LoggerUtils.Debug("[AppOpen] 进入前台");
|
||||
CheckSplashAdlash(false);
|
||||
}
|
||||
else if (state == AppState.Background)
|
||||
{
|
||||
backgroundTime = Time.realtimeSinceStartup;
|
||||
LoggerUtils.Debug("[AppOpen] 进入后台 :" + backgroundTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator LoadSplashAdAdWithTimeout()
|
||||
{
|
||||
// 开始加载广告
|
||||
AdsSDKManager.Instance.LoadSplashAd();
|
||||
// 等待5秒或直到广告加载完成
|
||||
float elapsedTime = 0f;
|
||||
while (elapsedTime < timeoutDuration && !AdsSDKManager.Instance.IsSplashAvailable())
|
||||
{
|
||||
elapsedTime += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
CheckSplashAdlash(true);
|
||||
}
|
||||
|
||||
IEnumerator DelayedAction()
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
CheckSplashAdlash(false);
|
||||
}
|
||||
|
||||
private void CheckSplashAdlash(bool isCold)
|
||||
{
|
||||
if (!isCold)
|
||||
{
|
||||
// 热启动
|
||||
// 当前有其他类型广告在展示
|
||||
LoggerUtils.Debug(" [AppOpen] 热启动 是否有广告在展示:" + AdsSDKManager.Instance.otherAdsOnShow);
|
||||
if (AdsSDKManager.Instance.otherAdsOnShow) return;
|
||||
|
||||
// 热启动开关
|
||||
var hotSplashSwitch = GetSplashConfigItem().hot_splash_switch == 1;
|
||||
LoggerUtils.Debug(" [AppOpen] 热启动 开关:" + hotSplashSwitch);
|
||||
if (!hotSplashSwitch)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 后台运行时间
|
||||
float resultTime = Time.realtimeSinceStartup - backgroundTime;
|
||||
float onlineTime = GetSplashConfigItem().hot_timegap;
|
||||
LoggerUtils.Debug(" [AppOpen] 后台运行时间差值:" + resultTime + " 在线参数值:" + onlineTime);
|
||||
if (resultTime < onlineTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AdsSDKManager.Instance.IsSplashAvailable())
|
||||
{
|
||||
LoggerUtils.Debug(" [AppOpen] 热启动 广告是否准备好:");
|
||||
AdsSDKManager.Instance.LoadSplashAd();
|
||||
return;
|
||||
}
|
||||
|
||||
// 展示热启动开屏
|
||||
AdsSDKManager.Instance.ShowSplashAd();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 冷启动
|
||||
// 首次启动
|
||||
var isNew = PlayerPrefsUtils.GetPlayerPrefsInt("Firstcold_Splash_Switch", 0) == 0;
|
||||
// 首次冷启动开关
|
||||
var isFirstShow = GetSplashConfigItem().firstcold_splash_switch == 1;
|
||||
// 冷启动开关
|
||||
var coldSplashSwitch = GetSplashConfigItem().cold_splash_switch == 1;
|
||||
LoggerUtils.Debug(" [AppOpen] 冷启动 开关:" + coldSplashSwitch + " 首次启动是否展示开屏:" + isFirstShow + " 新用户:" + isNew);
|
||||
// 新用户首次启动
|
||||
if (isNew)
|
||||
{
|
||||
PlayerPrefsUtils.SavePlayerPrefsInt("Firstcold_Splash_Switch", 1);
|
||||
if (!isFirstShow)
|
||||
{
|
||||
// 新用户首次不展示
|
||||
AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 新用户首次展示
|
||||
if (AdsSDKManager.Instance.IsSplashAvailable())
|
||||
{
|
||||
AdsSDKManager.Instance.ShowSplashAd();
|
||||
}
|
||||
else
|
||||
{
|
||||
AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke();
|
||||
AdsSDKManager.Instance.LoadSplashAd();
|
||||
LoggerUtils.Debug(" [AppOpen] 冷启动广告未准备好");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 非首次启动
|
||||
if (coldSplashSwitch)
|
||||
{
|
||||
// 展示冷启动
|
||||
if (AdsSDKManager.Instance.IsSplashAvailable())
|
||||
{
|
||||
AdsSDKManager.Instance.ShowSplashAd();
|
||||
}
|
||||
else
|
||||
{
|
||||
AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke();
|
||||
AdsSDKManager.Instance.LoadSplashAd();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AdsSDKManager.Instance.OnSplashAdCloseCallback?.Invoke();
|
||||
}
|
||||
}
|
||||
AppStateEventNotifier.AppStateChanged += OnAppStateChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private static string Splash_AD_RULES = "Splash_AD_RULES";
|
||||
private static string Splash_AD_RULES_DEFAULT_VALUE = "[{\"firstcold_splash_switch\":1,\"cold_splash_switch\":1,\"hot_splash_switch\":1,\"hot_timegap\":30,\"loadtime\":5}]";
|
||||
|
||||
public SplashConfigItem GetSplashConfigItem()
|
||||
{
|
||||
string jsonData = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString(Splash_AD_RULES, Splash_AD_RULES_DEFAULT_VALUE);
|
||||
SplashConfigItem[] configItems = DataUtils.FromJsonArray<SplashConfigItem>(jsonData);
|
||||
if (configItems.Length == 0 || configItems == null)
|
||||
{
|
||||
return new SplashConfigItem() { firstcold_splash_switch = 1, cold_splash_switch = 1, hot_splash_switch = 1, hot_timegap = 30, loadtime = 5 };
|
||||
}
|
||||
else
|
||||
{
|
||||
return configItems[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SplashConfigItem
|
||||
{
|
||||
public int firstcold_splash_switch;
|
||||
public int cold_splash_switch;
|
||||
public int hot_splash_switch;
|
||||
public int hot_timegap;
|
||||
public int loadtime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ad8d5f86e3dbf4c9986fcd1981e0be68
|
|
@ -2,16 +2,10 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BigoAds.Scripts.Api;
|
||||
using Script.Common;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.SDKManager.AdsSDKManager.Utils;
|
||||
using Script.Utils;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
public class BigoAdsManager : NormalSingleton<BigoAdsManager>, IAdService
|
||||
{
|
||||
|
|
|
@ -2,13 +2,9 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BigoAds.Scripts.Api;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.SDKManager.AdsSDKManager.Utils;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
|
||||
public class BigoInterstitialAdManager
|
||||
|
|
|
@ -2,12 +2,9 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BigoAds.Scripts.Api;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.BigoAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
|
||||
public class BigoRewardedAdManager
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Constant
|
||||
namespace WZ
|
||||
{
|
||||
public enum AdsType
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Constant
|
||||
namespace WZ
|
||||
{
|
||||
public enum BannerAliignType
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Constant
|
||||
namespace WZ
|
||||
{
|
||||
public enum IvType
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Constant
|
||||
namespace WZ
|
||||
{
|
||||
public enum PlatformType
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents
|
||||
|
||||
namespace WZ
|
||||
{
|
||||
public class AdsActionEvents
|
||||
{
|
||||
|
@ -14,12 +14,12 @@ namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents
|
|||
|
||||
public static void TrackAdClosed(PlatformType adPlatform, string adSource, string adUnitName, AdsType adFormat, string posotion, double value)
|
||||
{
|
||||
|
||||
AdsSDKManager.Instance.otherAdsOnShow = false;
|
||||
}
|
||||
|
||||
public static void TrackAdStartLoad(PlatformType adPlatform, string adSource, string adUnitName, AdsType adFormat)
|
||||
{
|
||||
|
||||
AdsSDKManager.Instance.otherAdsOnShow = true;
|
||||
}
|
||||
|
||||
public static void TrackAdLoaded(PlatformType adPlatform, string adSource, string adUnitName, AdsType adFormat, double loadTime)
|
||||
|
@ -33,7 +33,7 @@ namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents
|
|||
|
||||
public static void TrackAdFailToShow(PlatformType adPlatform, AdsType adFormat, string reason, string pos)
|
||||
{
|
||||
|
||||
AdsSDKManager.Instance.otherAdsOnShow = false;
|
||||
}
|
||||
|
||||
public static void TrackAdPosition(AdsType adFormat, string pos)
|
||||
|
|
|
@ -2,13 +2,10 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using Firebase.Analytics;
|
||||
using Newtonsoft.Json;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Utils;
|
||||
using Script.Utils;
|
||||
using Unity.VisualScripting.Antlr3.Runtime;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Events.AdsEvents
|
||||
namespace WZ
|
||||
{
|
||||
public class AdsKeyEvents : NormalSingleton<AdsKeyEvents>
|
||||
{
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback
|
||||
namespace WZ
|
||||
{
|
||||
public void OnSuccess()
|
||||
public class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback
|
||||
{
|
||||
Debug.Log("快手广告初始化成功");
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
KwaiAdsManager.Instance.LoadInterstitialAd();
|
||||
}
|
||||
public void OnSuccess()
|
||||
{
|
||||
Debug.Log("快手广告初始化成功");
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
KwaiAdsManager.Instance.LoadInterstitialAd();
|
||||
}
|
||||
|
||||
public void OnFail(int code, string msg)
|
||||
{
|
||||
Debug.LogFormat($"快手广告初始化失败 code is {code}, msg:{msg}");
|
||||
public void OnFail(int code, string msg)
|
||||
{
|
||||
Debug.LogFormat($"快手广告初始化失败 code is {code}, msg:{msg}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,31 +1,33 @@
|
|||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using UnityEngine;
|
||||
|
||||
public class InterstitialAdListener : IInterstitialAdListener
|
||||
namespace WZ
|
||||
{
|
||||
public void OnAdClick()
|
||||
public class InterstitialAdListener : IInterstitialAdListener
|
||||
{
|
||||
// 插页广告调整转换页 | Interstitial ad agjust conversion page
|
||||
}
|
||||
public void OnAdClick()
|
||||
{
|
||||
// 插页广告调整转换页 | Interstitial ad agjust conversion page
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
// 插页广告关闭 | Interstitial ad close
|
||||
}
|
||||
public void OnAdClose()
|
||||
{
|
||||
// 插页广告关闭 | Interstitial ad close
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
// 插页视频播放完成 | Interstitial video play complete
|
||||
KwaiAdsManager.Instance.OnInterstitialCallback();
|
||||
}
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
// 插页视频播放完成 | Interstitial video play complete
|
||||
KwaiAdsManager.Instance.OnInterstitialCallback();
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
// 插页视频曝光 | Interstitial video show
|
||||
}
|
||||
public void OnAdShow()
|
||||
{
|
||||
// 插页视频曝光 | Interstitial video show
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
Debug.LogError($"RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}");
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
Debug.LogError($"RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,35 +2,38 @@
|
|||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using UnityEngine;
|
||||
|
||||
public class InterstitialAdLoadListener : IInterstitialAdLoadListener
|
||||
namespace WZ
|
||||
{
|
||||
private const int maxLoadCount = 3;
|
||||
private int currentLoadCount = 0;
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
public class InterstitialAdLoadListener : IInterstitialAdLoadListener
|
||||
{
|
||||
// 受国内环境限制,国内无法请求到海外广告,需要加白。可以将trackId反馈给对接同学进行加白。| Due to the limitations of the domestic environment, it is not possible to request overseas advertisements in China, and it is necessary to add white. You can feedback the trackId to the contact peroson to add white.
|
||||
Debug.LogFormat($"InterstitialAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}");
|
||||
currentLoadCount++;
|
||||
if (currentLoadCount < maxLoadCount)
|
||||
private const int maxLoadCount = 3;
|
||||
private int currentLoadCount = 0;
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
// 受国内环境限制,国内无法请求到海外广告,需要加白。可以将trackId反馈给对接同学进行加白。| Due to the limitations of the domestic environment, it is not possible to request overseas advertisements in China, and it is necessary to add white. You can feedback the trackId to the contact peroson to add white.
|
||||
Debug.LogFormat($"InterstitialAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}");
|
||||
currentLoadCount++;
|
||||
if (currentLoadCount < maxLoadCount)
|
||||
{
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
Debug.Log($"InterstitialAdLoadListener#OnAdLoadStart , trackId:{trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
// price 单位是$(美元,ecpm) | price in $ (dollars, ecpm)
|
||||
Debug.Log($"InterstitialAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
if (double.TryParse(price, NumberStyles.Float, CultureInfo.InvariantCulture, out double result))
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiAdsManager.Instance.interstitiaAdRevenue = result;
|
||||
Debug.Log($"InterstitialAdLoadListener#OnAdLoadStart , trackId:{trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
// price 单位是$(美元,ecpm) | price in $ (dollars, ecpm)
|
||||
Debug.Log($"InterstitialAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
if (double.TryParse(price, NumberStyles.Float, CultureInfo.InvariantCulture, out double result))
|
||||
{
|
||||
KwaiAdsManager.Instance.interstitiaAdRevenue = result;
|
||||
Debug.Log($"InterstitialAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,130 +2,131 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using Script.SDKManager.AdsSDKManager.BigoAdsManager;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiAdsManager : NormalSingleton<KwaiAdsManager>
|
||||
namespace WZ
|
||||
{
|
||||
//目前都是测试id
|
||||
private const string appId = "899999";
|
||||
private const string token = "EaCw0AipSYyvf3E7";
|
||||
private const string rewardAdUnitId = "8999996001";
|
||||
private const string interstitialAdUnitId = "8999996002";
|
||||
|
||||
/// <summary>
|
||||
/// 目前是千倍广告价值
|
||||
/// </summary>
|
||||
public double rewardAdRevenue = 0;
|
||||
/// <summary>
|
||||
/// 插屏奖励价值 如果有竞价功能可能会用到
|
||||
/// </summary>
|
||||
public double interstitiaAdRevenue = 0;
|
||||
|
||||
private IRewardAdController rewardAdController;
|
||||
private IInterstitialAdController interstitialAdController;
|
||||
|
||||
public void Init()
|
||||
public class KwaiAdsManager : NormalSingleton<KwaiAdsManager>
|
||||
{
|
||||
bool debug = true; // Whether in debug mode. Plsease set to false when in release build.
|
||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||
.SetAppId(appId)
|
||||
.SetToken(token)
|
||||
.SetAppName("App Name") // Optional
|
||||
.SetDebugLog(debug) // Optional
|
||||
.Build();
|
||||
//目前都是测试id
|
||||
private const string appId = "899999";
|
||||
private const string token = "EaCw0AipSYyvf3E7";
|
||||
private const string rewardAdUnitId = "8999996001";
|
||||
private const string interstitialAdUnitId = "8999996002";
|
||||
|
||||
KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl());
|
||||
}
|
||||
/// <summary>
|
||||
/// 目前是千倍广告价值
|
||||
/// </summary>
|
||||
public double rewardAdRevenue = 0;
|
||||
/// <summary>
|
||||
/// 插屏奖励价值 如果有竞价功能可能会用到
|
||||
/// </summary>
|
||||
public double interstitiaAdRevenue = 0;
|
||||
|
||||
#region 激励广告
|
||||
private IRewardAdController rewardAdController;
|
||||
private IInterstitialAdController interstitialAdController;
|
||||
|
||||
/// <summary>
|
||||
/// 加载激励广告
|
||||
/// </summary>
|
||||
public void LoadRewardAd()
|
||||
{
|
||||
if (rewardAdController != null)
|
||||
public void Init()
|
||||
{
|
||||
rewardAdController.Destroy();
|
||||
rewardAdController = null;
|
||||
rewardAdRevenue = 0;
|
||||
bool debug = true; // Whether in debug mode. Plsease set to false when in release build.
|
||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||
.SetAppId(appId)
|
||||
.SetToken(token)
|
||||
.SetAppName("App Name") // Optional
|
||||
.SetDebugLog(debug) // Optional
|
||||
.Build();
|
||||
|
||||
KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl());
|
||||
}
|
||||
|
||||
rewardAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(rewardAdUnitId);
|
||||
rewardAdController.Load(kwaiRewardAdRequest, new RewardAdListener(), new RewardAdLoadListener());
|
||||
}
|
||||
#region 激励广告
|
||||
|
||||
/// <summary>
|
||||
/// 展示激励广告
|
||||
/// </summary>
|
||||
public void ShowRewardAd()
|
||||
{
|
||||
if (rewardAdController != null)
|
||||
/// <summary>
|
||||
/// 加载激励广告
|
||||
/// </summary>
|
||||
public void LoadRewardAd()
|
||||
{
|
||||
rewardAdController.Show();
|
||||
if (rewardAdController != null)
|
||||
{
|
||||
rewardAdController.Destroy();
|
||||
rewardAdController = null;
|
||||
rewardAdRevenue = 0;
|
||||
}
|
||||
|
||||
rewardAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(rewardAdUnitId);
|
||||
rewardAdController.Load(kwaiRewardAdRequest, new RewardAdListener(), new RewardAdLoadListener());
|
||||
}
|
||||
else
|
||||
|
||||
/// <summary>
|
||||
/// 展示激励广告
|
||||
/// </summary>
|
||||
public void ShowRewardAd()
|
||||
{
|
||||
if (rewardAdController != null)
|
||||
{
|
||||
rewardAdController.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadRewardAd();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 广告播放完成 获得奖励
|
||||
/// </summary>
|
||||
public void OnRewardAdCallback()
|
||||
{
|
||||
AdsSDKManager.Instance.OnRewardAdCallback(rewardAdRevenue);
|
||||
LoadRewardAd();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 广告播放完成 获得奖励
|
||||
/// </summary>
|
||||
public void OnRewardAdCallback()
|
||||
{
|
||||
AdsSDKManager.Instance.OnRewardAdCallback(rewardAdRevenue);
|
||||
LoadRewardAd();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#region 插屏
|
||||
|
||||
#region 插屏
|
||||
|
||||
public void LoadInterstitialAd()
|
||||
{
|
||||
if (interstitialAdController != null)
|
||||
public void LoadInterstitialAd()
|
||||
{
|
||||
interstitialAdController.Destroy();
|
||||
interstitialAdController = null;
|
||||
interstitiaAdRevenue = 0;
|
||||
if (interstitialAdController != null)
|
||||
{
|
||||
interstitialAdController.Destroy();
|
||||
interstitialAdController = null;
|
||||
interstitiaAdRevenue = 0;
|
||||
}
|
||||
|
||||
interstitialAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||
KwaiInterstitialAdRequest kwaiInterstitialAdRequest = new KwaiInterstitialAdRequest(interstitialAdUnitId);
|
||||
interstitialAdController.Load(kwaiInterstitialAdRequest, new InterstitialAdListener(), new InterstitialAdLoadListener());
|
||||
}
|
||||
|
||||
interstitialAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||
KwaiInterstitialAdRequest kwaiInterstitialAdRequest = new KwaiInterstitialAdRequest(interstitialAdUnitId);
|
||||
interstitialAdController.Load(kwaiInterstitialAdRequest, new InterstitialAdListener(), new InterstitialAdLoadListener());
|
||||
}
|
||||
|
||||
public void ShowInterstitialAd()
|
||||
{
|
||||
if (interstitialAdController != null)
|
||||
public void ShowInterstitialAd()
|
||||
{
|
||||
interstitialAdController.Show();
|
||||
if (interstitialAdController != null)
|
||||
{
|
||||
interstitialAdController.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadInterstitialAd();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
/// <summary>
|
||||
/// 广告播放完成 获得奖励
|
||||
/// </summary>
|
||||
public void OnInterstitialCallback()
|
||||
{
|
||||
if (AdsSDKManager.Instance.IsMoreAdsBidding)
|
||||
{
|
||||
AdsSDKManager.Instance.OnRewardAdCallback(interstitiaAdRevenue);
|
||||
}
|
||||
|
||||
LoadInterstitialAd();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 广告播放完成 获得奖励
|
||||
/// </summary>
|
||||
public void OnInterstitialCallback()
|
||||
{
|
||||
if (AdsSDKManager.Instance.IsMoreAdsBidding)
|
||||
{
|
||||
AdsSDKManager.Instance.OnRewardAdCallback(interstitiaAdRevenue);
|
||||
}
|
||||
|
||||
LoadInterstitialAd();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +1,40 @@
|
|||
using KwaiAds.Scripts.Api.Reward;
|
||||
using UnityEngine;
|
||||
|
||||
public class RewardAdListener : IRewardAdListener
|
||||
namespace WZ
|
||||
{
|
||||
public void OnAdClick()
|
||||
public class RewardAdListener : IRewardAdListener
|
||||
{
|
||||
// 激励广告调整转换页 | Reward ad adjustment conversion page
|
||||
}
|
||||
public void OnAdClick()
|
||||
{
|
||||
// 激励广告调整转换页 | Reward ad adjustment conversion page
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
// 激励广告关闭 | Reward ad close
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
}
|
||||
public void OnAdClose()
|
||||
{
|
||||
// 激励广告关闭 | Reward ad close
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
// 激励视频播放完成 | Reward video play complete
|
||||
}
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
// 激励视频播放完成 | Reward video play complete
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
// 激励视频曝光 | Reward video show
|
||||
}
|
||||
public void OnAdShow()
|
||||
{
|
||||
// 激励视频曝光 | Reward video show
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
Debug.LogFormat($"RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}");
|
||||
}
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
Debug.LogFormat($"RewardAdListener#OnAdShowFailed , code:{code}, msg:{msg}");
|
||||
}
|
||||
|
||||
public void OnRewardEarned()
|
||||
{
|
||||
// 获取到激励 | Reward earned
|
||||
KwaiAdsManager.Instance.OnRewardAdCallback();
|
||||
public void OnRewardEarned()
|
||||
{
|
||||
// 获取到激励 | Reward earned
|
||||
KwaiAdsManager.Instance.OnRewardAdCallback();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,34 +2,37 @@
|
|||
using KwaiAds.Scripts.Api.Reward;
|
||||
using UnityEngine;
|
||||
|
||||
public class RewardAdLoadListener : IRewardAdLoadListener
|
||||
namespace WZ
|
||||
{
|
||||
private const int maxLoadCount = 3;
|
||||
private int currentLoadCount = 0;
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
public class RewardAdLoadListener : IRewardAdLoadListener
|
||||
{
|
||||
// 受国内环境限制,国内无法请求到海外广告,需要加白。可以将trackId反馈给对接同学进行加白。| Due to the limitations of the domestic environment, it is not possible to request overseas advertisements in China, and it is necessary to add white. You can feedback the trackId to the contact peroson to add white.
|
||||
Debug.LogFormat($"RewardAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}");
|
||||
currentLoadCount++;
|
||||
if (currentLoadCount < maxLoadCount)
|
||||
private const int maxLoadCount = 3;
|
||||
private int currentLoadCount = 0;
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
// 受国内环境限制,国内无法请求到海外广告,需要加白。可以将trackId反馈给对接同学进行加白。| Due to the limitations of the domestic environment, it is not possible to request overseas advertisements in China, and it is necessary to add white. You can feedback the trackId to the contact peroson to add white.
|
||||
Debug.LogFormat($"RewardAdLoadListener#OnAdLoadFailed , trackId:{trackId}, code:{code}, msg:{msg}");
|
||||
currentLoadCount++;
|
||||
if (currentLoadCount < maxLoadCount)
|
||||
{
|
||||
KwaiAdsManager.Instance.LoadRewardAd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
Debug.Log($"RewardAdLoadListener#OnAdLoadStart , trackId:{trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
// price 单位是$(美元,ecpm) | price in $ (dollars, ecpm)
|
||||
if (double.TryParse(price, NumberStyles.Float, CultureInfo.InvariantCulture, out double result))
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiAdsManager.Instance.rewardAdRevenue = result;
|
||||
Debug.Log($"RewardAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
Debug.Log($"RewardAdLoadListener#OnAdLoadStart , trackId:{trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
// price 单位是$(美元,ecpm) | price in $ (dollars, ecpm)
|
||||
if (double.TryParse(price, NumberStyles.Float, CultureInfo.InvariantCulture, out double result))
|
||||
{
|
||||
KwaiAdsManager.Instance.rewardAdRevenue = result;
|
||||
Debug.Log($"RewardAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,14 +4,9 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Net.Security;
|
||||
using Firebase.Analytics;
|
||||
using Script.Common;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.SDKManager.AdsSDKManager.Utils;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.MaxAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
public class MaxAdsManager : NormalSingleton<MaxAdsManager>, IAdService
|
||||
{
|
||||
|
|
|
@ -5,15 +5,9 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using AnyThinkAds.Api;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
using Script.Common;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.SDKManager.AdsSDKManager.Utils;
|
||||
using Script.Utils;
|
||||
using SDKManager.AdsSDKManager.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.TpnAdsManager
|
||||
namespace WZ
|
||||
{
|
||||
public class TpnAdsManager : NormalSingleton<TpnAdsManager>, IAdService
|
||||
{
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.Utils;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public static class AdConfigParser
|
||||
{
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public class AdPlayCountManager
|
||||
{
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.Utils;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public struct AdPriceInfo
|
||||
{
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
|
||||
namespace Script.SDKManager.AdsSDKManager.Utils
|
||||
namespace WZ
|
||||
{
|
||||
[Serializable]
|
||||
public class AdTypeBidState
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SDKManager.AdsSDKManager.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public class ThreadUtils : MonoBehaviour
|
||||
{
|
||||
|
|
|
@ -4,10 +4,8 @@ using System.Collections.Generic;
|
|||
using EFSDK;
|
||||
using Firebase.RemoteConfig;
|
||||
using Newtonsoft.Json;
|
||||
using Script.Common;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
using WZ;
|
||||
|
||||
public class AppSDKManager : MonoBehaviour
|
||||
{
|
||||
|
@ -23,10 +21,15 @@ public class AppSDKManager : MonoBehaviour
|
|||
FireBaseSDKManager.Instance.Init();
|
||||
AdjustManager.Instance.Init();
|
||||
ShuShuMangage.Instance.Init();
|
||||
AdsSDKManager.Instance.InitSDK();
|
||||
|
||||
EFSdkManager.Instance.Init();
|
||||
}
|
||||
|
||||
public void Init(Action action)
|
||||
{
|
||||
AdsSDKManager.Instance.InitSDK(action);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 协程
|
||||
/// </summary>
|
||||
|
|
|
@ -1,46 +1,48 @@
|
|||
using EFSDK;
|
||||
using Firebase.Analytics;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
public class EFSdkManager : NormalSingleton<EFSdkManager>
|
||||
namespace WZ
|
||||
{
|
||||
public void Init()
|
||||
public class EFSdkManager : NormalSingleton<EFSdkManager>
|
||||
{
|
||||
EFSdk.get().Init((actionType, str) =>
|
||||
public void Init()
|
||||
{
|
||||
if (EFSdk.ActionType.COIN_CLICK == actionType)
|
||||
{
|
||||
//TOTO 游戏在此处理 点击金币弹广告的逻辑或其他
|
||||
}
|
||||
if (EFSdk.ActionType.BALLOON_CLICK == actionType)
|
||||
{
|
||||
//TOTO 游戏在此处理 点击宝箱弹广告的逻辑或其他
|
||||
}
|
||||
if (EFSdk.ActionType.COIN_SHOW == actionType)
|
||||
EFSdk.get().Init((actionType, str) =>
|
||||
{
|
||||
if (EFSdk.ActionType.COIN_CLICK == actionType)
|
||||
{
|
||||
//TOTO 游戏在此处理 点击金币弹广告的逻辑或其他
|
||||
}
|
||||
if (EFSdk.ActionType.BALLOON_CLICK == actionType)
|
||||
{
|
||||
//TOTO 游戏在此处理 点击宝箱弹广告的逻辑或其他
|
||||
}
|
||||
if (EFSdk.ActionType.COIN_SHOW == actionType)
|
||||
{
|
||||
|
||||
}
|
||||
if (EFSdk.ActionType.BOX_SHOW == actionType)
|
||||
{
|
||||
}
|
||||
if (EFSdk.ActionType.BOX_SHOW == actionType)
|
||||
{
|
||||
|
||||
}
|
||||
if (EFSdk.ActionType.GAM_LOAD_SUCC == actionType)
|
||||
{
|
||||
// 标签id,标识哪个WebView加载成功了
|
||||
int id = int.Parse(str);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (EFSdk.ActionType.GAM_LOAD_SUCC == actionType)
|
||||
{
|
||||
// 标签id,标识哪个WebView加载成功了
|
||||
int id = int.Parse(str);
|
||||
}
|
||||
});
|
||||
|
||||
SetSDKEventCallback();
|
||||
}
|
||||
SetSDKEventCallback();
|
||||
}
|
||||
|
||||
private void SetSDKEventCallback()
|
||||
{
|
||||
EFSdk.get().SetSDKEventCallback((eventName, dict) =>
|
||||
private void SetSDKEventCallback()
|
||||
{
|
||||
FireBaseAnalyticsManager.Instance.LogEvent(eventName, dict);
|
||||
ShuShuEvent.Instance.Track(eventName, dict);
|
||||
});
|
||||
EFSdk.get().SetSDKEventCallback((eventName, dict) =>
|
||||
{
|
||||
FireBaseAnalyticsManager.Instance.LogEvent(eventName, dict);
|
||||
ShuShuEvent.Instance.Track(eventName, dict);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,114 +3,112 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using Firebase.Analytics;
|
||||
using Newtonsoft.Json;
|
||||
using Script.Common;
|
||||
using Script.SDKManager.AdsSDKManager.Constant;
|
||||
using Script.SDKManager.AdsSDKManager.Events.AdsEvents;
|
||||
using Script.Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Firebase analytics事件上报
|
||||
/// </summary>
|
||||
public class FireBaseAnalyticsManager : NormalSingleton<FireBaseAnalyticsManager>
|
||||
namespace WZ
|
||||
{
|
||||
private const string KEY_SUPER_PROPERTIES = "KEY_SUPER_PROPERTIES";
|
||||
|
||||
private Dictionary<string, object> superProperties = new Dictionary<string, object>();
|
||||
|
||||
public void InitSuperProperties()
|
||||
/// <summary>
|
||||
/// Firebase analytics事件上报
|
||||
/// </summary>
|
||||
public class FireBaseAnalyticsManager : NormalSingleton<FireBaseAnalyticsManager>
|
||||
{
|
||||
string json = PlayerPrefsUtils.GetPlayerPrefsString(KEY_SUPER_PROPERTIES, "");
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
superProperties = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
|
||||
}
|
||||
}
|
||||
private const string KEY_SUPER_PROPERTIES = "KEY_SUPER_PROPERTIES";
|
||||
|
||||
private Dictionary<string, object> superProperties = new Dictionary<string, object>();
|
||||
|
||||
public void LogEvent(string eventName)
|
||||
{
|
||||
List<Parameter> parameterList = new List<Parameter>();
|
||||
if (superProperties != null)
|
||||
public void InitSuperProperties()
|
||||
{
|
||||
foreach (var superProperty in superProperties)
|
||||
string json = PlayerPrefsUtils.GetPlayerPrefsString(KEY_SUPER_PROPERTIES, "");
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
Parameter parameter = new Parameter(superProperty.Key, superProperty.Value.ToString());
|
||||
parameterList.Add(parameter);
|
||||
superProperties = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
|
||||
}
|
||||
}
|
||||
|
||||
FirebaseAnalytics.LogEvent(eventName, parameterList.ToArray());
|
||||
}
|
||||
|
||||
public void LogEvent(string eventName, Dictionary<string, string> dict)
|
||||
{
|
||||
List<Parameter> parameters = new List<Parameter>();
|
||||
foreach (var item in dict)
|
||||
public void LogEvent(string eventName)
|
||||
{
|
||||
Parameter parameter = new Parameter(item.Key, item.Value);
|
||||
parameters.Add(parameter);
|
||||
}
|
||||
Firebase.Analytics.FirebaseAnalytics.LogEvent(eventName, parameters.ToArray());
|
||||
}
|
||||
List<Parameter> parameterList = new List<Parameter>();
|
||||
if (superProperties != null)
|
||||
{
|
||||
foreach (var superProperty in superProperties)
|
||||
{
|
||||
Parameter parameter = new Parameter(superProperty.Key, superProperty.Value.ToString());
|
||||
parameterList.Add(parameter);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置用户属性
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="property"></param>
|
||||
public void SetUserProperty(string name, string property)
|
||||
{
|
||||
Firebase.Analytics.FirebaseAnalytics.SetUserProperty(name, property);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置用户属性
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="property"></param>
|
||||
public void SetUserProperty(Dictionary<string, object> propertys)
|
||||
{
|
||||
foreach (var property in propertys)
|
||||
{
|
||||
SetUserProperty(property.Key, property.Value.ToString());
|
||||
FirebaseAnalytics.LogEvent(eventName, parameterList.ToArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置公共事件属性
|
||||
/// </summary>
|
||||
/// <param name="propertys"></param>
|
||||
public void SetSuperProperties(Dictionary<string, object> propertys)
|
||||
{
|
||||
if (superProperties == null)
|
||||
public void LogEvent(string eventName, Dictionary<string, string> dict)
|
||||
{
|
||||
superProperties = new Dictionary<string, object>();
|
||||
List<Parameter> parameters = new List<Parameter>();
|
||||
foreach (var item in dict)
|
||||
{
|
||||
Parameter parameter = new Parameter(item.Key, item.Value);
|
||||
parameters.Add(parameter);
|
||||
}
|
||||
Firebase.Analytics.FirebaseAnalytics.LogEvent(eventName, parameters.ToArray());
|
||||
}
|
||||
|
||||
foreach (var property in propertys)
|
||||
/// <summary>
|
||||
/// 设置用户属性
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="property"></param>
|
||||
public void SetUserProperty(string name, string property)
|
||||
{
|
||||
superProperties[property.Key] = property.Value;
|
||||
Firebase.Analytics.FirebaseAnalytics.SetUserProperty(name, property);
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(superProperties);
|
||||
PlayerPrefsUtils.SavePlayerPrefsString(KEY_SUPER_PROPERTIES, json);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置用户属性
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="property"></param>
|
||||
public void SetUserProperty(Dictionary<string, object> propertys)
|
||||
{
|
||||
foreach (var property in propertys)
|
||||
{
|
||||
SetUserProperty(property.Key, property.Value.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置公共事件属性
|
||||
/// </summary>
|
||||
/// <param name="propertys"></param>
|
||||
public void SetSuperProperties(Dictionary<string, object> propertys)
|
||||
{
|
||||
if (superProperties == null)
|
||||
{
|
||||
superProperties = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
foreach (var property in propertys)
|
||||
{
|
||||
superProperties[property.Key] = property.Value;
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(superProperties);
|
||||
PlayerPrefsUtils.SavePlayerPrefsString(KEY_SUPER_PROPERTIES, json);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// FireBase收益上报
|
||||
/// </summary>
|
||||
/// <param name="ad_platform">聚合平台名称</param>
|
||||
/// <param name="ad_source">广告平台名称</param>
|
||||
/// <param name="ad_unit_name">广告位ID</param>
|
||||
/// <param name="ad_format">广告格式</param>
|
||||
/// <param name="revenue">单次展示收益</param>
|
||||
/// <param name="position">广告展示点位</param>
|
||||
/// <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)
|
||||
{
|
||||
var impressionParameters = new[] {
|
||||
/// <summary>
|
||||
/// FireBase收益上报
|
||||
/// </summary>
|
||||
/// <param name="ad_platform">聚合平台名称</param>
|
||||
/// <param name="ad_source">广告平台名称</param>
|
||||
/// <param name="ad_unit_name">广告位ID</param>
|
||||
/// <param name="ad_format">广告格式</param>
|
||||
/// <param name="revenue">单次展示收益</param>
|
||||
/// <param name="position">广告展示点位</param>
|
||||
/// <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)
|
||||
{
|
||||
var impressionParameters = new[] {
|
||||
new Firebase.Analytics.Parameter("ad_platform", ad_platform),
|
||||
new Firebase.Analytics.Parameter("ad_source", ad_source),
|
||||
new Firebase.Analytics.Parameter("ad_unit_name",ad_unit_name),
|
||||
|
@ -121,50 +119,51 @@ public class FireBaseAnalyticsManager : NormalSingleton<FireBaseAnalyticsManager
|
|||
new Firebase.Analytics.Parameter("number", number),
|
||||
};
|
||||
|
||||
string name = GetName();
|
||||
Firebase.Analytics.FirebaseAnalytics.LogEvent(name, impressionParameters);
|
||||
AdsKeyEvents.Instance.LogAdCountEvents(ad_format, revenue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 收益分离
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetName()
|
||||
{
|
||||
string name = "ad_impression";
|
||||
//获取在线参数
|
||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("revenue_fir");
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
return name;
|
||||
}
|
||||
var revenueAdjs = JsonConvert.DeserializeObject<RevenueData[]>(json);
|
||||
if (revenueAdjs == null && revenueAdjs.Length == 0)
|
||||
{
|
||||
return name;
|
||||
string name = GetName();
|
||||
Firebase.Analytics.FirebaseAnalytics.LogEvent(name, impressionParameters);
|
||||
AdsKeyEvents.Instance.LogAdCountEvents(ad_format, revenue);
|
||||
}
|
||||
|
||||
int totalRate = 0;
|
||||
//获取全部概率
|
||||
foreach (var item in revenueAdjs)
|
||||
/// <summary>
|
||||
/// 收益分离
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetName()
|
||||
{
|
||||
totalRate += item.rate;
|
||||
}
|
||||
//开始随机
|
||||
int randomValue = UnityEngine.Random.Range(0, totalRate);
|
||||
int accumulatedRate = 0;
|
||||
|
||||
//根据随机值定位
|
||||
foreach (var item in revenueAdjs)
|
||||
{
|
||||
accumulatedRate += item.rate;
|
||||
if (randomValue < accumulatedRate)
|
||||
string name = "ad_impression";
|
||||
//获取在线参数
|
||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("revenue_fir");
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
return item.name;
|
||||
return name;
|
||||
}
|
||||
var revenueAdjs = JsonConvert.DeserializeObject<RevenueData[]>(json);
|
||||
if (revenueAdjs == null && revenueAdjs.Length == 0)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
int totalRate = 0;
|
||||
//获取全部概率
|
||||
foreach (var item in revenueAdjs)
|
||||
{
|
||||
totalRate += item.rate;
|
||||
}
|
||||
//开始随机
|
||||
int randomValue = UnityEngine.Random.Range(0, totalRate);
|
||||
int accumulatedRate = 0;
|
||||
|
||||
//根据随机值定位
|
||||
foreach (var item in revenueAdjs)
|
||||
{
|
||||
accumulatedRate += item.rate;
|
||||
if (randomValue < accumulatedRate)
|
||||
{
|
||||
return item.name;
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,218 +2,219 @@
|
|||
using System.Globalization;
|
||||
using Firebase.Extensions;
|
||||
using Firebase.RemoteConfig;
|
||||
using Script.Utils;
|
||||
using SDK.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
public class FireBaseRemoteConfigManager : NormalSingleton<FireBaseRemoteConfigManager>
|
||||
namespace WZ
|
||||
{
|
||||
public void FetchRemoteConfig()
|
||||
public class FireBaseRemoteConfigManager : NormalSingleton<FireBaseRemoteConfigManager>
|
||||
{
|
||||
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
|
||||
public void FetchRemoteConfig()
|
||||
{
|
||||
if (task.Result == Firebase.DependencyStatus.Available)
|
||||
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
|
||||
{
|
||||
Firebase.RemoteConfig.FirebaseRemoteConfig.DefaultInstance.FetchAsync(TimeSpan.Zero).ContinueWithOnMainThread(task =>
|
||||
if (task.Result == Firebase.DependencyStatus.Available)
|
||||
{
|
||||
FirebaseRemoteConfig.DefaultInstance.ActivateAsync().ContinueWithOnMainThread(task =>
|
||||
Firebase.RemoteConfig.FirebaseRemoteConfig.DefaultInstance.FetchAsync(TimeSpan.Zero).ContinueWithOnMainThread(task =>
|
||||
{
|
||||
// adjust卸载监控
|
||||
FirebaseRemoteConfig.DefaultInstance.ActivateAsync().ContinueWithOnMainThread(task =>
|
||||
{
|
||||
// adjust卸载监控
|
||||
|
||||
/* 执行到这时,表示firebase接入正常,能获取到远端在线参数 */
|
||||
/* 执行到这时,表示firebase接入正常,能获取到远端在线参数 */
|
||||
|
||||
// 设置 firebase 初始化成功 flag
|
||||
// 设置 firebase 初始化成功 flag
|
||||
|
||||
// 初始化广告
|
||||
// 初始化广告
|
||||
|
||||
// 检查Adjust归因
|
||||
// 检查Adjust归因
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取int参数
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public int GetRemoteConfigInt(string key, int defaultValue = 0, bool IsEncrypt = false)
|
||||
{
|
||||
try
|
||||
/// <summary>
|
||||
/// 获取int参数
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public int GetRemoteConfigInt(string key, int defaultValue = 0, bool IsEncrypt = false)
|
||||
{
|
||||
string newKey = GetKey(key, IsEncrypt);
|
||||
// 获取值
|
||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey);
|
||||
try
|
||||
{
|
||||
string newKey = GetKey(key, IsEncrypt);
|
||||
// 获取值
|
||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey);
|
||||
|
||||
if (configValue.Source == ValueSource.RemoteValue)
|
||||
{
|
||||
int value = (int)GetValueLong(newKey, configValue);
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {value}, No Is defaultValue");
|
||||
return value;
|
||||
if (configValue.Source == ValueSource.RemoteValue)
|
||||
{
|
||||
int value = (int)GetValueLong(newKey, configValue);
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {value}, No Is defaultValue");
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}");
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取string参数
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public string GetRemoteConfigString(string key, string defaultValue = "", bool IsEncrypt = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
string newKey = GetKey(key, IsEncrypt);
|
||||
// 获取值
|
||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey);
|
||||
if (configValue.Source == ValueSource.RemoteValue)
|
||||
{
|
||||
string valueStr = GetValueStr(newKey, configValue);
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueStr}, No Is defaultValue");
|
||||
return valueStr;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}");
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}");
|
||||
return defaultValue;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取string参数
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public string GetRemoteConfigString(string key, string defaultValue = "", bool IsEncrypt = false)
|
||||
{
|
||||
try
|
||||
/// <summary>
|
||||
/// 获取bool参数
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public bool GetRemoteConfigBool(string key, bool defaultValue = false, bool IsEncrypt = false)
|
||||
{
|
||||
string newKey = GetKey(key, IsEncrypt);
|
||||
// 获取值
|
||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey);
|
||||
if (configValue.Source == ValueSource.RemoteValue)
|
||||
try
|
||||
{
|
||||
string valueStr = GetValueStr(newKey, configValue);
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueStr}, No Is defaultValue");
|
||||
return valueStr;
|
||||
string newKey = GetKey(key, IsEncrypt);
|
||||
// 获取值
|
||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey);
|
||||
|
||||
if (configValue.Source == ValueSource.RemoteValue)
|
||||
{
|
||||
bool valueBool = GetValueBool(newKey, configValue);
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueBool}, No Is defaultValue");
|
||||
return valueBool;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}");
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}");
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
return defaultValue;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取bool参数
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public bool GetRemoteConfigBool(string key, bool defaultValue = false, bool IsEncrypt = false)
|
||||
{
|
||||
try
|
||||
/// <summary>
|
||||
/// 获取float参数
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public float GetRemoteConfigFloat(string key, float defaultValue = 0, bool IsEncrypt = false)
|
||||
{
|
||||
string newKey = GetKey(key, IsEncrypt);
|
||||
// 获取值
|
||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey);
|
||||
|
||||
if (configValue.Source == ValueSource.RemoteValue)
|
||||
try
|
||||
{
|
||||
bool valueBool = GetValueBool(newKey, configValue);
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueBool}, No Is defaultValue");
|
||||
return valueBool;
|
||||
string newKey = GetKey(key, IsEncrypt);
|
||||
// 获取值
|
||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey);
|
||||
|
||||
if (configValue.Source == ValueSource.RemoteValue)
|
||||
{
|
||||
float valueFloat = (float)GetValueDouble(newKey, configValue);
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueFloat}, No Is defaultValue");
|
||||
return valueFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}");
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}");
|
||||
return defaultValue;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取float参数
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public float GetRemoteConfigFloat(string key, float defaultValue = 0, bool IsEncrypt = false)
|
||||
{
|
||||
try
|
||||
/// <summary>
|
||||
/// 是否是加密
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool IsEncrypt(string key)
|
||||
{
|
||||
string newKey = GetKey(key, IsEncrypt);
|
||||
// 获取值
|
||||
var configValue = FirebaseRemoteConfig.DefaultInstance.GetValue(newKey);
|
||||
return key.StartsWith("CCB", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
if (configValue.Source == ValueSource.RemoteValue)
|
||||
private string GetKey(string key, bool isEncrypt)
|
||||
{
|
||||
//ccb开头 忽略大小写
|
||||
return isEncrypt ? $"ccb{EncryptionUtils.AesEncrypt(AppSDKManager.PackageName, key)}" : key;
|
||||
}
|
||||
|
||||
private string GetValueStr(string key, ConfigValue configValue)
|
||||
{
|
||||
return IsEncrypt(key) ? EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue) : configValue.StringValue;
|
||||
}
|
||||
|
||||
private long GetValueLong(string key, ConfigValue configValue)
|
||||
{
|
||||
return IsEncrypt(key) ? long.Parse(EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue)) : configValue.LongValue;
|
||||
}
|
||||
|
||||
private bool GetValueBool(string key, ConfigValue configValue)
|
||||
{
|
||||
return IsEncrypt(key) ? bool.Parse(EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue)) : configValue.BooleanValue;
|
||||
}
|
||||
|
||||
private double GetValueDouble(string key, ConfigValue configValue)
|
||||
{
|
||||
if (IsEncrypt(key))
|
||||
{
|
||||
float valueFloat = (float)GetValueDouble(newKey, configValue);
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {valueFloat}, No Is defaultValue");
|
||||
return valueFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
return defaultValue;
|
||||
string valueStr = EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue);
|
||||
if (float.TryParse(valueStr, NumberStyles.Float, CultureInfo.InvariantCulture, out float result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return configValue.DoubleValue;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LoggerUtils.Debug($"[RemoteConfig] key is {key}, defaultValue is {defaultValue}, value is {defaultValue}, Is defaultValue");
|
||||
Debug.LogError($"Failed to get Remote Config value for key '{key}': {e.Message}");
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否是加密
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool IsEncrypt(string key)
|
||||
{
|
||||
return key.StartsWith("CCB", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private string GetKey(string key, bool isEncrypt)
|
||||
{
|
||||
//ccb开头 忽略大小写
|
||||
return isEncrypt ? $"ccb{EncryptionUtils.AesEncrypt(AppSDKManager.PackageName, key)}" : key;
|
||||
}
|
||||
|
||||
private string GetValueStr(string key, ConfigValue configValue)
|
||||
{
|
||||
return IsEncrypt(key) ? EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue) : configValue.StringValue;
|
||||
}
|
||||
|
||||
private long GetValueLong(string key, ConfigValue configValue)
|
||||
{
|
||||
return IsEncrypt(key) ? long.Parse(EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue)) : configValue.LongValue;
|
||||
}
|
||||
|
||||
private bool GetValueBool(string key, ConfigValue configValue)
|
||||
{
|
||||
return IsEncrypt(key) ? bool.Parse(EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue)) : configValue.BooleanValue;
|
||||
}
|
||||
|
||||
private double GetValueDouble(string key, ConfigValue configValue)
|
||||
{
|
||||
if (IsEncrypt(key))
|
||||
{
|
||||
string valueStr = EncryptionUtils.AesDecrypt(AppSDKManager.PackageName, configValue.StringValue);
|
||||
if (float.TryParse(valueStr, NumberStyles.Float, CultureInfo.InvariantCulture, out float result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return configValue.DoubleValue;
|
||||
}
|
||||
}
|
|
@ -3,19 +3,21 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using Firebase;
|
||||
using Firebase.RemoteConfig;
|
||||
using Script.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
public class FireBaseSDKManager : NormalSingleton<FireBaseSDKManager>
|
||||
namespace WZ
|
||||
{
|
||||
public void Init()
|
||||
public class FireBaseSDKManager : NormalSingleton<FireBaseSDKManager>
|
||||
{
|
||||
InitSDK();
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
InitSDK();
|
||||
}
|
||||
|
||||
private void InitSDK()
|
||||
{
|
||||
FireBaseRemoteConfigManager.Instance.FetchRemoteConfig();
|
||||
FireBaseAnalyticsManager.Instance.InitSuperProperties();
|
||||
private void InitSDK()
|
||||
{
|
||||
FireBaseRemoteConfigManager.Instance.FetchRemoteConfig();
|
||||
FireBaseAnalyticsManager.Instance.InitSuperProperties();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,91 +1,93 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Script.Utils;
|
||||
using ThinkingData.Analytics;
|
||||
|
||||
public class ShuShuEvent : NormalSingleton<ShuShuEvent>
|
||||
namespace WZ
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置用户属性
|
||||
/// </summary>
|
||||
public void UserSet(Dictionary<string, object> dic)
|
||||
public class ShuShuEvent : NormalSingleton<ShuShuEvent>
|
||||
{
|
||||
TDAnalytics.UserSet(dic);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置用户属性
|
||||
/// </summary>
|
||||
public void UserSet(Dictionary<string, object> dic)
|
||||
{
|
||||
TDAnalytics.UserSet(dic);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置公共事件属性
|
||||
/// </summary>
|
||||
/// <param name="superProperties"></param>
|
||||
public void SetSuperProperties(Dictionary<string, object> superProperties)
|
||||
{
|
||||
TDAnalytics.SetSuperProperties(superProperties);//设置公共事件属性
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置公共事件属性
|
||||
/// </summary>
|
||||
/// <param name="superProperties"></param>
|
||||
public void SetSuperProperties(Dictionary<string, object> superProperties)
|
||||
{
|
||||
TDAnalytics.SetSuperProperties(superProperties);//设置公共事件属性
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送事件
|
||||
/// </summary>
|
||||
public void Track(string eventName)
|
||||
{
|
||||
TDAnalytics.Track(eventName);
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送事件
|
||||
/// </summary>
|
||||
public void Track(string eventName)
|
||||
{
|
||||
TDAnalytics.Track(eventName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送事件
|
||||
/// </summary>
|
||||
public void Track(string eventName, string key1, object value1)
|
||||
{
|
||||
var extraInfo = new Dictionary<string, object>();
|
||||
if (key1 != null && value1 != null)
|
||||
{
|
||||
extraInfo[key1] = value1;
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送事件
|
||||
/// </summary>
|
||||
public void Track(string eventName, string key1, object value1)
|
||||
{
|
||||
var extraInfo = new Dictionary<string, object>();
|
||||
if (key1 != null && value1 != null)
|
||||
{
|
||||
extraInfo[key1] = value1;
|
||||
}
|
||||
|
||||
Track(eventName, extraInfo);
|
||||
}
|
||||
Track(eventName, extraInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送事件
|
||||
/// </summary>
|
||||
public void Track(string eventName, Dictionary<string, object> properties)
|
||||
{
|
||||
TDAnalytics.Track(eventName, properties);
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送事件
|
||||
/// </summary>
|
||||
public void Track(string eventName, Dictionary<string, object> properties)
|
||||
{
|
||||
TDAnalytics.Track(eventName, properties);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送事件
|
||||
/// </summary>
|
||||
public void Track(string eventName, Dictionary<string, string> properties)
|
||||
{
|
||||
var newProperties = properties.ToDictionary(
|
||||
pair => pair.Key,
|
||||
pair => (object)pair.Value
|
||||
);
|
||||
TDAnalytics.Track(eventName, newProperties);
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送事件
|
||||
/// </summary>
|
||||
public void Track(string eventName, Dictionary<string, string> properties)
|
||||
{
|
||||
var newProperties = properties.ToDictionary(
|
||||
pair => pair.Key,
|
||||
pair => (object)pair.Value
|
||||
);
|
||||
TDAnalytics.Track(eventName, newProperties);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数数收益上报
|
||||
/// </summary>
|
||||
/// <param name="ad_platform">聚合平台名称</param>
|
||||
/// <param name="ad_source">广告平台名称</param>
|
||||
/// <param name="ad_unit_name">广告位ID</param>
|
||||
/// <param name="ad_format">广告格式</param>
|
||||
/// <param name="revenue">单次展示收益</param>
|
||||
/// <param name="position">广告展示点位</param>
|
||||
/// <param name="number">第几次展示该格式的广告</param>
|
||||
public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, string ad_format, double revenue, string position, int number)
|
||||
{
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||
properties.Add("ad_platform", ad_platform);
|
||||
properties.Add("ad_source", ad_source);
|
||||
properties.Add("ad_unit_name", ad_unit_name);
|
||||
properties.Add("ad_format", ad_format);
|
||||
properties.Add("value", revenue);
|
||||
properties.Add("currency", "USD");
|
||||
properties.Add("position", position);
|
||||
properties.Add("number", number);
|
||||
/// <summary>
|
||||
/// 数数收益上报
|
||||
/// </summary>
|
||||
/// <param name="ad_platform">聚合平台名称</param>
|
||||
/// <param name="ad_source">广告平台名称</param>
|
||||
/// <param name="ad_unit_name">广告位ID</param>
|
||||
/// <param name="ad_format">广告格式</param>
|
||||
/// <param name="revenue">单次展示收益</param>
|
||||
/// <param name="position">广告展示点位</param>
|
||||
/// <param name="number">第几次展示该格式的广告</param>
|
||||
public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, string ad_format, double revenue, string position, int number)
|
||||
{
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||
properties.Add("ad_platform", ad_platform);
|
||||
properties.Add("ad_source", ad_source);
|
||||
properties.Add("ad_unit_name", ad_unit_name);
|
||||
properties.Add("ad_format", ad_format);
|
||||
properties.Add("value", revenue);
|
||||
properties.Add("currency", "USD");
|
||||
properties.Add("position", position);
|
||||
properties.Add("number", number);
|
||||
|
||||
TDAnalytics.Track("ad_impression", properties);
|
||||
TDAnalytics.Track("ad_impression", properties);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +1,23 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Script.Utils;
|
||||
using ThinkingData.Analytics;
|
||||
using UnityEngine;
|
||||
|
||||
public class ShuShuMangage : NormalSingleton<ShuShuMangage>
|
||||
namespace WZ
|
||||
{
|
||||
private const string appid = "80f6819a81c743cbad667ecf242f3133";
|
||||
private const string server = "https://global-receiver-ta.thinkingdata.cn";
|
||||
|
||||
public void Init()
|
||||
public class ShuShuMangage : NormalSingleton<ShuShuMangage>
|
||||
{
|
||||
// 初始化SDK
|
||||
TDAnalytics.Init(appid, server);
|
||||
//开启自动采集事件
|
||||
TDAnalytics.EnableAutoTrack(TDAutoTrackEventType.AppInstall | TDAutoTrackEventType.AppStart | TDAutoTrackEventType.AppEnd);
|
||||
//如果用户已登录,可以设置用户的账号ID作为身份唯一标识
|
||||
TDAnalytics.Login("TA");
|
||||
}
|
||||
private const string appid = "80f6819a81c743cbad667ecf242f3133";
|
||||
private const string server = "https://global-receiver-ta.thinkingdata.cn";
|
||||
|
||||
public void Init()
|
||||
{
|
||||
// 初始化SDK
|
||||
TDAnalytics.Init(appid, server);
|
||||
//开启自动采集事件
|
||||
TDAnalytics.EnableAutoTrack(TDAutoTrackEventType.AppInstall | TDAutoTrackEventType.AppStart | TDAutoTrackEventType.AppEnd);
|
||||
//如果用户已登录,可以设置用户的账号ID作为身份唯一标识
|
||||
TDAnalytics.Login("TA");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using WZ;
|
||||
|
||||
public class Test : MonoBehaviour
|
||||
{
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace WZ
|
||||
{
|
||||
public static class DataUtils
|
||||
{
|
||||
[System.Serializable]
|
||||
private class Wrapper<T>
|
||||
{
|
||||
public T[] items;
|
||||
}
|
||||
|
||||
public static T[] FromJsonArray<T>(string json)
|
||||
{
|
||||
string wrappedJson = $"{{\"items\":{json}}}";
|
||||
Wrapper<T> wrapper = JsonUtility.FromJson<Wrapper<T>>(wrappedJson);
|
||||
return wrapper.items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: be1bd83cd48f44fa59b93f7ee10ec4fc
|
|
@ -5,7 +5,7 @@ using System.Security.Cryptography;
|
|||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SDK.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public static class EncryptionUtils
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public static class LoggerUtils
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public class PlayerPrefsUtils
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Script.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public abstract class NormalSingleton<T> where T : new()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace Script.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public class TimeUtils
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.Utils
|
||||
namespace WZ
|
||||
{
|
||||
public class TimerUtils : MonoBehaviour
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue