2025-09-01 05:59:06 +00:00
|
|
|
|
using System;
|
2025-08-31 08:42:48 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2025-09-02 09:36:19 +00:00
|
|
|
|
using AdjustSdk;
|
2025-09-05 09:58:34 +00:00
|
|
|
|
using AnyThinkAds.ThirdParty.LitJson;
|
2025-09-01 08:27:45 +00:00
|
|
|
|
using EFSDK;
|
|
|
|
|
using Firebase.RemoteConfig;
|
2025-09-02 10:06:58 +00:00
|
|
|
|
using GoogleMobileAds.Api;
|
2025-09-01 09:57:19 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2025-09-02 09:36:19 +00:00
|
|
|
|
using ThinkingAnalytics;
|
2025-09-05 09:58:34 +00:00
|
|
|
|
using ThinkingData.Analytics;
|
2025-08-31 08:42:48 +00:00
|
|
|
|
using UnityEngine;
|
2025-09-01 10:32:50 +00:00
|
|
|
|
using WZ;
|
2025-08-31 08:42:48 +00:00
|
|
|
|
|
2025-09-01 13:28:17 +00:00
|
|
|
|
public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
2025-09-03 08:12:41 +00:00
|
|
|
|
{
|
2025-09-02 08:13:06 +00:00
|
|
|
|
public void Init(Action action, bool showLog)
|
2025-08-31 08:42:48 +00:00
|
|
|
|
{
|
2025-09-02 08:13:06 +00:00
|
|
|
|
LoggerUtils.Enabled = showLog;
|
2025-09-01 13:28:17 +00:00
|
|
|
|
FileParse.Parse();
|
|
|
|
|
// AdConfigParser.Parse();
|
2025-09-02 00:58:55 +00:00
|
|
|
|
FireBaseSDKManager.Instance.Init();
|
2025-09-04 06:24:18 +00:00
|
|
|
|
ShuShuMangage.Instance.Init();
|
2025-09-01 13:28:17 +00:00
|
|
|
|
AdmobAdsManager.Instance.RefreshAdsData();
|
|
|
|
|
AdmobAdsManager.Instance.Initialize();
|
2025-08-31 08:42:48 +00:00
|
|
|
|
AdjustManager.Instance.Init();
|
2025-09-02 12:45:05 +00:00
|
|
|
|
AdsSDKManager.Instance.InitSDK(action);
|
2025-09-01 08:27:45 +00:00
|
|
|
|
EFSdkManager.Instance.Init();
|
2025-08-31 08:42:48 +00:00
|
|
|
|
}
|
2025-09-01 11:10:21 +00:00
|
|
|
|
|
2025-09-01 10:32:50 +00:00
|
|
|
|
|
2025-08-31 08:42:48 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 协程
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="coroutine"></param>
|
|
|
|
|
public void Coroutine(IEnumerator coroutine)
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(coroutine);
|
|
|
|
|
}
|
2025-09-01 05:59:06 +00:00
|
|
|
|
|
2025-09-01 09:57:19 +00:00
|
|
|
|
#region ad
|
|
|
|
|
|
2025-09-02 06:20:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否已缓存激励广告
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2025-09-02 08:13:06 +00:00
|
|
|
|
public bool IsRewardedAdReady()
|
2025-09-02 06:20:54 +00:00
|
|
|
|
{
|
|
|
|
|
return AdsSDKManager.Instance.IsRewardAdReady();;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 展示激励广告
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="position"></param>
|
|
|
|
|
/// <param name="callback"></param>
|
2025-09-01 15:21:18 +00:00
|
|
|
|
public void ShowRewardAd(string position, Action<bool,double> callback = null)
|
|
|
|
|
{
|
2025-09-03 11:58:43 +00:00
|
|
|
|
AdsActionEvents.TrackAdPosition(AdsType.Rewarded, position);
|
2025-09-01 15:21:18 +00:00
|
|
|
|
bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady();
|
|
|
|
|
if (isRewardAdReady)
|
|
|
|
|
{
|
|
|
|
|
AdsSDKManager.Instance.ShowRewardAd(position, (isReward, revenue) =>
|
|
|
|
|
{
|
2025-09-03 11:58:43 +00:00
|
|
|
|
AdsSplashManager.Instance.backgroundTime = Time.realtimeSinceStartup;
|
2025-09-01 15:21:18 +00:00
|
|
|
|
if (isReward)
|
|
|
|
|
{
|
2025-09-02 06:20:54 +00:00
|
|
|
|
AdsSDKManager.Instance.ClearIvRules();
|
2025-09-01 15:21:18 +00:00
|
|
|
|
callback?.Invoke(true, revenue);
|
|
|
|
|
}
|
2025-09-02 06:20:54 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
callback?.Invoke(false, 0);
|
|
|
|
|
}
|
2025-09-01 15:21:18 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
2025-09-02 06:20:54 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2025-09-05 02:15:32 +00:00
|
|
|
|
AdsActionEvents.TrackAdFailToShow(AdsType.Rewarded, position, AdsShowFailType.NoFill);
|
2025-09-02 06:20:54 +00:00
|
|
|
|
callback?.Invoke(false, 0);
|
|
|
|
|
}
|
2025-09-01 15:21:18 +00:00
|
|
|
|
}
|
2025-09-02 06:20:54 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否已缓存插屏
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsInterstitialAdReady()
|
|
|
|
|
{
|
|
|
|
|
return AdsSDKManager.Instance.IsInterstitialReady();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 展示插屏广告
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="position"></param>
|
|
|
|
|
/// <param name="ivadType"></param>
|
|
|
|
|
/// <param name="callback"></param>
|
2025-09-01 05:59:06 +00:00
|
|
|
|
public void ShowInterstitial(string position, IvType ivadType = IvType.IV1, Action<double> callback = null)
|
|
|
|
|
{
|
2025-09-03 11:58:43 +00:00
|
|
|
|
AdsActionEvents.TrackAdPosition(AdsType.Interstitial, position);
|
2025-09-01 05:59:06 +00:00
|
|
|
|
//插屏展示逻辑
|
|
|
|
|
bool ivRulesShow = AdsSDKManager.Instance.IvRulesShow(ivadType);
|
|
|
|
|
if (ivRulesShow)
|
|
|
|
|
{
|
|
|
|
|
//是否有缓存
|
|
|
|
|
bool isInterstitialReady = AdsSDKManager.Instance.IsInterstitialReady();
|
|
|
|
|
if (isInterstitialReady)
|
|
|
|
|
{
|
2025-09-01 14:14:33 +00:00
|
|
|
|
AdsSDKManager.Instance.ShowInterstitialAd(position, ivadType, (revenue) =>
|
2025-09-01 05:59:06 +00:00
|
|
|
|
{
|
|
|
|
|
//展示完一个插屏之后调用
|
2025-09-04 08:50:26 +00:00
|
|
|
|
IvRulesConst.OverLevels[ivadType.ToString()] = 1;
|
2025-09-02 06:20:54 +00:00
|
|
|
|
IvRulesConst.Intervals[ivadType.ToString()] = TimeUtils.GetLocalTimestamp();
|
2025-09-03 11:58:43 +00:00
|
|
|
|
AdsSplashManager.Instance.backgroundTime = Time.realtimeSinceStartup;
|
2025-09-02 06:20:54 +00:00
|
|
|
|
callback?.Invoke(revenue);
|
2025-09-01 05:59:06 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
2025-09-01 14:14:33 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2025-09-05 02:15:32 +00:00
|
|
|
|
AdsActionEvents.TrackAdFailToShow(AdsType.Interstitial, position, AdsShowFailType.NoFill);
|
2025-09-02 08:17:14 +00:00
|
|
|
|
callback?.Invoke(-1);
|
2025-09-01 14:14:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-09-05 02:15:32 +00:00
|
|
|
|
AdsActionEvents.TrackAdFailToShow(AdsType.Interstitial, position, AdsShowFailType.RuleLimit);
|
2025-09-02 08:17:14 +00:00
|
|
|
|
callback?.Invoke(-1);
|
2025-09-01 05:59:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-02 08:13:06 +00:00
|
|
|
|
public void ShowBanner()
|
|
|
|
|
{
|
2025-09-03 11:58:43 +00:00
|
|
|
|
AdsActionEvents.TrackAdPosition(AdsType.Banner, "");
|
|
|
|
|
if (AdsSDKManager.Instance.IsBannerAdReady())
|
2025-09-05 02:15:32 +00:00
|
|
|
|
{
|
2025-09-03 11:58:43 +00:00
|
|
|
|
AdsSDKManager.Instance.ShowBanner();
|
|
|
|
|
}
|
2025-09-05 02:15:32 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AdsActionEvents.TrackAdFailToShow(AdsType.Banner, "", AdsShowFailType.NoFill);
|
|
|
|
|
}
|
2025-09-03 11:58:43 +00:00
|
|
|
|
|
2025-09-02 08:13:06 +00:00
|
|
|
|
}
|
2025-09-02 06:20:54 +00:00
|
|
|
|
|
2025-09-02 08:13:06 +00:00
|
|
|
|
public void HideBanner()
|
|
|
|
|
{
|
|
|
|
|
AdsSDKManager.Instance.HideBanner();
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-02 08:17:14 +00:00
|
|
|
|
public bool IsNativeFullReady()
|
|
|
|
|
{
|
2025-09-02 10:06:58 +00:00
|
|
|
|
var adUnitId = StaticValue.AdmobFullNativeId;
|
|
|
|
|
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-09-02 10:06:58 +00:00
|
|
|
|
public void ShowFullNative(RectTransform rectTransform, Camera pCom = null, string position = "")
|
2025-09-02 08:17:14 +00:00
|
|
|
|
{
|
2025-09-03 11:58:43 +00:00
|
|
|
|
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
2025-09-02 10:06:58 +00:00
|
|
|
|
if (!IsNativeFullReady())
|
|
|
|
|
{
|
2025-09-05 02:15:32 +00:00
|
|
|
|
AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
2025-09-02 10:06:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2025-09-02 08:17:14 +00:00
|
|
|
|
|
2025-09-02 10:06:58 +00:00
|
|
|
|
var adUnitId = StaticValue.AdmobFullNativeId;
|
|
|
|
|
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
|
|
|
|
{
|
|
|
|
|
TemplateId = NativeTemplateId.Medium,
|
|
|
|
|
MainBackgroundColor = Color.white
|
|
|
|
|
}, rectTransform, pCom);
|
2025-09-02 08:17:14 +00:00
|
|
|
|
|
2025-09-02 10:06:58 +00:00
|
|
|
|
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-09-02 10:06:58 +00:00
|
|
|
|
public void HideFullNative()
|
2025-09-02 08:17:14 +00:00
|
|
|
|
{
|
2025-09-02 10:06:58 +00:00
|
|
|
|
var adUnitId = StaticValue.AdmobFullNativeId;
|
|
|
|
|
AdsSDKManager.Instance.RemoveNativeAd(adUnitId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsNativeReady()
|
|
|
|
|
{
|
|
|
|
|
var adUnitId = StaticValue.AdmobNativeId;
|
|
|
|
|
return AdsSDKManager.Instance.IsNativeAdReady(adUnitId);
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-09-02 10:06:58 +00:00
|
|
|
|
public void ShowNative(RectTransform rectTransform, Camera pCom = null, string position = "")
|
2025-09-02 08:17:14 +00:00
|
|
|
|
{
|
2025-09-03 11:58:43 +00:00
|
|
|
|
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
2025-09-02 10:06:58 +00:00
|
|
|
|
if (!IsNativeReady())
|
|
|
|
|
{
|
2025-09-05 02:15:32 +00:00
|
|
|
|
AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
2025-09-02 10:06:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var adUnitId = StaticValue.AdmobNativeId;
|
|
|
|
|
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
|
|
|
|
{
|
2025-09-05 02:58:17 +00:00
|
|
|
|
TemplateId = NativeTemplateId.Small,
|
2025-09-02 10:06:58 +00:00
|
|
|
|
MainBackgroundColor = Color.white
|
|
|
|
|
}, rectTransform, pCom);
|
2025-09-02 08:17:14 +00:00
|
|
|
|
|
2025-09-02 10:06:58 +00:00
|
|
|
|
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void HideNative()
|
|
|
|
|
{
|
2025-09-02 10:06:58 +00:00
|
|
|
|
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 = "")
|
|
|
|
|
{
|
2025-09-03 11:58:43 +00:00
|
|
|
|
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
2025-09-02 10:06:58 +00:00
|
|
|
|
if (!IsSmallNativeReady())
|
|
|
|
|
{
|
2025-09-05 02:15:32 +00:00
|
|
|
|
AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
2025-09-02 10:06:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var adUnitId = StaticValue.AdmobSmallNativeId;
|
|
|
|
|
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
|
|
|
|
{
|
2025-09-05 02:58:17 +00:00
|
|
|
|
TemplateId = NativeTemplateId.Small,
|
2025-09-02 10:06:58 +00:00
|
|
|
|
MainBackgroundColor = Color.white
|
|
|
|
|
}, 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 = "")
|
|
|
|
|
{
|
2025-09-03 11:58:43 +00:00
|
|
|
|
AdsActionEvents.TrackAdPosition(AdsType.Native, position);
|
2025-09-05 10:09:55 +00:00
|
|
|
|
if (!IsMinddleNativeReady())
|
2025-09-02 10:06:58 +00:00
|
|
|
|
{
|
2025-09-05 02:15:32 +00:00
|
|
|
|
AdsActionEvents.TrackAdFailToShow(AdsType.Native, position, AdsShowFailType.NoFill);
|
2025-09-02 10:06:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2025-09-02 08:17:14 +00:00
|
|
|
|
|
2025-09-02 10:06:58 +00:00
|
|
|
|
var adUnitId = StaticValue.AdmobMinddleNativeId;
|
|
|
|
|
var nativeAdPosition = NativeAdPosition.Create(new NativeTemplateStyle
|
|
|
|
|
{
|
2025-09-05 02:58:17 +00:00
|
|
|
|
TemplateId = NativeTemplateId.Small,
|
2025-09-02 10:06:58 +00:00
|
|
|
|
MainBackgroundColor = Color.white
|
|
|
|
|
}, rectTransform, pCom);
|
2025-09-02 08:17:14 +00:00
|
|
|
|
|
2025-09-02 10:06:58 +00:00
|
|
|
|
AdsSDKManager.Instance.ShowNativeAd(position, adUnitId, nativeAdPosition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void HideMinddleNative()
|
|
|
|
|
{
|
|
|
|
|
var adUnitId = StaticValue.AdmobMinddleNativeId;
|
|
|
|
|
AdsSDKManager.Instance.RemoveNativeAd(adUnitId);
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
2025-09-01 09:57:19 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 埋点
|
|
|
|
|
|
|
|
|
|
public void LogEvent(string eventName)
|
|
|
|
|
{
|
2025-09-01 11:10:21 +00:00
|
|
|
|
ShuShuEvent.Instance.Track(eventName);
|
|
|
|
|
FireBaseAnalyticsManager.Instance.LogEvent(eventName);
|
2025-09-02 10:08:26 +00:00
|
|
|
|
AdjustTrackEvent.Instance.TrackEventName(eventName, new Dictionary<string, object>());
|
2025-09-01 09:57:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LogEvent(string eventName, string key1, object value1)
|
|
|
|
|
{
|
2025-09-01 11:10:21 +00:00
|
|
|
|
ShuShuEvent.Instance.Track(eventName, key1, value1);
|
|
|
|
|
FireBaseAnalyticsManager.Instance.LogEvent(eventName, key1, value1);
|
2025-09-02 10:08:26 +00:00
|
|
|
|
AdjustTrackEvent.Instance.TrackEventName(eventName, new Dictionary<string, object>
|
|
|
|
|
{
|
|
|
|
|
[key1] = value1
|
|
|
|
|
});
|
|
|
|
|
|
2025-09-01 09:57:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LogEvent(string eventName, Dictionary<string, object> extraInfo)
|
|
|
|
|
{
|
2025-09-01 11:10:21 +00:00
|
|
|
|
ShuShuEvent.Instance.Track(eventName, extraInfo);
|
|
|
|
|
FireBaseAnalyticsManager.Instance.LogEvent(eventName, extraInfo);
|
2025-09-02 10:08:26 +00:00
|
|
|
|
AdjustTrackEvent.Instance.TrackEventName(eventName, extraInfo);
|
2025-09-01 09:57:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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
|
2025-09-01 06:45:25 +00:00
|
|
|
|
|
2025-09-01 08:33:14 +00:00
|
|
|
|
#region 在线参数
|
|
|
|
|
|
|
|
|
|
public bool GetRemoteConfigBool(string key, bool defaultValue = false)
|
|
|
|
|
{
|
2025-09-01 11:10:21 +00:00
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return defaultValue;
|
|
|
|
|
}
|
2025-09-01 08:33:14 +00:00
|
|
|
|
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigBool(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetRemoteConfigInt(string key, int defaultValue = 0)
|
|
|
|
|
{
|
2025-09-01 11:10:21 +00:00
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return defaultValue;
|
|
|
|
|
}
|
2025-09-01 08:33:14 +00:00
|
|
|
|
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-01 15:21:18 +00:00
|
|
|
|
public string GetRemoteConfigStr(string key, string defaultValue = "")
|
2025-09-01 08:33:14 +00:00
|
|
|
|
{
|
2025-09-01 11:10:21 +00:00
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return defaultValue;
|
|
|
|
|
}
|
2025-09-01 08:33:14 +00:00
|
|
|
|
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigString(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float GetRemoteConfigFloat(string key, float defaultValue = 0)
|
|
|
|
|
{
|
2025-09-01 11:10:21 +00:00
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return defaultValue;
|
|
|
|
|
}
|
2025-09-01 08:33:14 +00:00
|
|
|
|
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigFloat(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2025-09-01 08:27:45 +00:00
|
|
|
|
#region EFSDK
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 展示WebView
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">标签id,存在多个WebView时,用于标识WebView</param>
|
2025-09-02 03:07:36 +00:00
|
|
|
|
/// <param name="pos">广告位</param>
|
2025-09-01 08:27:45 +00:00
|
|
|
|
/// <param name="url">网址</param>
|
|
|
|
|
/// <param name="pRect">WebView展示区域的RectTransform</param>
|
|
|
|
|
/// <param name="pCam">可不传;传值的话要传正交相机</param>
|
2025-09-02 03:07:36 +00:00
|
|
|
|
public void ShowWebView(int id, string pos, string url, RectTransform pRect, Camera pCam = null)
|
2025-09-01 08:27:45 +00:00
|
|
|
|
{
|
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-09-02 03:07:36 +00:00
|
|
|
|
|
2025-09-05 05:31:32 +00:00
|
|
|
|
string newUrl = url.Replace("{gaid}", AppSDKManager.Instance.GetGaid());
|
2025-09-04 08:50:26 +00:00
|
|
|
|
EFSdkManager.Instance.AddUrl(id, url);
|
2025-09-02 03:07:36 +00:00
|
|
|
|
EFSdkManager.Instance.SetOkspinShowPos(pos);
|
2025-09-05 05:31:32 +00:00
|
|
|
|
EFSdk.get().ShowWebView(id, newUrl, pRect, pCam);
|
2025-09-01 08:27:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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();
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-02 08:17:14 +00:00
|
|
|
|
public void CanGoback(Action<bool> canGobackAction)
|
|
|
|
|
{
|
|
|
|
|
EFSdk.get().CanGoback(canGobackAction);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-01 08:27:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 回上一页
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public void GoBack()
|
|
|
|
|
{
|
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
EFSdk.get().CanGoback((IsGoback) =>
|
|
|
|
|
{
|
|
|
|
|
if (IsGoback)
|
|
|
|
|
{
|
|
|
|
|
EFSdk.get().GoBack();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-09-02 06:37:21 +00:00
|
|
|
|
|
|
|
|
|
|
2025-09-01 08:27:45 +00:00
|
|
|
|
/// <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>
|
2025-09-02 08:17:14 +00:00
|
|
|
|
public void SetPushMessagenotif(int timeSeconds)
|
2025-09-01 08:27:45 +00:00
|
|
|
|
{
|
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
EFSdk.get().SetPushMessagenotif(timeSeconds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 持续性通知在进入游戏时弹出的时间间隔,SDK默认设置为300秒(在线参数控制 )-Key:persistentnotif Value:300
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="timeSeconds"></param>
|
2025-09-02 08:17:14 +00:00
|
|
|
|
public void SetPushPersistentnotif(int timeSeconds)
|
2025-09-01 08:27:45 +00:00
|
|
|
|
{
|
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
EFSdk.get().SetPushPersistentnotif(timeSeconds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 每次回调游戏的onResume的时候都调用一次,获取游戏要跳转的页面
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// 0 不需要进行任何跳转
|
|
|
|
|
/// 1 进行游戏主页
|
|
|
|
|
/// 2 进入游戏的金币提现界面
|
|
|
|
|
/// 3 进入对应小游戏1界面
|
|
|
|
|
/// 4 进入对应小游戏2界面
|
|
|
|
|
/// </returns>
|
2025-09-02 08:17:14 +00:00
|
|
|
|
public int GetJumpPage()
|
2025-09-01 08:27:45 +00:00
|
|
|
|
{
|
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
2025-09-02 08:17:14 +00:00
|
|
|
|
return 0;
|
2025-09-01 08:27:45 +00:00
|
|
|
|
}
|
|
|
|
|
int pageId = EFSdk.get().GetJumpPage();
|
2025-09-02 08:17:14 +00:00
|
|
|
|
return pageId;
|
|
|
|
|
|
2025-09-01 08:27:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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);
|
|
|
|
|
}
|
2025-09-02 08:17:14 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 定时远程推送
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void AutoLocalPush(bool isOpen)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2025-09-01 08:27:45 +00:00
|
|
|
|
|
2025-09-03 08:12:41 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Webview展示成功后回调
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="action"></param>
|
|
|
|
|
public void WebviewShowSuccess(Action<string> action)
|
|
|
|
|
{
|
|
|
|
|
EFSdkManager.Instance.SetWebviewShowSuccessAction(action);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-01 08:27:45 +00:00
|
|
|
|
#endregion
|
2025-09-02 03:45:05 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否是自然量用户
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool InOrganic()
|
|
|
|
|
{
|
|
|
|
|
return AdjustNetwork.Instance.InOrganic();
|
|
|
|
|
}
|
2025-09-02 08:17:14 +00:00
|
|
|
|
|
2025-09-02 09:36:19 +00:00
|
|
|
|
public string GetGaid()
|
2025-09-02 08:17:14 +00:00
|
|
|
|
{
|
2025-09-02 09:36:19 +00:00
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return "gaid";
|
|
|
|
|
}
|
|
|
|
|
return AdjustManager.Instance.GetGdid();
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetAndroidId()
|
|
|
|
|
{
|
2025-09-02 09:36:19 +00:00
|
|
|
|
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;
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetAdid()
|
|
|
|
|
{
|
2025-09-02 09:36:19 +00:00
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return "adid";
|
|
|
|
|
}
|
|
|
|
|
return AdjustManager.Instance.GetAdid();
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetUserAgent()
|
|
|
|
|
{
|
2025-09-02 09:36:19 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetSSAccountId()
|
|
|
|
|
{
|
2025-09-02 09:36:19 +00:00
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return "GetSSAccountId";
|
|
|
|
|
}
|
2025-09-02 08:17:14 +00:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetSSDistinctId()
|
|
|
|
|
{
|
2025-09-02 09:36:19 +00:00
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return "GetSSDistinctId";
|
|
|
|
|
}
|
2025-09-05 09:58:34 +00:00
|
|
|
|
LoggerUtils.Debug("GetSSDistinctId:"+TDAnalytics.GetDistinctId());
|
|
|
|
|
return TDAnalytics.GetDistinctId();
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetSSSuperProperties()
|
|
|
|
|
{
|
2025-09-02 09:36:19 +00:00
|
|
|
|
if (Application.isEditor)
|
|
|
|
|
{
|
|
|
|
|
return "GetSSSuperProperties";
|
|
|
|
|
}
|
2025-09-04 14:30:30 +00:00
|
|
|
|
|
2025-09-05 09:58:34 +00:00
|
|
|
|
var superProperties = TDAnalytics.GetSuperProperties();
|
|
|
|
|
LoggerUtils.Debug("GetSSDistinctId:" + JsonMapper.ToJson(superProperties));
|
2025-09-04 14:30:30 +00:00
|
|
|
|
return superProperties == null ? "" : superProperties.ToString();
|
2025-09-02 08:17:14 +00:00
|
|
|
|
}
|
2025-08-31 08:42:48 +00:00
|
|
|
|
}
|