747 lines
23 KiB
C#
747 lines
23 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using AdjustSdk;
|
||
using AnyThinkAds.ThirdParty.LitJson;
|
||
using Firebase.RemoteConfig;
|
||
using GoogleMobileAds.Api;
|
||
using Newtonsoft.Json;
|
||
using ThinkingAnalytics;
|
||
using ThinkingData.Analytics;
|
||
using UnityEngine;
|
||
#if UNITY_PURCHASE
|
||
using UnityEngine.Purchasing;
|
||
#endif
|
||
using WZ;
|
||
|
||
public class RushSDKManager : D_MonoSingleton<RushSDKManager>
|
||
{
|
||
#region vpn
|
||
public void StartAdInitialization(bool afterLoading,int level)
|
||
{
|
||
TransferManager.Instance.StartAdInitialization(afterLoading, level);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Loading events
|
||
private float _loadingStartTime;
|
||
private float _loadingEndTime;
|
||
public void StartLoading()
|
||
{
|
||
_loadingStartTime = Time.time;
|
||
Invoke(nameof(SendLoadingStartEvent),15);
|
||
}
|
||
|
||
public void LoadingEnd()
|
||
{
|
||
_loadingEndTime = Time.time - _loadingStartTime;
|
||
Invoke(nameof(SendLoadingEndEvent),15);
|
||
}
|
||
public void SendLoadingStartEvent()
|
||
{
|
||
LogEvent("loading_show");
|
||
}
|
||
|
||
public void SendLoadingEndEvent()
|
||
{
|
||
LogEvent("loading_end","pass_time",(int)_loadingEndTime);
|
||
}
|
||
|
||
#endregion
|
||
|
||
public static string GetSDKVersion()
|
||
{
|
||
return "1.0.0";
|
||
}
|
||
protected override void Initialized()
|
||
{
|
||
base.Initialized();
|
||
FileParse.Parse();
|
||
}
|
||
public void InitializeSdk(Action action, bool showLog)
|
||
{
|
||
LoggerUtils.Enabled = showLog;
|
||
#if UNITY_PURCHASE
|
||
IAPPurchaseManager.Instance.PreInitialize();
|
||
#endif
|
||
AdsSplashManager.Instance.SetSplashAdCloseCallback(action);
|
||
FireBaseSDKManager.Instance.Init();
|
||
ShuShuMangage.Instance.Init();
|
||
AdjustManager.Instance.Init();
|
||
|
||
#if UNITY_PURCHASE
|
||
IAPPurchaseManager.Instance.Initialize();
|
||
#endif
|
||
|
||
}
|
||
|
||
#if UNITY_PURCHASE
|
||
#region 支付
|
||
|
||
|
||
/// <summary>
|
||
/// 初始化回调
|
||
/// </summary>
|
||
public Action<bool, string> OnPurchaseInitComplete;
|
||
public void RegisterPurchaseInitHandler(Action<bool,string> _action)
|
||
{
|
||
OnPurchaseInitComplete = _action;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取 AppStore/Google Play 上所有配置的商品;
|
||
/// </summary>
|
||
/// <param name="_action">返回所有商品信息</param>
|
||
/// ex:
|
||
/// Product[0].metadata.localizedTitle
|
||
/// Product[0].metadata.localizedPriceString
|
||
/// Product[0].metadata.localizedDescription
|
||
/// Product[0].metadata.isoCurrencyCode
|
||
public Action<Product[]> OnGetProductsInfo;
|
||
public void RegisterProductsInfoHandler(Action<Product[]> _action)
|
||
{
|
||
OnGetProductsInfo += _action;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 支付回调
|
||
/// </summary>
|
||
public Action<PurchaseInfo> OnPurchaseComplete;
|
||
public void RegisterPurchaseCompletionHandler(Action<PurchaseInfo> _action)
|
||
{
|
||
OnPurchaseComplete = _action;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 订阅查询回调
|
||
/// </summary>
|
||
public Action<string, SubscribeInfo> OnSubscriptionQueriedByProductId;
|
||
public void QuerySubscriptionDataByProductId(string _pID,Action<string,SubscribeInfo> _action)
|
||
{
|
||
OnSubscriptionQueriedByProductId = _action;
|
||
IAPSubscribeManager.Instance.CheckSubscribeDataByProductId(_pID);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取商品价格
|
||
/// </summary>
|
||
/// <param name="_pID"></param>
|
||
/// <returns></returns>
|
||
public string GetProductPriceByID(string _pID)
|
||
{
|
||
return IAPPurchaseManager.Instance.GetProductPriceByID(_pID);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取商品信息
|
||
/// </summary>
|
||
/// <param name="pID"></param>
|
||
/// <returns></returns>
|
||
public Product GetProductInfoByID(string _pID)
|
||
{
|
||
return IAPPurchaseManager.Instance.GetProductInfoByID(_pID);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 动态添加商品ID
|
||
/// </summary>
|
||
/// <param name="_products">Product IDs</param>
|
||
public void AddProductsDynamic(Dictionary<string, ProductType> _products,Action<bool, string> _onProductsResult = null)
|
||
{
|
||
IAPPurchaseManager.Instance.AddProductsDynamic(_products,_onProductsResult);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化前静态添加商品ID
|
||
/// </summary>
|
||
/// <param name="_products">Product IDs</param>
|
||
public void AddProductsStatic(Dictionary<string, ProductType> _products)
|
||
{
|
||
IAPPurchaseManager.StaticProductDic = IAPPurchaseManager.StaticProductDic.Concat(_products).ToDictionary(postParK => postParK.Key, PostParV => PostParV.Value);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 点击购买方法
|
||
/// </summary>
|
||
/// <param name="_productId"> 商品SKU </param>
|
||
/// <param name="_productName"> 商品名称 </param>
|
||
/// <param name="_gameExtraParam"> 游戏拓展参数 </param>
|
||
public void PurchaseProductById(string _productId, string _productName, string _gameExtraParam = "")
|
||
{
|
||
IAPPurchaseManager.Instance.BuyProductByID(_productId, _productName,_gameExtraParam);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 游戏下发奖励后上报
|
||
/// </summary>
|
||
/// <param name="productName">商品名称</param>
|
||
/// <param name="productID">商品SKU ID</param>
|
||
/// <param name="orderID">订单ID</param>
|
||
/// <param name="gameExtra01">游戏拓展字段-购买商品数量</param>
|
||
/// <param name="gameExtra02">游戏拓展字段</param>
|
||
public void LogCheckingOrder(string _productName, string _productId, string _orderId, string gameExtra01, string gameExtra02)
|
||
{
|
||
|
||
#if !UNITY_EDITOR
|
||
IAPOrderManager.Instance.RemoveVerifySuccessOrder(_orderId);
|
||
IAPPurchaseManager.Instance.DoConfirmPendingPurchaseByID(_productId);
|
||
IAPEvent.LogChecingOrderBySdk(_productName, _productId, _orderId, gameExtra01, gameExtra02);
|
||
#endif
|
||
}
|
||
#endregion
|
||
#endif
|
||
|
||
#region 买量用户回调
|
||
|
||
public Action<bool, string> OnUserSourceListener;
|
||
|
||
/// Adjust归因回调
|
||
/// <summary>
|
||
/// <param name="is organic user">是否为买量用户</param>
|
||
/// <param name="adNetwork">adjust 返回的network字段</param>
|
||
/// </summary>
|
||
public void SetUserSourceListener(Action<bool, string> _action)
|
||
{
|
||
OnUserSourceListener = _action;
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
#region 跳转谷歌评价
|
||
public void Review()
|
||
{
|
||
var httpsPlayGoogleComStoreAppsDetailsID = "https://play.google.com/store/apps/details?id=" + Application.identifier;
|
||
Application.OpenURL(httpsPlayGoogleComStoreAppsDetailsID);
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
#region ad
|
||
|
||
|
||
/// <summary>
|
||
/// 展示激励广告
|
||
/// </summary>
|
||
/// <param name="position"></param>
|
||
/// <param name="callback"></param>
|
||
public void ShowRewardAd(string position, Action<bool, double> callback = null)
|
||
{
|
||
AdsActionEvents.TrackAdPosition(AdsType.Rewarded, position);
|
||
|
||
var _platform = TransferAndroidClass.IsVpnConnected() ? PlatformType.Admob : PlatformType.Topon;
|
||
|
||
bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady(_platform);
|
||
|
||
if (isRewardAdReady)
|
||
{
|
||
AdsSDKManager.Instance.ShowRewardAd(position, (isReward, revenue) =>
|
||
{
|
||
AdsSplashManager.Instance.backgroundTime = Time.realtimeSinceStartup;
|
||
if (isReward)
|
||
{
|
||
AdsSDKManager.Instance.ClearIvRules();
|
||
callback?.Invoke(true, revenue);
|
||
}
|
||
else
|
||
{
|
||
callback?.Invoke(false, 0);
|
||
}
|
||
}, () =>
|
||
{
|
||
callback?.Invoke(false, 0);
|
||
},_platform);
|
||
}
|
||
else
|
||
{
|
||
//AdsActionEvents.TrackAdFailToShow(AdsType.Rewarded, position, AdsShowFailType.NoFill);
|
||
callback?.Invoke(false, 0);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 展示插屏广告
|
||
/// </summary>
|
||
/// <param name="position"></param>
|
||
/// <param name="ivadType"></param>
|
||
/// <param name="callback"></param>
|
||
public void ShowInterstitial(string position, IvType ivadType = IvType.IV1, Action<double> callback = null)
|
||
{
|
||
AdsActionEvents.TrackAdPosition(AdsType.Interstitial, position);
|
||
//插屏展示逻辑
|
||
bool ivRulesShow = AdsSDKManager.Instance.IvRulesShow(ivadType);
|
||
var _platform = TransferAndroidClass.IsVpnConnected() ? PlatformType.Admob : PlatformType.Topon;
|
||
|
||
if (ivRulesShow)
|
||
{
|
||
//是否有缓存
|
||
bool isInterstitialReady = AdsSDKManager.Instance.IsInterstitialReady(_platform);
|
||
if (isInterstitialReady)
|
||
{
|
||
AdsSDKManager.Instance.ShowInterstitialAd(position, ivadType, (revenue) =>
|
||
{
|
||
//展示完一个插屏之后调用
|
||
IvRulesConst.OverLevels[ivadType.ToString()] = 1;
|
||
IvRulesConst.Intervals[ivadType.ToString()] = TimeUtils.GetLocalTimestamp();
|
||
AdsSplashManager.Instance.backgroundTime = Time.realtimeSinceStartup;
|
||
callback?.Invoke(revenue);
|
||
},_platform);
|
||
}
|
||
else
|
||
{
|
||
//AdsActionEvents.TrackAdFailToShow(AdsType.Interstitial, position, AdsShowFailType.NoFill);
|
||
callback?.Invoke(-1);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//AdsActionEvents.TrackAdFailToShow(AdsType.Interstitial, position, AdsShowFailType.RuleLimit);
|
||
callback?.Invoke(-1);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="bannerType">banner样式,Standard:普通banner;Collapsible:可折叠banner</param>
|
||
/// <param name="bannerAlignType">banner位置,CenterBottom:底部居中;CenterTop:顶部居中</param>
|
||
public void ShowBanner(BannerType bannerType, BannerAlignType bannerAlignType)
|
||
{
|
||
AdsActionEvents.TrackAdPosition(AdsType.Banner, "");
|
||
|
||
var _platform = TransferAndroidClass.IsVpnConnected() ? PlatformType.Admob : PlatformType.Topon;
|
||
if (AdsSDKManager.Instance.IsBannerAdReady(bannerType,_platform))
|
||
{
|
||
AdsSDKManager.Instance.ShowBanner(bannerType, bannerAlignType, _platform);
|
||
}
|
||
else
|
||
{
|
||
//AdsActionEvents.TrackAdFailToShow(AdsType.Banner, "", AdsShowFailType.NoFill);
|
||
}
|
||
}
|
||
|
||
public void HideBanner(BannerType bannerType)
|
||
{
|
||
AdsSDKManager.Instance.HideBanner(bannerType);
|
||
}
|
||
|
||
public bool IsNativeFullReady()
|
||
{
|
||
var adUnitId = StaticValue.AdmobFullNativeId;
|
||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="rectTransform"></param>
|
||
/// <param name="pCom"></param>
|
||
/// <param name="position"></param>
|
||
/// <param name="nativeTemplateStyle"></param>
|
||
public void ShowFullNative(RectTransform rectTransform, Camera pCom = null, string position = "", NativeTemplateStyle nativeTemplateStyle = null)
|
||
{
|
||
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
||
if (!IsNativeFullReady())
|
||
{
|
||
//AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
||
AdsActionEvents.TrackAdFailToShow(AdsType.Native,
|
||
position,
|
||
PlatformType.Admob.ToString(),
|
||
"",
|
||
StaticValue.AdmobFullNativeId,
|
||
AdPlayCountManager.GetAdsActionCount(AdsType.Native,position+AdPlayCountManager.POS_SUFFIX),
|
||
NativeType.Full,
|
||
"-1",
|
||
AdsShowFailType.NoFill.ToString()
|
||
);
|
||
return;
|
||
}
|
||
|
||
var adUnitId = StaticValue.AdmobFullNativeId;
|
||
|
||
if (nativeTemplateStyle == null)
|
||
{
|
||
nativeTemplateStyle = new NativeTemplateStyle
|
||
{
|
||
TemplateId = NativeTemplateId.Medium,
|
||
MainBackgroundColor = Color.white
|
||
};
|
||
}
|
||
|
||
var nativeAdPosition = NativeAdPosition.Create(nativeTemplateStyle, rectTransform, pCom);
|
||
|
||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition,NativeType.Full);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 获取全屏Native广告价值
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public double GetFullNativeRevenue()
|
||
{
|
||
if (!IsNativeFullReady())
|
||
{
|
||
return -1;
|
||
}
|
||
var adUnitId = StaticValue.AdmobFullNativeId;
|
||
return AdsSDKManager.Instance.GetNativeAdRevenue(adUnitId);
|
||
}
|
||
|
||
public void HideFullNative()
|
||
{
|
||
var adUnitId = StaticValue.AdmobFullNativeId;
|
||
AdsSDKManager.Instance.RemoveNativeAd(adUnitId);
|
||
}
|
||
|
||
public bool IsNativeReady()
|
||
{
|
||
var adUnitId = StaticValue.AdmobNativeId;
|
||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||
}
|
||
|
||
public void ShowNative(RectTransform rectTransform, Camera pCom = null, string position = "", NativeTemplateStyle nativeTemplateStyle = null)
|
||
{
|
||
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
||
if (!IsNativeReady())
|
||
{
|
||
//AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
||
AdsActionEvents.TrackAdFailToShow(AdsType.Native,
|
||
position,
|
||
PlatformType.Admob.ToString(),
|
||
"",
|
||
StaticValue.AdmobNativeId,
|
||
AdPlayCountManager.GetAdsActionCount(AdsType.Native,position+AdPlayCountManager.POS_SUFFIX),
|
||
NativeType.Full,
|
||
"-1",
|
||
AdsShowFailType.NoFill.ToString()
|
||
);
|
||
return;
|
||
}
|
||
|
||
if (nativeTemplateStyle == null)
|
||
{
|
||
nativeTemplateStyle = new NativeTemplateStyle
|
||
{
|
||
//除了中型Native,其他的都是Small
|
||
TemplateId = NativeTemplateId.Small,
|
||
//背景颜色
|
||
MainBackgroundColor = Color.white
|
||
};
|
||
}
|
||
|
||
var adUnitId = StaticValue.AdmobNativeId;
|
||
var nativeAdPosition = NativeAdPosition.Create(nativeTemplateStyle, rectTransform, pCom);
|
||
|
||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition,NativeType.Full);
|
||
}
|
||
|
||
public void HideNative()
|
||
{
|
||
var adUnitId = StaticValue.AdmobNativeId;
|
||
AdsSDKManager.Instance.RemoveNativeAd(adUnitId);
|
||
}
|
||
|
||
public bool IsSmallNativeReady()
|
||
{
|
||
var adUnitId = StaticValue.AdmobSmallNativeId;
|
||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||
}
|
||
|
||
public void ShowSmallNative(RectTransform rectTransform, Camera pCom = null, string position = "", NativeTemplateStyle nativeTemplateStyle = null)
|
||
{
|
||
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
||
if (!IsSmallNativeReady())
|
||
{
|
||
//AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
||
AdsActionEvents.TrackAdFailToShow(AdsType.Native,
|
||
position,
|
||
PlatformType.Admob.ToString(),
|
||
"",
|
||
StaticValue.AdmobSmallNativeId,
|
||
AdPlayCountManager.GetAdsActionCount(AdsType.Native,position+AdPlayCountManager.POS_SUFFIX),
|
||
NativeType.Small,
|
||
"-1",
|
||
AdsShowFailType.NoFill.ToString()
|
||
);
|
||
return;
|
||
}
|
||
|
||
if (nativeTemplateStyle == null)
|
||
{
|
||
nativeTemplateStyle = new NativeTemplateStyle
|
||
{
|
||
TemplateId = NativeTemplateId.Small,
|
||
MainBackgroundColor = Color.white
|
||
};
|
||
}
|
||
|
||
var adUnitId = StaticValue.AdmobSmallNativeId;
|
||
var nativeAdPosition = NativeAdPosition.Create(nativeTemplateStyle, rectTransform, pCom);
|
||
|
||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition,NativeType.Small);
|
||
}
|
||
|
||
public void HideSmallNative()
|
||
{
|
||
var adUnitId = StaticValue.AdmobSmallNativeId;
|
||
AdsSDKManager.Instance.RemoveNativeAd(adUnitId);
|
||
}
|
||
|
||
public bool IsMinddleNativeReady()
|
||
{
|
||
var adUnitId = StaticValue.AdmobMinddleNativeId;
|
||
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
||
}
|
||
|
||
public void ShowMinddleNative(RectTransform rectTransform, Camera pCom = null, string position = "", NativeTemplateStyle nativeTemplateStyle = null)
|
||
{
|
||
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
||
if (!IsMinddleNativeReady())
|
||
{
|
||
//AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
||
AdsActionEvents.TrackAdFailToShow(AdsType.Native,
|
||
position,
|
||
PlatformType.Admob.ToString(),
|
||
"",
|
||
StaticValue.AdmobMinddleNativeId,
|
||
AdPlayCountManager.GetAdsActionCount(AdsType.Native,position+AdPlayCountManager.POS_SUFFIX),
|
||
NativeType.Medium,
|
||
"-1",
|
||
AdsShowFailType.NoFill.ToString()
|
||
);
|
||
return;
|
||
}
|
||
|
||
if (nativeTemplateStyle == null)
|
||
{
|
||
nativeTemplateStyle = new NativeTemplateStyle
|
||
{
|
||
TemplateId = NativeTemplateId.Small,
|
||
MainBackgroundColor = Color.white
|
||
};
|
||
}
|
||
|
||
var adUnitId = StaticValue.AdmobMinddleNativeId;
|
||
var nativeAdPosition = NativeAdPosition.Create(nativeTemplateStyle, rectTransform, pCom);
|
||
|
||
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition,NativeType.Medium);
|
||
}
|
||
|
||
public void HideMinddleNative()
|
||
{
|
||
var adUnitId = StaticValue.AdmobMinddleNativeId;
|
||
AdsSDKManager.Instance.RemoveNativeAd(adUnitId);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 埋点
|
||
|
||
public void LogEvent(string eventName)
|
||
{
|
||
ShuShuEvent.Instance.Track(eventName);
|
||
FireBaseAnalyticsManager.Instance.LogEvent(eventName);
|
||
AdjustTrackEvent.Instance.TrackEventName(eventName, new Dictionary<string, object>());
|
||
}
|
||
|
||
public void LogEvent(string eventName, string key1, object value1)
|
||
{
|
||
ShuShuEvent.Instance.Track(eventName, key1, value1);
|
||
FireBaseAnalyticsManager.Instance.LogEvent(eventName, key1, value1);
|
||
AdjustTrackEvent.Instance.TrackEventName(eventName, new Dictionary<string, object>
|
||
{
|
||
[key1] = value1
|
||
});
|
||
|
||
}
|
||
|
||
public void LogEvent(string eventName, Dictionary<string, object> extraInfo)
|
||
{
|
||
ShuShuEvent.Instance.Track(eventName, extraInfo);
|
||
FireBaseAnalyticsManager.Instance.LogEvent(eventName, extraInfo);
|
||
AdjustTrackEvent.Instance.TrackEventName(eventName, extraInfo);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 公共事件属性
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
public void SetSuperProperties(Dictionary<string, object> args)
|
||
{
|
||
ShuShuEvent.Instance.SetSuperProperties(args);
|
||
FireBaseAnalyticsManager.Instance.SetSuperProperties(args);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 用户属性
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
public void SetUserProperties(Dictionary<string, object> args)
|
||
{
|
||
ShuShuEvent.Instance.UserSet(args);
|
||
FireBaseAnalyticsManager.Instance.SetUserProperty(args);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 在线参数
|
||
|
||
public bool GetRemoteConfigBool(string key, bool defaultValue = false)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return defaultValue;
|
||
}
|
||
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigBool(key, defaultValue);
|
||
}
|
||
|
||
public int GetRemoteConfigInt(string key, int defaultValue = 0)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return defaultValue;
|
||
}
|
||
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt(key, defaultValue);
|
||
}
|
||
|
||
public string GetRemoteConfigStr(string key, string defaultValue = "")
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return defaultValue;
|
||
}
|
||
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigString(key, defaultValue);
|
||
}
|
||
|
||
public float GetRemoteConfigFloat(string key, float defaultValue = 0)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return defaultValue;
|
||
}
|
||
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigFloat(key, defaultValue);
|
||
}
|
||
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 是否是自然量用户
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool InOrganic()
|
||
{
|
||
return AdjustNetwork.Instance.InOrganic();
|
||
}
|
||
|
||
public string GetGaid()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return "gaid";
|
||
}
|
||
return AdjustManager.Instance.GetGdid();
|
||
}
|
||
|
||
public string GetAndroidId()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return "androidid";
|
||
}
|
||
string androidId = "unknown";
|
||
try
|
||
{
|
||
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
||
using (AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
|
||
using (AndroidJavaClass settingsSecure = new AndroidJavaClass("android.provider.Settings$Secure"))
|
||
{
|
||
// 调用 Settings.Secure.getString() 方法获取 ANDROID_ID
|
||
androidId = settingsSecure.CallStatic<string>(
|
||
"getString",
|
||
currentActivity.Call<AndroidJavaObject>("getContentResolver"),
|
||
"android_id"
|
||
);
|
||
}
|
||
}
|
||
catch (System.Exception e)
|
||
{
|
||
LoggerUtils.Error("获取 Android ID 出错: " + e.Message);
|
||
}
|
||
return androidId;
|
||
}
|
||
|
||
public string GetAdid()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return "adid";
|
||
}
|
||
return AdjustManager.Instance.GetAdid();
|
||
}
|
||
|
||
public string GetUserAgent()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return "GetUserAgent";
|
||
}
|
||
try
|
||
{
|
||
// 获取Java的System类
|
||
using (AndroidJavaClass systemClass = new AndroidJavaClass("java.lang.System"))
|
||
{
|
||
// 调用System.getProperty("http.agent")方法
|
||
string httpAgent = systemClass.CallStatic<string>("getProperty", "http.agent");
|
||
return httpAgent;
|
||
}
|
||
}
|
||
catch (System.Exception e)
|
||
{
|
||
Debug.LogError("获取http.agent失败: " + e.Message);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
public string GetSSAccountId()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return "GetSSAccountId";
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public string GetSSDistinctId()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return "GetSSDistinctId";
|
||
}
|
||
LoggerUtils.Debug("GetSSDistinctId:" + TDAnalytics.GetDistinctId());
|
||
return TDAnalytics.GetDistinctId();
|
||
}
|
||
|
||
public string GetSSSuperProperties()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return "GetSSSuperProperties";
|
||
}
|
||
|
||
var superProperties = TDAnalytics.GetSuperProperties();
|
||
LoggerUtils.Debug("GetSSDistinctId:" + JsonMapper.ToJson(superProperties));
|
||
return superProperties == null ? "" : superProperties.ToString();
|
||
}
|
||
|
||
public void OpenPrivacy()
|
||
{
|
||
Application.OpenURL(StaticValue.PrivacyUrl);
|
||
}
|
||
|
||
|
||
}
|