1056 lines
30 KiB
C#
1056 lines
30 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using AdjustSdk;
|
||
using AnyThinkAds.ThirdParty.LitJson;
|
||
using EFSDK;
|
||
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>
|
||
{
|
||
|
||
public static string GetSDKVersion()
|
||
{
|
||
return "1.0.4.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
|
||
FireBaseSDKManager.Instance.Init();
|
||
ShuShuMangage.Instance.Init();
|
||
AdmobAdsManager.Instance.RefreshAdsData();
|
||
AdmobAdsManager.Instance.Initialize();
|
||
AdjustManager.Instance.Init();
|
||
AdsSDKManager.Instance.InitSDK(action);
|
||
EFSdkManager.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>
|
||
/// 多类型广告竞价:激励、插屏、全屏Native
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public AdsType GetAdBidType()
|
||
{
|
||
return AdsSDKManager.Instance.GetAdBidType();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否已缓存激励广告
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool IsRewardedAdReady()
|
||
{
|
||
return AdsSDKManager.Instance.IsRewardAdReady(); ;
|
||
}
|
||
|
||
/// <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);
|
||
bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady();
|
||
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);
|
||
}
|
||
});
|
||
}
|
||
else
|
||
{
|
||
AdsActionEvents.TrackAdFailToShow(AdsType.Rewarded, position, AdsShowFailType.NoFill);
|
||
callback?.Invoke(false, 0);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 是否已缓存插屏
|
||
/// </summary>
|
||
public bool IsInterstitialAdReady()
|
||
{
|
||
return AdsSDKManager.Instance.IsInterstitialReady();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否能展示插屏
|
||
/// </summary>
|
||
/// <param name="ivType"></param>
|
||
/// <returns></returns>
|
||
public bool CanShowInterstitialAd(IvType ivType)
|
||
{
|
||
return AdsSDKManager.Instance.IvRulesShow(ivType, false);
|
||
}
|
||
|
||
/// <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, bool ivRules = true)
|
||
{
|
||
AdsActionEvents.TrackAdPosition(AdsType.Interstitial, position);
|
||
//插屏展示逻辑
|
||
bool ivRulesShow = AdsSDKManager.Instance.IvRulesShow(ivadType);
|
||
if (!ivRules)
|
||
{
|
||
//激励竞价不能被规则限制
|
||
//是否有缓存
|
||
bool isInterstitialReady = AdsSDKManager.Instance.IsInterstitialReady();
|
||
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);
|
||
});
|
||
}
|
||
else
|
||
{
|
||
AdsActionEvents.TrackAdFailToShow(AdsType.Interstitial, position, AdsShowFailType.NoFill);
|
||
callback?.Invoke(-1);
|
||
}
|
||
}
|
||
if (ivRulesShow && ivRules)
|
||
{
|
||
//是否有缓存
|
||
bool isInterstitialReady = AdsSDKManager.Instance.IsInterstitialReady();
|
||
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);
|
||
});
|
||
}
|
||
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, "");
|
||
|
||
if (AdsSDKManager.Instance.IsBannerAdReady(bannerType))
|
||
{
|
||
AdsSDKManager.Instance.ShowBanner(bannerType, bannerAlignType);
|
||
}
|
||
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);
|
||
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);
|
||
}
|
||
|
||
|
||
/// <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);
|
||
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);
|
||
}
|
||
|
||
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);
|
||
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);
|
||
}
|
||
|
||
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);
|
||
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);
|
||
}
|
||
|
||
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
|
||
|
||
#region EFSDK
|
||
|
||
/// <summary>
|
||
/// 展示WebView
|
||
/// </summary>
|
||
/// <param name="id">标签id,存在多个WebView时,用于标识WebView</param>
|
||
/// <param name="pos">广告位</param>
|
||
/// <param name="url">网址</param>
|
||
/// <param name="pRect">WebView展示区域的RectTransform</param>
|
||
/// <param name="pCam">可不传;传值的话要传正交相机</param>
|
||
public void ShowWebView(int id, string pos, string url, RectTransform pRect, Camera pCam = null)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
|
||
string newUrl = url.Replace("{gaid}", RushSDKManager.Instance.GetGaid());
|
||
EFSdkManager.Instance.AddUrl(id, url);
|
||
EFSdkManager.Instance.SetOkspinShowPos(pos);
|
||
EFSdk.get().ShowWebView(id, newUrl, pRect, pCam);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 移除所有原生WebView, 回到游戏时调用
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public void RemoveAll()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().RemoveAll();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 刷新当前页面
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public void Refresh()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().Refresh();
|
||
}
|
||
|
||
public void CanGoback(Action<bool> canGobackAction)
|
||
{
|
||
EFSdk.get().CanGoback(canGobackAction);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 回上一页
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public void GoBack()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().CanGoback((IsGoback) =>
|
||
{
|
||
if (IsGoback)
|
||
{
|
||
EFSdk.get().GoBack();
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 设置推送开关, SDK默认关闭通知
|
||
/// </summary>
|
||
/// <param name="isOpen"></param>
|
||
public void SetPushSwitch(bool isOpen)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().SetPushSwitch(isOpen);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 向SDK上报当前金币总数,每次金币变化都要调用一次
|
||
/// </summary>
|
||
/// <param name="totalGold"></param>
|
||
public void SendTotalGold2SDK(int totalGold)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().SendTotalGold2SDK(totalGold);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 向SDK上报当前要提现的现金额,每次变化都要调用一次
|
||
/// </summary>
|
||
/// <param name="cashNum"></param>
|
||
public void SendCashNum2SDK(double cashNum)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().SendCashNum2SDK(cashNum);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 向SDK上报 游戏名字(当前语言的),每次语言变化都上报
|
||
/// </summary>
|
||
/// <param name="gameName"></param>
|
||
public void SetGameName(string gameName)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().SetGameName(gameName);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置当前游戏语言是否是 巴西语
|
||
///
|
||
/// </summary>
|
||
/// <param name="isPT">巴西语传 true, 其他的都传 false </param>
|
||
public void SetCurrLang(bool isPT)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().SetCurrLang(isPT);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 消息类通知弹出间隔,SDK默认设置为60秒(在线参数控制)-Key: messagenotif Value:60
|
||
/// </summary>
|
||
/// <param name="timeSeconds"></param>
|
||
public void SetPushMessagenotif(int timeSeconds)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().SetPushMessagenotif(timeSeconds);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 持续性通知在进入游戏时弹出的时间间隔,SDK默认设置为300秒(在线参数控制 )-Key:persistentnotif Value:300
|
||
/// </summary>
|
||
/// <param name="timeSeconds"></param>
|
||
public void SetPushPersistentnotif(int timeSeconds)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().SetPushPersistentnotif(timeSeconds);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 每次回调游戏的onResume的时候都调用一次,获取游戏要跳转的页面
|
||
/// </summary>
|
||
/// <returns>
|
||
/// 0 不需要进行任何跳转
|
||
/// 1 进行游戏主页
|
||
/// 2 进入游戏的金币提现界面
|
||
/// 3 进入对应小游戏1界面
|
||
/// 4 进入对应小游戏2界面
|
||
/// </returns>
|
||
public int GetJumpPage()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return 0;
|
||
}
|
||
int pageId = EFSdk.get().GetJumpPage();
|
||
return pageId;
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取当前是否有通知权限
|
||
/// </summary>
|
||
public bool HasNotifyPermission()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return false;
|
||
}
|
||
return EFSdk.get().HasNotifyPermission();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 请求获取通知权限
|
||
/// <param name="action">授权弹窗关闭回调 bool:表示用户是否允许了权限 true:有权限 false:无权限</param>
|
||
/// </summary>
|
||
public void ReqNotifyPermission(Action<bool> action)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
// 如果没有通知权限就尝试申请通知权限
|
||
if (!HasNotifyPermission())
|
||
{
|
||
EFSdk.get().ReqNotifyPermission(isgGranted =>
|
||
{
|
||
//收到回调之后,可以认为权限申请弹窗弹出来了
|
||
if (isgGranted)
|
||
{
|
||
//用户已同意授权
|
||
}
|
||
else
|
||
{
|
||
//用户拒绝了授权
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 满足条件:未领取 R$0.1 的 买量用户, 调用这个方法
|
||
/// </summary>
|
||
public void SubscribeUnclaimed01()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().SubscribeUnclaimed01();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 不满足条件:未领取 R$0.1 的 买量用户, 调用这个方法
|
||
/// </summary>
|
||
public void UnSubscribeUnclaimed01()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().UnSubscribeUnclaimed01();
|
||
}
|
||
|
||
/// <summary>
|
||
// 满足条件: 在排队中 且 当日R$1 未领取 的买量用户, 调用这个方法
|
||
/// </summary>
|
||
public void SubscribePending1()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().SubscribePending1();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 不满足条件: 在排队中 且 当日R$1 未领取 的买量用户, 调用这个方法
|
||
/// </summary>
|
||
public void UnSubscribePending1()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().UnSubscribePending1();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 订阅Firebase推送主题
|
||
/// </summary>
|
||
/// <param name="topic">主题名称</param>
|
||
public void SubscribeToTopic(string topic)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().SubscribeToTopic(topic);
|
||
}
|
||
|
||
/// 取消订阅Firebase推送主题
|
||
/// </summary>
|
||
/// <param name="topic">主题名称</param>
|
||
public void UnSubscribeToTopic(string topic)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().UnSubscribeToTopic(topic);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 可覆盖广告的Toast
|
||
/// </summary>
|
||
/// <param name="message"></param>
|
||
public void ShowToast(string message)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().ShowToast(message);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 定时远程推送
|
||
/// </summary>
|
||
public void AutoLocalPush(bool isOpen)
|
||
{
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// Webview展示成功后回调
|
||
/// </summary>
|
||
/// <param name="action"></param>
|
||
public void WebviewShowSuccess(Action<string> action)
|
||
{
|
||
EFSdkManager.Instance.SetWebviewShowSuccessAction(action);
|
||
}
|
||
|
||
#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 null;
|
||
}
|
||
|
||
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);
|
||
}
|
||
}
|