using System; using System.Collections.Generic; using EFSDK; using Firebase.Analytics; using UnityEngine; namespace WZ { public class EFSdkManager : D_MonoSingleton { private const string KEY_OKSPIN_SHOW_COUNT = "OKSPIN_SHOW_COUNT"; //互动广告位 private string okspinShowPos = ""; private Action _webviewShowSuccessAction; //保存的链接 private List urls = new List(); public void Init() { if (Application.isEditor) { return; } EFSdk.get().Init((actionType, str) => { if (actionType == EFSdk.ActionType.H5_Load_Succ) { _webviewShowSuccessAction?.Invoke(str); } }); SetSDKEventCallback(); SetHdH5ImpressionCallback(); } private void SetSDKEventCallback() { EFSdk.get().SetSDKEventCallback((eventName, dict) => { FireBaseAnalyticsManager.Instance.LogEvent(eventName, dict); ShuShuEvent.Instance.Track(eventName, dict); }); } // /// 互动广告展示回调,此时可以计算上报互动广告展示次数和收益 /// /// string 是互动广告的url public void SetHdH5ImpressionCallback() { EFSdk.get().SetHdH5ImpressionCallback((pid) => { //判断链接不为空 if (string.IsNullOrEmpty(pid)) { return; } //展示次数 int count = PlayerPrefsUtils.GetPlayerPrefsInt(KEY_OKSPIN_SHOW_COUNT, 0); count++; PlayerPrefsUtils.SavePlayerPrefsInt(KEY_OKSPIN_SHOW_COUNT, count); string url = GetUrl(pid); //互动广告只有okSpin float revenue = FireBaseRemoteConfigManager.Instance.GetRemoteConfigFloat("rev_okspin", 0); //adjust AdjustTrackEvent.Instance.TrackAdEvent(revenue, "H5ad_game", url, url); //firebase FireBaseAnalyticsManager.Instance.OnAdRevenueEvent("H5ad_game", "H5ad_game", url, AdsType.Fix, revenue, okspinShowPos, count); //数数 ShuShuEvent.Instance.OnAdRevenueEvent("H5ad_game", "H5ad_game", url, AdsType.Fix.ToString(), revenue, okspinShowPos, count); }); } public void SetOkspinShowPos(string pos) { okspinShowPos = pos; } public void SetWebviewShowSuccessAction(Action action) { _webviewShowSuccessAction = action; } public void AddUrl(int id, string url) { if (!urls.Contains(url)) { urls.Add(url); } } private string GetUrl(string pid) { foreach (var url in urls) { if (url.Contains(pid)) { return url; } } return pid; } private void OnApplicationFocus(bool hasFocus) { EFSdk.get().SetGameActive(hasFocus); } } }