589 lines
16 KiB
C#
589 lines
16 KiB
C#
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<AppSDKManager>
|
||
{
|
||
//包名
|
||
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();
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 协程
|
||
/// </summary>
|
||
/// <param name="coroutine"></param>
|
||
public void Coroutine(IEnumerator coroutine)
|
||
{
|
||
StartCoroutine(coroutine);
|
||
}
|
||
|
||
#region ad
|
||
|
||
public void ShowRewardAd(string position, Action<bool,double> callback = null)
|
||
{
|
||
bool isRewardAdReady = AdsSDKManager.Instance.IsRewardAdReady();
|
||
if (isRewardAdReady)
|
||
{
|
||
AdsSDKManager.Instance.ShowRewardAd(position, (isReward, revenue) =>
|
||
{
|
||
if (isReward)
|
||
{
|
||
//callback?.Invoke();
|
||
callback?.Invoke(true, revenue);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
public void ShowInterstitial(string position, IvType ivadType = IvType.IV1, Action<double> callback = null)
|
||
{
|
||
//插屏展示逻辑
|
||
bool ivRulesShow = AdsSDKManager.Instance.IvRulesShow(ivadType);
|
||
if (ivRulesShow)
|
||
{
|
||
//是否有缓存
|
||
bool isInterstitialReady = AdsSDKManager.Instance.IsInterstitialReady();
|
||
if (isInterstitialReady)
|
||
{
|
||
AdsSDKManager.Instance.ShowInterstitialAd(position, ivadType, (revenue) =>
|
||
{
|
||
//展示完一个插屏之后调用
|
||
IvRulesConst.CurrentOverLevel = 0;
|
||
IvRulesConst.CurrentInterval = TimeUtils.GetLocalTimestamp();
|
||
});
|
||
}
|
||
else
|
||
{
|
||
callback?.Invoke(0);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
callback?.Invoke(0);
|
||
}
|
||
}
|
||
|
||
public bool IsRewardAdReady()
|
||
{
|
||
return AdsSDKManager.Instance.IsRewardAdReady();;
|
||
}
|
||
|
||
#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<string, object> extraInfo)
|
||
{
|
||
ShuShuEvent.Instance.Track(eventName, extraInfo);
|
||
FireBaseAnalyticsManager.Instance.LogEvent(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;
|
||
}
|
||
|
||
EFSdkManager.Instance.SetOkspinShowPos(pos);
|
||
EFSdk.get().ShowWebView(id, url, 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();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 回上一页
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public void GoBack()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().CanGoback((IsGoback) =>
|
||
{
|
||
if (IsGoback)
|
||
{
|
||
EFSdk.get().GoBack();
|
||
}
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否手动控制漂浮道具显示/隐藏
|
||
/// SDK内默认当H5页面加载完成后自动显示漂浮道具
|
||
/// </summary>
|
||
/// <param name="autoShow">true: 自动显示/隐藏道具 false: 游戏主动控制道具显示/隐藏</param>
|
||
/// <returns></returns>
|
||
public void AutoShowFloat(bool autoShow)
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().AutoShowFloat(false);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 新增接口飘金币
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <param name="res">悬浮金币按钮的图片资源,传字符串 0 或 1 0:金币图 1:红点宝箱图 </param>
|
||
/// <returns></returns>
|
||
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);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 隐藏金币
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public void HideFloatCoin()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().HideFloatCoin();
|
||
}
|
||
|
||
/// <param name="startId">宝箱动画起始位置</param>
|
||
/// <param name="endId">宝箱动画移动结束位置</param>
|
||
/// <param name="fly_first_time">首次delay时间</param>
|
||
/// <param name="fly_gap_time">每次漂浮移动的时间间隔</param>
|
||
/// <returns></returns>
|
||
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);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 隐藏气球
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public void HideBalloon()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
EFSdk.get().HideBalloon();
|
||
}
|
||
|
||
/// <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()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
int timeSeconds = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("messagenotif", 60);
|
||
EFSdk.get().SetPushMessagenotif(timeSeconds);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 持续性通知在进入游戏时弹出的时间间隔,SDK默认设置为300秒(在线参数控制 )-Key:persistentnotif Value:300
|
||
/// </summary>
|
||
/// <param name="timeSeconds"></param>
|
||
public void SetPushPersistentnotif()
|
||
{
|
||
if (Application.isEditor)
|
||
{
|
||
return;
|
||
}
|
||
int timeSeconds = FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt("persistentnotif", 300);
|
||
EFSdk.get().SetPushPersistentnotif(timeSeconds);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 每次回调游戏的onResume的时候都调用一次,获取游戏要跳转的页面
|
||
/// </summary>
|
||
/// <returns>
|
||
/// 0 不需要进行任何跳转
|
||
/// 1 进行游戏主页
|
||
/// 2 进入游戏的金币提现界面
|
||
/// 3 进入对应小游戏1界面
|
||
/// 4 进入对应小游戏2界面
|
||
/// </returns>
|
||
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;
|
||
}
|
||
}
|
||
|
||
/// <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);
|
||
}
|
||
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 是否是自然量用户
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool InOrganic()
|
||
{
|
||
return AdjustNetwork.Instance.InOrganic();
|
||
}
|
||
}
|