using System; using System.Collections; using System.Collections.Generic; using EFSDK; using Firebase.RemoteConfig; using Newtonsoft.Json; using UnityEngine; using WZ; public class AppSDKManager : D_MonoSingleton { //包名 public const string PackageName = "com.rush.cash.earn.fast.real.money.game"; public void Init(Action action) { FileParse.Parse(); // AdConfigParser.Parse(); FireBaseSDKManager.Instance.Init(); AdmobAdsManager.Instance.RefreshAdsData(); AdmobAdsManager.Instance.Initialize(); AdjustManager.Instance.Init(); ShuShuMangage.Instance.Init(); AdsSDKManager.Instance.InitSDK(null); EFSdkManager.Instance.Init(); } /// /// 协程 /// /// public void Coroutine(IEnumerator coroutine) { StartCoroutine(coroutine); } #region ad /// /// 是否已缓存激励广告 /// /// public bool IsRewardAdReady() { return AdsSDKManager.Instance.IsRewardAdReady();; } /// /// 展示激励广告 /// /// /// public void ShowRewardAd(string position, Action callback = null) { bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady(); if (isRewardAdReady) { AdsSDKManager.Instance.ShowRewardAd(position, (isReward, revenue) => { if (isReward) { AdsSDKManager.Instance.ClearIvRules(); callback?.Invoke(true, revenue); } else { callback?.Invoke(false, 0); } }); } else { callback?.Invoke(false, 0); } } /// /// 是否已缓存插屏 /// public bool IsInterstitialAdReady() { return AdsSDKManager.Instance.IsInterstitialReady(); } /// /// 展示插屏广告 /// /// /// /// public void ShowInterstitial(string position, IvType ivadType = IvType.IV1, Action callback = null) { //插屏展示逻辑 bool ivRulesShow = AdsSDKManager.Instance.IvRulesShow(ivadType); if (ivRulesShow) { //是否有缓存 bool isInterstitialReady = AdsSDKManager.Instance.IsInterstitialReady(); if (isInterstitialReady) { AdsSDKManager.Instance.ShowInterstitialAd(position, ivadType, (revenue) => { //展示完一个插屏之后调用 IvRulesConst.OverLevels[ivadType.ToString()] = 0; IvRulesConst.Intervals[ivadType.ToString()] = TimeUtils.GetLocalTimestamp(); callback?.Invoke(revenue); }); } else { callback?.Invoke(0); } } else { callback?.Invoke(0); } } #endregion #region 埋点 public void LogEvent(string eventName) { ShuShuEvent.Instance.Track(eventName); FireBaseAnalyticsManager.Instance.LogEvent(eventName); } public void LogEvent(string eventName, string key1, object value1) { ShuShuEvent.Instance.Track(eventName, key1, value1); FireBaseAnalyticsManager.Instance.LogEvent(eventName, key1, value1); } public void LogEvent(string eventName, Dictionary extraInfo) { ShuShuEvent.Instance.Track(eventName, extraInfo); FireBaseAnalyticsManager.Instance.LogEvent(eventName, extraInfo); } /// /// 公共事件属性 /// /// public void SetSuperProperties(Dictionary args) { ShuShuEvent.Instance.SetSuperProperties(args); FireBaseAnalyticsManager.Instance.SetSuperProperties(args); } /// /// 用户属性 /// /// public void SetUserProperties(Dictionary 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 /// /// 展示WebView /// /// 标签id,存在多个WebView时,用于标识WebView /// 广告位 /// 网址 /// WebView展示区域的RectTransform /// 可不传;传值的话要传正交相机 public void ShowWebView(int id, string pos, string url, RectTransform pRect, Camera pCam = null) { if (Application.isEditor) { return; } EFSdkManager.Instance.SetOkspinShowPos(pos); EFSdk.get().ShowWebView(id, url, pRect, pCam); } /// /// 移除所有原生WebView, 回到游戏时调用 /// /// public void RemoveAll() { if (Application.isEditor) { return; } EFSdk.get().RemoveAll(); } /// /// 刷新当前页面 /// /// public void Refresh() { if (Application.isEditor) { return; } EFSdk.get().Refresh(); } /// /// 回上一页 /// /// public void GoBack() { if (Application.isEditor) { return; } EFSdk.get().CanGoback((IsGoback) => { if (IsGoback) { EFSdk.get().GoBack(); } }); } /// /// 是否手动控制漂浮道具显示/隐藏 /// SDK内默认当H5页面加载完成后自动显示漂浮道具 /// /// true: 自动显示/隐藏道具 false: 游戏主动控制道具显示/隐藏 /// public void AutoShowFloat(bool autoShow) { if (Application.isEditor) { return; } EFSdk.get().AutoShowFloat(false); } /// /// 新增接口飘金币 /// /// /// 悬浮金币按钮的图片资源,传字符串 0 或 1 0:金币图 1:红点宝箱图 /// public void ShowFloatCoin(String res) { if (Application.isEditor) { return; } var remoteConfig = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("coin_position", 3); if (remoteConfig <= 0) { remoteConfig = 3; } if (remoteConfig > 10) { remoteConfig = 3; } EFSdk.get().SetFloatCoinRes(res); EFSdk.get().ShowFloatCoin(remoteConfig); } /// /// 隐藏金币 /// /// public void HideFloatCoin() { if (Application.isEditor) { return; } EFSdk.get().HideFloatCoin(); } /// 宝箱动画起始位置 /// 宝箱动画移动结束位置 /// 首次delay时间 /// 每次漂浮移动的时间间隔 /// public void ShowBalloon(int startId, int endId, int fly_first_time, int fly_gap_time) { if (Application.isEditor) { return; } var startFlyIndex = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("start_fly", 40); var endFlyIndex = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("end_fly", 60); var flyFirstTime = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("fly_first_time", 3); var flyGapTime = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("fly_gap_time", 15); EFSdk.get().ShowBalloon(startFlyIndex, endFlyIndex, flyFirstTime, flyGapTime); } /// /// 隐藏气球 /// /// public void HideBalloon() { if (Application.isEditor) { return; } EFSdk.get().HideBalloon(); } /// /// 设置推送开关, SDK默认关闭通知 /// /// public void SetPushSwitch(bool isOpen) { if (Application.isEditor) { return; } EFSdk.get().SetPushSwitch(isOpen); } /// /// 向SDK上报当前金币总数,每次金币变化都要调用一次 /// /// public void SendTotalGold2SDK(int totalGold) { if (Application.isEditor) { return; } EFSdk.get().SendTotalGold2SDK(totalGold); } /// /// 向SDK上报当前要提现的现金额,每次变化都要调用一次 /// /// public void SendCashNum2SDK(double cashNum) { if (Application.isEditor) { return; } EFSdk.get().SendCashNum2SDK(cashNum); } /// /// 向SDK上报 游戏名字(当前语言的),每次语言变化都上报 /// /// public void SetGameName(string gameName) { if (Application.isEditor) { return; } EFSdk.get().SetGameName(gameName); } /// /// 设置当前游戏语言是否是 巴西语 /// /// /// 巴西语传 true, 其他的都传 false public void SetCurrLang(bool isPT) { if (Application.isEditor) { return; } EFSdk.get().SetCurrLang(isPT); } /// /// 消息类通知弹出间隔,SDK默认设置为60秒(在线参数控制)-Key: messagenotif Value:60 /// /// public void SetPushMessagenotif() { if (Application.isEditor) { return; } int timeSeconds = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("messagenotif", 60); EFSdk.get().SetPushMessagenotif(timeSeconds); } /// /// 持续性通知在进入游戏时弹出的时间间隔,SDK默认设置为300秒(在线参数控制 )-Key:persistentnotif Value:300 /// /// public void SetPushPersistentnotif() { if (Application.isEditor) { return; } int timeSeconds = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("persistentnotif", 300); EFSdk.get().SetPushPersistentnotif(timeSeconds); } /// /// 每次回调游戏的onResume的时候都调用一次,获取游戏要跳转的页面 /// /// /// 0 不需要进行任何跳转 /// 1 进行游戏主页 /// 2 进入游戏的金币提现界面 /// 3 进入对应小游戏1界面 /// 4 进入对应小游戏2界面 /// public void GetJumpPage() { if (Application.isEditor) { return; } int pageId = EFSdk.get().GetJumpPage(); switch (pageId) { case 0: // Nothing to do break; case 1: // 回到游戏主页 break; case 2: // 进入游戏的金币提现界面 break; case 3: // 进入对应小游戏1界面 break; case 4: // 进入对应小游戏2界面 break; } } /// /// 获取当前是否有通知权限 /// public bool HasNotifyPermission() { if (Application.isEditor) { return false; } return EFSdk.get().HasNotifyPermission(); } /// /// 请求获取通知权限 /// 授权弹窗关闭回调 bool:表示用户是否允许了权限 true:有权限 false:无权限 /// public void ReqNotifyPermission(Action action) { if (Application.isEditor) { return; } // 如果没有通知权限就尝试申请通知权限 if(!HasNotifyPermission()) { EFSdk.get().ReqNotifyPermission(isgGranted => { //收到回调之后,可以认为权限申请弹窗弹出来了 if (isgGranted) { //用户已同意授权 } else { //用户拒绝了授权 } }); } } /// /// 满足条件:未领取 R$0.1 的 买量用户, 调用这个方法 /// public void SubscribeUnclaimed01() { if (Application.isEditor) { return; } EFSdk.get().SubscribeUnclaimed01(); } /// /// 不满足条件:未领取 R$0.1 的 买量用户, 调用这个方法 /// public void UnSubscribeUnclaimed01() { if (Application.isEditor) { return; } EFSdk.get().UnSubscribeUnclaimed01(); } /// // 满足条件: 在排队中 且 当日R$1 未领取 的买量用户, 调用这个方法 /// public void SubscribePending1() { if (Application.isEditor) { return; } EFSdk.get().SubscribePending1(); } /// /// 不满足条件: 在排队中 且 当日R$1 未领取 的买量用户, 调用这个方法 /// public void UnSubscribePending1() { if (Application.isEditor) { return; } EFSdk.get().UnSubscribePending1(); } /// /// 订阅Firebase推送主题 /// /// 主题名称 public void SubscribeToTopic(string topic) { if (Application.isEditor) { return; } EFSdk.get().SubscribeToTopic(topic); } /// 取消订阅Firebase推送主题 /// /// 主题名称 public void UnSubscribeToTopic(string topic) { if (Application.isEditor) { return; } EFSdk.get().UnSubscribeToTopic(topic); } /// /// 可覆盖广告的Toast /// /// public void ShowToast(string message) { if (Application.isEditor) { return; } EFSdk.get().ShowToast(message); } #endregion /// /// 是否是自然量用户 /// /// public bool InOrganic() { return AdjustNetwork.Instance.InOrganic(); } }