update: GuruSDK 回调优化, codereview
parent
4da06c8f96
commit
42c7302ea3
|
|
@ -2,6 +2,8 @@ namespace Guru
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启动参数配置
|
/// 启动参数配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -55,7 +57,7 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用 AdjustDeeplink
|
/// 启用 AdjustDeeplink
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseAdjustDeeplink = false;
|
public Action<string> OnAdjustDeeplinkCallback = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 支付初始化Keys
|
/// 支付初始化Keys
|
||||||
|
|
@ -77,7 +79,7 @@ namespace Guru
|
||||||
bool isBuyNoAds = false,
|
bool isBuyNoAds = false,
|
||||||
string bannerBackgroundColor = "#00000000",
|
string bannerBackgroundColor = "#00000000",
|
||||||
bool debugMode = false,
|
bool debugMode = false,
|
||||||
bool useAdjustDeeplink = false,
|
Action<string> onAdjustDeeplinkCallback = null,
|
||||||
Dictionary<string, object> defaultRemoteData = null,
|
Dictionary<string, object> defaultRemoteData = null,
|
||||||
byte[] googleKeys = null,
|
byte[] googleKeys = null,
|
||||||
byte[] appleRootCerts = null,
|
byte[] appleRootCerts = null,
|
||||||
|
|
@ -93,7 +95,7 @@ namespace Guru
|
||||||
IsBuyNoAds = isBuyNoAds,
|
IsBuyNoAds = isBuyNoAds,
|
||||||
BannerBackgroundColor = bannerBackgroundColor,
|
BannerBackgroundColor = bannerBackgroundColor,
|
||||||
DebugMode = debugMode,
|
DebugMode = debugMode,
|
||||||
UseAdjustDeeplink = useAdjustDeeplink,
|
OnAdjustDeeplinkCallback = onAdjustDeeplinkCallback,
|
||||||
GoogleKeys = googleKeys,
|
GoogleKeys = googleKeys,
|
||||||
AppleRootCerts = appleRootCerts,
|
AppleRootCerts = appleRootCerts,
|
||||||
DefaultRemoteData = defaultRemoteData ?? new Dictionary<string, object>(),
|
DefaultRemoteData = defaultRemoteData ?? new Dictionary<string, object>(),
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ namespace Guru
|
||||||
AdServiceHandler();
|
AdServiceHandler();
|
||||||
|
|
||||||
// 调用回调
|
// 调用回调
|
||||||
Callbacks.ConsentFlow._onConsentResult?.Invoke(code);
|
Callbacks.ConsentFlow.InvokeOnConsentResult(code);
|
||||||
|
|
||||||
#if UNITY_IOS
|
#if UNITY_IOS
|
||||||
CheckAttStatus(); // [iOS] Consent 启动后检查 ATT 初始值
|
CheckAttStatus(); // [iOS] Consent 启动后检查 ATT 初始值
|
||||||
|
|
@ -240,7 +240,7 @@ namespace Guru
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitNotiPermission()
|
private void InitNotiPermission()
|
||||||
{
|
{
|
||||||
bool hasNotiGranted = false;
|
// bool hasNotiGranted = false;
|
||||||
_notiStatue = "no_determined";
|
_notiStatue = "no_determined";
|
||||||
NotificationService.Initialize(); // 初始化 Noti 服务
|
NotificationService.Initialize(); // 初始化 Noti 服务
|
||||||
SetNotiPerm(NotificationService.GetStatus());
|
SetNotiPerm(NotificationService.GetStatus());
|
||||||
|
|
@ -256,15 +256,15 @@ namespace Guru
|
||||||
// 如果未启用自动 Noti 授权,则直接上报状态
|
// 如果未启用自动 Noti 授权,则直接上报状态
|
||||||
if (!_initConfig.AutoNotificationPermission)
|
if (!_initConfig.AutoNotificationPermission)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogWarning($"[SDK] ---- AutoNotificationPermission is OFF, Project should request permission own.");
|
Debug.LogWarning($"[SDK] ---- AutoNotificationPermission is OFF, Project should request permission own.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isGranted = NotificationService.IsPermissionGranted();
|
bool isGranted = NotificationService.IsPermissionGranted();
|
||||||
UnityEngine.Debug.Log($"[SDK] ---- Check Noti Permission: {isGranted}");
|
Debug.Log($"[SDK] ---- Check Noti Permission: {isGranted}");
|
||||||
if (isGranted)
|
if (isGranted)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log($"[SDK] ---- Set Notification Permission: {status}");
|
Debug.Log($"[SDK] ---- Set Notification Permission: {status}");
|
||||||
SetNotiPerm(status);
|
SetNotiPerm(status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -280,10 +280,10 @@ namespace Guru
|
||||||
{
|
{
|
||||||
FirebaseUtil.StartFetchFcmToken();
|
FirebaseUtil.StartFetchFcmToken();
|
||||||
|
|
||||||
UnityEngine.Debug.Log($"[SDK] ---- RequestNotificationPermission");
|
Debug.Log($"[SDK] ---- RequestNotificationPermission");
|
||||||
NotificationService.RequestPermission(status =>
|
NotificationService.RequestPermission(status =>
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log($"[SDK] ---- Set Notification Permission: {status}");
|
Debug.Log($"[SDK] ---- Set Notification Permission: {status}");
|
||||||
if(!string.IsNullOrEmpty(status)) SetNotiPerm(status);
|
if(!string.IsNullOrEmpty(status)) SetNotiPerm(status);
|
||||||
|
|
||||||
callback?.Invoke(status);
|
callback?.Invoke(status);
|
||||||
|
|
@ -313,7 +313,6 @@ namespace Guru
|
||||||
#region Ad Services
|
#region Ad Services
|
||||||
|
|
||||||
private static bool _initAdsCompleted = false;
|
private static bool _initAdsCompleted = false;
|
||||||
private static bool _isBannerVisible = false;
|
|
||||||
public static bool IsAdsReady => _initAdsCompleted;
|
public static bool IsAdsReady => _initAdsCompleted;
|
||||||
private static int _preBannerAction = 0;
|
private static int _preBannerAction = 0;
|
||||||
|
|
||||||
|
|
@ -347,18 +346,18 @@ namespace Guru
|
||||||
|
|
||||||
//--------- Add Callbacks -----------
|
//--------- Add Callbacks -----------
|
||||||
// BADS
|
// BADS
|
||||||
ADService.OnBannerStartLoad = OnBannerStartLoad;
|
ADService.Instance.OnBannerStartLoad = OnBannerStartLoad;
|
||||||
ADService.OnBannerLoaded = OnBannerLoaded;
|
ADService.Instance.OnBannerLoaded = OnBannerLoaded;
|
||||||
// IADS
|
// IADS
|
||||||
ADService.OnInterstitialStartLoad = OnInterstitialStartLoad;
|
ADService.Instance.OnInterstitialStartLoad = OnInterstitialStartLoad;
|
||||||
ADService.OnInterstitialLoaded = OnInterstitialLoaded;
|
ADService.Instance.OnInterstitialLoaded = OnInterstitialLoaded;
|
||||||
ADService.OnInterstitialFailed = OnInterstitialFailed;
|
ADService.Instance.OnInterstitialFailed = OnInterstitialFailed;
|
||||||
ADService.OnInterstitialClosed = OnInterstitialClosed;
|
ADService.Instance.OnInterstitialClosed = OnInterstitialClosed;
|
||||||
// RADS
|
// RADS
|
||||||
ADService.OnRewardedStartLoad = OnRewardStartLoad;
|
ADService.Instance.OnRewardedStartLoad = OnRewardStartLoad;
|
||||||
ADService.OnRewardLoaded = OnRewardLoaded;
|
ADService.Instance.OnRewardLoaded = OnRewardLoaded;
|
||||||
ADService.OnRewardFailed = OnRewardFailed;
|
ADService.Instance.OnRewardFailed = OnRewardFailed;
|
||||||
ADService.OnRewardClosed = OnRewardClosed;
|
ADService.Instance.OnRewardClosed = OnRewardClosed;
|
||||||
|
|
||||||
// ---------- Start Services ----------
|
// ---------- Start Services ----------
|
||||||
ADService.Instance.StartService(OnAdsInitComplete, spec);
|
ADService.Instance.StartService(OnAdsInitComplete, spec);
|
||||||
|
|
@ -378,25 +377,25 @@ namespace Guru
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnBannerStartLoad(string adUnitId)
|
private static void OnBannerStartLoad(string adUnitId)
|
||||||
=> Callbacks.Ads._onBannerADStartLoad?.Invoke(adUnitId);
|
=> Callbacks.Ads.InvokeOnBannerADStartLoad(adUnitId);
|
||||||
private static void OnBannerLoaded()
|
private static void OnBannerLoaded()
|
||||||
=> Callbacks.Ads._onBannerADLoaded?.Invoke();
|
=> Callbacks.Ads.InvokeOnBannerADLoaded();
|
||||||
private static void OnInterstitialStartLoad(string adUnitId)
|
private static void OnInterstitialStartLoad(string adUnitId)
|
||||||
=> Callbacks.Ads._onInterstitialADStartLoad?.Invoke(adUnitId);
|
=> Callbacks.Ads.InvokeOnInterstitialADStartLoad(adUnitId);
|
||||||
private static void OnInterstitialLoaded()
|
private static void OnInterstitialLoaded()
|
||||||
=> Callbacks.Ads._onInterstitialADLoaded?.Invoke();
|
=> Callbacks.Ads.InvokeOnInterstitialADLoaded();
|
||||||
private static void OnInterstitialFailed()
|
private static void OnInterstitialFailed()
|
||||||
=> Callbacks.Ads._onInterstitialADFailed?.Invoke();
|
=> Callbacks.Ads.InvokeOnInterstitialADFailed();
|
||||||
private static void OnInterstitialClosed()
|
private static void OnInterstitialClosed()
|
||||||
=> Callbacks.Ads._onInterstitialADClosed?.Invoke();
|
=> Callbacks.Ads.InvokeOnInterstitialADClosed();
|
||||||
private static void OnRewardStartLoad(string adUnitId)
|
private static void OnRewardStartLoad(string adUnitId)
|
||||||
=> Callbacks.Ads._onRewardedADStartLoad?.Invoke(adUnitId);
|
=> Callbacks.Ads.InvokeOnRewardedADStartLoad(adUnitId);
|
||||||
private static void OnRewardLoaded()
|
private static void OnRewardLoaded()
|
||||||
=> Callbacks.Ads._onRewardedADLoaded?.Invoke();
|
=> Callbacks.Ads.InvokeOnRewardedADLoaded();
|
||||||
private static void OnRewardFailed()
|
private static void OnRewardFailed()
|
||||||
=> Callbacks.Ads._onRewardADFailed?.Invoke();
|
=> Callbacks.Ads.InvokeOnRewardADFailed();
|
||||||
private static void OnRewardClosed()
|
private static void OnRewardClosed()
|
||||||
=> Callbacks.Ads._onRewardADClosed?.Invoke();
|
=> Callbacks.Ads.InvokeOnRewardADClosed();
|
||||||
|
|
||||||
private static void OnAdsInitComplete()
|
private static void OnAdsInitComplete()
|
||||||
{
|
{
|
||||||
|
|
@ -416,7 +415,7 @@ namespace Guru
|
||||||
HideBanner();
|
HideBanner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Callbacks.Ads._onAdsInitComplete?.Invoke();
|
Callbacks.Ads.InvokeOnAdsInitComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool CheckAdsReady()
|
private static bool CheckAdsReady()
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,15 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Guru
|
namespace Guru
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打点管理
|
/// 打点管理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class GuruSDK
|
public partial class GuruSDK
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 主线关卡类型
|
|
||||||
/// 只有传入此类型时才会进行 Blevel 的累加
|
|
||||||
/// </summary>
|
|
||||||
public const string LevelTypeMain = "main";
|
|
||||||
|
|
||||||
//----------------- 关卡开始类型 ---------------------
|
|
||||||
public const string EventLevelStartModePlay = "play";
|
|
||||||
public const string EventLevelStartModeReplay = "replay";
|
|
||||||
public const string EventLevelStartModeContinue= "continue";
|
|
||||||
|
|
||||||
//----------------- 关卡结束类型 ---------------------
|
|
||||||
public const string EventLevelEndSuccess = "success";
|
|
||||||
public const string EventLevelEndFail = "fail";
|
|
||||||
public const string EventLevelEndExit = "exit";
|
|
||||||
public const string EventLevelEndTimeout = "timeout";
|
|
||||||
|
|
||||||
private const string KeyCachedScreen = "k_cached_screen";
|
|
||||||
|
|
||||||
#region 通用接口
|
#region 通用接口
|
||||||
|
|
||||||
|
|
@ -79,13 +56,13 @@ namespace Guru
|
||||||
/// <param name="startType">关卡开始类型: play:开始游戏;replay:重玩;continue:继续游戏</param>
|
/// <param name="startType">关卡开始类型: play:开始游戏;replay:重玩;continue:继续游戏</param>
|
||||||
/// <param name="isReplay">是否重新开始: true/false</param>
|
/// <param name="isReplay">是否重新开始: true/false</param>
|
||||||
/// <param name="extra">扩展数据</param>
|
/// <param name="extra">扩展数据</param>
|
||||||
public static void LogLevelStart(int levelId, string startType = EventLevelStartModePlay,
|
public static void LogLevelStart(int levelId, string startType = Consts.EventLevelStartModePlay,
|
||||||
string levelType = LevelTypeMain, string levelName = "", string itemId = "",
|
string levelType = Consts.LevelTypeMain, string levelName = "", string itemId = "",
|
||||||
bool isReplay = false, Dictionary<string, object> extra = null)
|
bool isReplay = false, Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
if (!IsInitialSuccess)
|
if (!IsInitialSuccess)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"{Tag} :: LogLevelStart {levelId} :: Please call <GuruSDK.Start()> first, before you call <LogLevelStart>.");
|
Debug.LogError($"{Tag} :: LogLevelStart {levelId} :: Please call <GuruSDK.Start()> first, before you call <LogLevelStart>.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,10 +77,10 @@ namespace Guru
|
||||||
/// <param name="levelName"></param>
|
/// <param name="levelName"></param>
|
||||||
/// <param name="itemId"></param>
|
/// <param name="itemId"></param>
|
||||||
/// <param name="extra"></param>
|
/// <param name="extra"></param>
|
||||||
public static void LogLevelContinue(int levelId, string levelType = LevelTypeMain,
|
public static void LogLevelContinue(int levelId, string levelType = Consts.LevelTypeMain,
|
||||||
string levelName = "", string itemId = "", Dictionary<string, object> extra = null)
|
string levelName = "", string itemId = "", Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
LogLevelStart(levelId, EventLevelStartModeContinue, levelType, levelName, itemId, true, extra:extra);
|
LogLevelStart(levelId, Consts.EventLevelStartModeContinue, levelType, levelName, itemId, true, extra:extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -113,10 +90,10 @@ namespace Guru
|
||||||
/// <param name="levelType"></param>
|
/// <param name="levelType"></param>
|
||||||
/// <param name="levelName"></param>
|
/// <param name="levelName"></param>
|
||||||
/// <param name="itemId"></param>
|
/// <param name="itemId"></param>
|
||||||
public static void LogLevelReplay(int levelId, string levelType = LevelTypeMain,
|
public static void LogLevelReplay(int levelId, string levelType = Consts.LevelTypeMain,
|
||||||
string levelName = "", string itemId = "", Dictionary<string, object> extra = null)
|
string levelName = "", string itemId = "", Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
LogLevelStart(levelId, EventLevelStartModeReplay,levelType, levelName, itemId, true, extra:extra);
|
LogLevelStart(levelId, Consts.EventLevelStartModeReplay,levelType, levelName, itemId, true, extra:extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -131,13 +108,13 @@ namespace Guru
|
||||||
/// <param name="step">步数(有则上报)</param>
|
/// <param name="step">步数(有则上报)</param>
|
||||||
/// <param name="score">分数(有则上报)</param>
|
/// <param name="score">分数(有则上报)</param>
|
||||||
/// <param name="extra">扩展数据</param>
|
/// <param name="extra">扩展数据</param>
|
||||||
public static void LogLevelEnd(int levelId, string result = EventLevelEndSuccess,
|
public static void LogLevelEnd(int levelId, string result = Consts.EventLevelEndSuccess,
|
||||||
string levelType = LevelTypeMain, string levelName = "", string itemId = "",
|
string levelType = Consts.LevelTypeMain, string levelName = "", string itemId = "",
|
||||||
int duration = 0, int? step = null, int? score = null, Dictionary<string, object> extra = null)
|
int duration = 0, int? step = null, int? score = null, Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
if (!IsInitialSuccess)
|
if (!IsInitialSuccess)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError(
|
Debug.LogError(
|
||||||
$"{Tag} :: LogLevelEnd {levelId} :: Please call <GuruSDK.Start()> first, before you call <LogLevelEnd>.");
|
$"{Tag} :: LogLevelEnd {levelId} :: Please call <GuruSDK.Start()> first, before you call <LogLevelEnd>.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -147,9 +124,9 @@ namespace Guru
|
||||||
// 自动记录关卡属性
|
// 自动记录关卡属性
|
||||||
if (InitConfig.AutoRecordFinishedLevels)
|
if (InitConfig.AutoRecordFinishedLevels)
|
||||||
{
|
{
|
||||||
if (result == EventLevelEndSuccess)
|
if (result == Consts.EventLevelEndSuccess)
|
||||||
{
|
{
|
||||||
if (levelType == LevelTypeMain)
|
if (levelType == Consts.LevelTypeMain)
|
||||||
{
|
{
|
||||||
if (levelId > Model.SuccessLevelId) Model.SuccessLevelId = levelId; // 自动记录关卡完成次数
|
if (levelId > Model.SuccessLevelId) Model.SuccessLevelId = levelId; // 自动记录关卡完成次数
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +152,7 @@ namespace Guru
|
||||||
/// <param name="duration"></param>
|
/// <param name="duration"></param>
|
||||||
/// <param name="extra"></param>
|
/// <param name="extra"></param>
|
||||||
public static void LogLevelFirstEnd(string levelType, string levelName, int level,
|
public static void LogLevelFirstEnd(string levelType, string levelName, int level,
|
||||||
string result = EventLevelEndSuccess, int duration = 0, Dictionary<string, object> extra = null)
|
string result = Consts.EventLevelEndSuccess, int duration = 0, Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
Analytics.LevelFirstEnd(levelType, levelName, level, result, duration, extra);
|
Analytics.LevelFirstEnd(levelType, levelName, level, result, duration, extra);
|
||||||
}
|
}
|
||||||
|
|
@ -203,10 +180,10 @@ namespace Guru
|
||||||
/// <param name="score"></param>
|
/// <param name="score"></param>
|
||||||
/// <param name="extra"></param>
|
/// <param name="extra"></param>
|
||||||
public static void LogLevelFail(int levelId,
|
public static void LogLevelFail(int levelId,
|
||||||
string levelType = LevelTypeMain, string levelName = "", string itemId = "",
|
string levelType = Consts.LevelTypeMain, string levelName = "", string itemId = "",
|
||||||
int duration = 0, int? step = null, int? score = null , Dictionary<string, object> extra = null)
|
int duration = 0, int? step = null, int? score = null , Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
LogLevelEnd(levelId, EventLevelEndFail, levelType, levelName, itemId, duration, step, score, extra);
|
LogLevelEnd(levelId, Consts.EventLevelEndFail, levelType, levelName, itemId, duration, step, score, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -221,10 +198,10 @@ namespace Guru
|
||||||
/// <param name="score"></param>
|
/// <param name="score"></param>
|
||||||
/// <param name="extra"></param>
|
/// <param name="extra"></param>
|
||||||
public static void LogLevelFailExit(int levelId,
|
public static void LogLevelFailExit(int levelId,
|
||||||
string levelType = LevelTypeMain, string levelName = "", string itemId = "",
|
string levelType = Consts.LevelTypeMain, string levelName = "", string itemId = "",
|
||||||
int duration = 0, int? step = null, int? score = null, Dictionary<string, object> extra = null)
|
int duration = 0, int? step = null, int? score = null, Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
LogLevelEnd(levelId, EventLevelEndExit, levelType, levelName, itemId, duration, step, score, extra);
|
LogLevelEnd(levelId, Consts.EventLevelEndExit, levelType, levelName, itemId, duration, step, score, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -239,10 +216,10 @@ namespace Guru
|
||||||
/// <param name="score"></param>
|
/// <param name="score"></param>
|
||||||
/// <param name="extra"></param>
|
/// <param name="extra"></param>
|
||||||
public static void LogLevelFailTimeout(int levelId,
|
public static void LogLevelFailTimeout(int levelId,
|
||||||
string levelType = LevelTypeMain, string levelName = "", string itemId = "",
|
string levelType = Consts.LevelTypeMain, string levelName = "", string itemId = "",
|
||||||
int duration = 0, int? step = null, int? score = null, Dictionary<string, object> extra = null)
|
int duration = 0, int? step = null, int? score = null, Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
LogLevelEnd(levelId, EventLevelEndTimeout, levelType, levelName, itemId, duration, step, score, extra);
|
LogLevelEnd(levelId, Consts.EventLevelEndTimeout, levelType, levelName, itemId, duration, step, score, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -256,7 +233,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
if (!IsInitialSuccess)
|
if (!IsInitialSuccess)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"{Tag} :: LogLevelUp {playerLevel} :: Please call <GuruSDK.Start()> first, before you call <LogLevelUp>.");
|
Debug.LogError($"{Tag} :: LogLevelUp {playerLevel} :: Please call <GuruSDK.Start()> first, before you call <LogLevelUp>.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Analytics.LevelUp(playerLevel, characterName, extra);
|
Analytics.LevelUp(playerLevel, characterName, extra);
|
||||||
|
|
@ -271,7 +248,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
if (!IsInitialSuccess)
|
if (!IsInitialSuccess)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"{Tag} :: LogAchievement {achievementId} :: Please call <GuruSDK.Start()> first, before you call <LogAchievement>.");
|
Debug.LogError($"{Tag} :: LogAchievement {achievementId} :: Please call <GuruSDK.Start()> first, before you call <LogAchievement>.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Analytics.UnlockAchievement(achievementId, extra);
|
Analytics.UnlockAchievement(achievementId, extra);
|
||||||
|
|
@ -326,7 +303,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
if (!IsInitialSuccess)
|
if (!IsInitialSuccess)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"{Tag} :: InitUserProperties :: Please call <GuruSDK.Start()> first, before you call <InitUserProperties>.");
|
Debug.LogError($"{Tag} :: InitUserProperties :: Please call <GuruSDK.Start()> first, before you call <InitUserProperties>.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -339,31 +316,6 @@ namespace Guru
|
||||||
if (Model.IsNoAds) SetBuyNoAds(true); // 设置用户已经购买了去广告
|
if (Model.IsNoAds) SetBuyNoAds(true); // 设置用户已经购买了去广告
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<string, string> _userPropertyCacheData = new Dictionary<string, string>(10);
|
|
||||||
private static HashSet<string> _userPropertyExistKeys = new HashSet<string>();
|
|
||||||
|
|
||||||
private static void RecordUserPropertyKey(string key)
|
|
||||||
{
|
|
||||||
if(_userPropertyExistKeys == null)
|
|
||||||
_userPropertyExistKeys = new HashSet<string>();
|
|
||||||
|
|
||||||
if(!HasUserPropertyKey(key)) _userPropertyExistKeys.Add(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool HasUserPropertyKey(string key)
|
|
||||||
{
|
|
||||||
return _userPropertyExistKeys?.Contains(key) ?? false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CacheUserProperty(string key, string value)
|
|
||||||
{
|
|
||||||
if (_userPropertyCacheData == null) _userPropertyCacheData = new Dictionary<string, string>(10);
|
|
||||||
_userPropertyCacheData[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置用户属性
|
/// 设置用户属性
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -371,7 +323,6 @@ namespace Guru
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public static void SetUserProperty(string key, string value)
|
public static void SetUserProperty(string key, string value)
|
||||||
{
|
{
|
||||||
RecordUserPropertyKey(key); // 记录属性打点
|
|
||||||
Analytics.SetUserProperty(key, value);
|
Analytics.SetUserProperty(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -421,7 +372,7 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上报用户付费金币的 数量 (累加值)
|
/// 上报用户付费金币的 数量 (累加值)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="freeCoins"></param>
|
/// <param name="paidCoins"></param>
|
||||||
public static void SetUserIapCoin(int paidCoins)
|
public static void SetUserIapCoin(int paidCoins)
|
||||||
{
|
{
|
||||||
SetUserProperty(Consts.PropertyIAPCoin, $"{paidCoins}");
|
SetUserProperty(Consts.PropertyIAPCoin, $"{paidCoins}");
|
||||||
|
|
@ -472,62 +423,41 @@ namespace Guru
|
||||||
SetUserProperty(Consts.PropertyNetwork, Instance.GetNetworkStatus());
|
SetUserProperty(Consts.PropertyNetwork, Instance.GetNetworkStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool _hasUserPropertiesInitiallyUpdated = false;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化时调用一下所有的属性打点 </br>
|
/// 初始化时补全一下所有的属性打点
|
||||||
|
/// 如果用户已经设置过 Key, 则不会再次设置
|
||||||
/// <a href="https://docs.google.com/spreadsheets/d/1N47rXgjatRHFvzWWx0Hqv5C1D9NHHGbggi6pQ65c-zQ/edit#gid=1858695240">用户属性文档</a>
|
/// <a href="https://docs.google.com/spreadsheets/d/1N47rXgjatRHFvzWWx0Hqv5C1D9NHHGbggi6pQ65c-zQ/edit#gid=1858695240">用户属性文档</a>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void UpdateAllUserProperties()
|
private static void InitiallyUpdateUserProperties()
|
||||||
{
|
{
|
||||||
if(!HasUserPropertyKey(Consts.PropertyFirstOpenTime))
|
if (_hasUserPropertiesInitiallyUpdated) return;
|
||||||
|
_hasUserPropertiesInitiallyUpdated = true;
|
||||||
|
|
||||||
SetFirstOpenTime(TimeUtil.GetCurrentTimeStamp().ToString()); // first_open_time
|
SetFirstOpenTime(TimeUtil.GetCurrentTimeStamp().ToString()); // first_open_time
|
||||||
|
|
||||||
if(!HasUserPropertyKey(Consts.PropertyIsIAPUser))
|
|
||||||
SetUserIsIAP(Model?.IsIapUser ?? false); // is_iap_user
|
SetUserIsIAP(Model?.IsIapUser ?? false); // is_iap_user
|
||||||
|
|
||||||
if (!HasUserPropertyKey(Consts.PropertyLevel))
|
|
||||||
SetUserBLevel(Model?.SuccessLevelId ?? 0); // b_level
|
SetUserBLevel(Model?.SuccessLevelId ?? 0); // b_level
|
||||||
|
|
||||||
if (!HasUserPropertyKey(Consts.PropertyPlay))
|
|
||||||
SetUserBLevel(Model?.TotalPlayedCount ?? 0); // b_play
|
SetUserBLevel(Model?.TotalPlayedCount ?? 0); // b_play
|
||||||
|
|
||||||
if(!HasUserPropertyKey(Consts.PropertyUserID))
|
|
||||||
SetUserProperty(Consts.PropertyUserID, UID); // user_id
|
|
||||||
|
|
||||||
if(!HasUserPropertyKey(Consts.PropertyDeviceID))
|
|
||||||
SetUserProperty(Consts.PropertyDeviceID, DeviceId); // device_id
|
SetUserProperty(Consts.PropertyDeviceID, DeviceId); // device_id
|
||||||
|
|
||||||
if(!HasUserPropertyKey(Consts.PropertyIAPCoin))
|
|
||||||
SetUserIapCoin(0); // iap_coin
|
SetUserIapCoin(0); // iap_coin
|
||||||
|
|
||||||
if(!HasUserPropertyKey(Consts.PropertyNonIAPCoin))
|
|
||||||
SetUserNonIapCoin(0); // non_iap_coin
|
SetUserNonIapCoin(0); // non_iap_coin
|
||||||
|
|
||||||
if(!HasUserPropertyKey(Consts.PropertyCoin))
|
|
||||||
SetUserCoin(0);// coin
|
SetUserCoin(0);// coin
|
||||||
|
|
||||||
if (!HasUserPropertyKey(Consts.PropertyGrade))
|
|
||||||
SetUserGrade(0); // grade
|
SetUserGrade(0); // grade
|
||||||
|
|
||||||
if(!HasUserPropertyKey(Consts.PropertyExp))
|
|
||||||
SetUserExp(0); // exp
|
SetUserExp(0); // exp
|
||||||
|
|
||||||
if(!HasUserPropertyKey(Consts.PropertyHp))
|
|
||||||
SetUserHp(0); // hp
|
SetUserHp(0); // hp
|
||||||
|
|
||||||
|
if(!string.IsNullOrEmpty(UID))
|
||||||
|
SetUID(UID); // user_id
|
||||||
|
|
||||||
#if UNITY_IOS
|
#if UNITY_IOS
|
||||||
if(!HasUserPropertyKey(Consts.PropertyATTStatus))
|
|
||||||
SetATTStatus("notDetermined"); // att_status
|
SetATTStatus("notDetermined"); // att_status
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!HasUserPropertyKey(Consts.PropertyNotiPerm))
|
|
||||||
SetNotiPerm("not_determined"); // noti_perm
|
SetNotiPerm("not_determined"); // noti_perm
|
||||||
|
|
||||||
if(!HasUserPropertyKey(Consts.PropertyNetwork))
|
|
||||||
SetNetworkStatus(); // NetworkStatus
|
SetNetworkStatus(); // NetworkStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SDK 打点
|
#region SDK 打点
|
||||||
|
|
@ -581,7 +511,7 @@ namespace Guru
|
||||||
/// 当付费页面打开时调用 (iap_imp)
|
/// 当付费页面打开时调用 (iap_imp)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scene">付费页场景名称</param>
|
/// <param name="scene">付费页场景名称</param>
|
||||||
/// <param name="productId">列表中首个商品的 ProductId </param>
|
/// <param name="extra"></param>
|
||||||
public static void LogIAPImp(string scene, Dictionary<string, object> extra = null)
|
public static void LogIAPImp(string scene, Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
Analytics.IAPImp(scene, extra);
|
Analytics.IAPImp(scene, extra);
|
||||||
|
|
@ -591,7 +521,7 @@ namespace Guru
|
||||||
/// 当付费页面关闭时调用 (iap_close)
|
/// 当付费页面关闭时调用 (iap_close)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
/// <param name="productId"></param>
|
/// <param name="extra"></param>
|
||||||
public static void LogIAPClose(string scene, Dictionary<string, object> extra = null)
|
public static void LogIAPClose(string scene, Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
Analytics.IAPClose(scene, extra);
|
Analytics.IAPClose(scene, extra);
|
||||||
|
|
@ -602,7 +532,9 @@ namespace Guru
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
/// <param name="productId"></param>
|
/// <param name="productId"></param>
|
||||||
|
/// <param name="basePlan"></param>
|
||||||
/// <param name="offerId"></param>
|
/// <param name="offerId"></param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogIAPClick(string scene, string productId, string basePlan = "", string offerId = "", Dictionary<string, object> extra = null)
|
public static void LogIAPClick(string scene, string productId, string basePlan = "", string offerId = "", Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
Analytics.IAPClick(scene, productId, basePlan, offerId, extra);
|
Analytics.IAPClick(scene, productId, basePlan, offerId, extra);
|
||||||
|
|
@ -727,6 +659,7 @@ namespace Guru
|
||||||
/// <param name="levelName">当前关卡名称</param>
|
/// <param name="levelName">当前关卡名称</param>
|
||||||
/// <param name="scene">应用场景</param>
|
/// <param name="scene">应用场景</param>
|
||||||
/// <param name="props">获取的道具名称列表</param>
|
/// <param name="props">获取的道具名称列表</param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogEarnVirtualCurrencyBySign(string currencyName,
|
public static void LogEarnVirtualCurrencyBySign(string currencyName,
|
||||||
int value = 0, int balance = 0, string levelName = "",
|
int value = 0, int balance = 0, string levelName = "",
|
||||||
string scene = "home_page", string[] props = null, Dictionary<string, object> extra = null)
|
string scene = "home_page", string[] props = null, Dictionary<string, object> extra = null)
|
||||||
|
|
@ -750,6 +683,7 @@ namespace Guru
|
||||||
/// <param name="levelName">当前关卡名称</param>
|
/// <param name="levelName">当前关卡名称</param>
|
||||||
/// <param name="scene">应用场景</param>
|
/// <param name="scene">应用场景</param>
|
||||||
/// <param name="props">获取的道具名称列表</param>
|
/// <param name="props">获取的道具名称列表</param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogEarnVirtualCurrencyByIAP(string currencyName,
|
public static void LogEarnVirtualCurrencyByIAP(string currencyName,
|
||||||
int value = 0, int balance = 0, string levelName = "",
|
int value = 0, int balance = 0, string levelName = "",
|
||||||
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
||||||
|
|
@ -772,6 +706,7 @@ namespace Guru
|
||||||
/// <param name="levelName">当前关卡名称</param>
|
/// <param name="levelName">当前关卡名称</param>
|
||||||
/// <param name="scene">应用场景</param>
|
/// <param name="scene">应用场景</param>
|
||||||
/// <param name="props">获取的道具名称列表</param>
|
/// <param name="props">获取的道具名称列表</param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogEarnVirtualCurrencyByAds(string currencyName,
|
public static void LogEarnVirtualCurrencyByAds(string currencyName,
|
||||||
int value = 0, int balance = 0, string levelName = "",
|
int value = 0, int balance = 0, string levelName = "",
|
||||||
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
||||||
|
|
@ -793,6 +728,7 @@ namespace Guru
|
||||||
/// <param name="levelName">当前关卡名称</param>
|
/// <param name="levelName">当前关卡名称</param>
|
||||||
/// <param name="scene">应用场景</param>
|
/// <param name="scene">应用场景</param>
|
||||||
/// <param name="props">获取的道具名称列表</param>
|
/// <param name="props">获取的道具名称列表</param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogEarnVirtualCurrencyByPaidAds(string currencyName,
|
public static void LogEarnVirtualCurrencyByPaidAds(string currencyName,
|
||||||
int value = 0, int balance = 0, string levelName = "",
|
int value = 0, int balance = 0, string levelName = "",
|
||||||
string scene = Consts.ParameterDefaultScene, string[] props = null, Dictionary<string, object> extra = null)
|
string scene = Consts.ParameterDefaultScene, string[] props = null, Dictionary<string, object> extra = null)
|
||||||
|
|
@ -814,6 +750,7 @@ namespace Guru
|
||||||
/// <param name="levelName">当前关卡名称</param>
|
/// <param name="levelName">当前关卡名称</param>
|
||||||
/// <param name="scene">应用场景</param>
|
/// <param name="scene">应用场景</param>
|
||||||
/// <param name="props">获取的道具名称列表</param>
|
/// <param name="props">获取的道具名称列表</param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogEarnVirtualCurrencyByLevelComplete(string currencyName,
|
public static void LogEarnVirtualCurrencyByLevelComplete(string currencyName,
|
||||||
int value = 0, int balance = 0, string levelName = "",
|
int value = 0, int balance = 0, string levelName = "",
|
||||||
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
||||||
|
|
@ -853,6 +790,7 @@ namespace Guru
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="balance"></param>
|
/// <param name="balance"></param>
|
||||||
/// <param name="levelName"></param>
|
/// <param name="levelName"></param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogEarnPropByProp(string propName, string otherName,
|
public static void LogEarnPropByProp(string propName, string otherName,
|
||||||
string scene = Consts.ParameterDefaultScene,
|
string scene = Consts.ParameterDefaultScene,
|
||||||
int value = 1, int balance = 0, string levelName = "", Dictionary<string, object> extra = null)
|
int value = 1, int balance = 0, string levelName = "", Dictionary<string, object> extra = null)
|
||||||
|
|
@ -874,6 +812,7 @@ namespace Guru
|
||||||
/// <param name="levelName">当前关卡名称</param>
|
/// <param name="levelName">当前关卡名称</param>
|
||||||
/// <param name="scene">应用场景</param>
|
/// <param name="scene">应用场景</param>
|
||||||
/// <param name="props">获取的道具名称列表</param>
|
/// <param name="props">获取的道具名称列表</param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogEarnVirtualCurrencyByLottery(string currencyName,
|
public static void LogEarnVirtualCurrencyByLottery(string currencyName,
|
||||||
int value = 0, int balance = 0, string levelName = "",
|
int value = 0, int balance = 0, string levelName = "",
|
||||||
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
string scene = "store", string[] props = null, Dictionary<string, object> extra = null)
|
||||||
|
|
@ -899,6 +838,7 @@ namespace Guru
|
||||||
/// <param name="levelName">当前关卡或者人物等级名称</param>
|
/// <param name="levelName">当前关卡或者人物等级名称</param>
|
||||||
/// <param name="itemName">购买道具名称</param>
|
/// <param name="itemName">购买道具名称</param>
|
||||||
/// <param name="scene">购买场景如 Store, Workbench, Sign, Ads....</param>
|
/// <param name="scene">购买场景如 Store, Workbench, Sign, Ads....</param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogSpendVirtualCurrency(string currencyName, int value, int balance, string category = "", string itemName = "",
|
public static void LogSpendVirtualCurrency(string currencyName, int value, int balance, string category = "", string itemName = "",
|
||||||
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
||||||
{
|
{
|
||||||
|
|
@ -911,7 +851,6 @@ namespace Guru
|
||||||
/// <param name="currencyName">货币/道具名称</param>
|
/// <param name="currencyName">货币/道具名称</param>
|
||||||
/// <param name="value">货币消耗值 10</param>
|
/// <param name="value">货币消耗值 10</param>
|
||||||
/// <param name="balance">结算后货币总量 30 -> 20</param>
|
/// <param name="balance">结算后货币总量 30 -> 20</param>
|
||||||
/// <param name="category"></param>
|
|
||||||
/// <param name="itemName"></param>
|
/// <param name="itemName"></param>
|
||||||
/// <param name="levelName"></param>
|
/// <param name="levelName"></param>
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
|
|
@ -932,6 +871,7 @@ namespace Guru
|
||||||
/// <param name="balance"></param>
|
/// <param name="balance"></param>
|
||||||
/// <param name="levelName"></param>
|
/// <param name="levelName"></param>
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogSpendVirtualCurrencyWithProp(string currencyName, string prop,
|
public static void LogSpendVirtualCurrencyWithProp(string currencyName, string prop,
|
||||||
int value, int balance,
|
int value, int balance,
|
||||||
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
||||||
|
|
@ -949,6 +889,7 @@ namespace Guru
|
||||||
/// <param name="balance"></param>
|
/// <param name="balance"></param>
|
||||||
/// <param name="levelName"></param>
|
/// <param name="levelName"></param>
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogSpendVirtualCurrencyWithProps(string currencyName, string[] props,
|
public static void LogSpendVirtualCurrencyWithProps(string currencyName, string[] props,
|
||||||
int value, int balance,
|
int value, int balance,
|
||||||
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
||||||
|
|
@ -974,6 +915,7 @@ namespace Guru
|
||||||
/// <param name="balance"></param>
|
/// <param name="balance"></param>
|
||||||
/// <param name="levelName"></param>
|
/// <param name="levelName"></param>
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogSpendVirtualCurrencyWithBundle(string currencyName, string bundle,
|
public static void LogSpendVirtualCurrencyWithBundle(string currencyName, string bundle,
|
||||||
int value, int balance,
|
int value, int balance,
|
||||||
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
||||||
|
|
@ -990,6 +932,7 @@ namespace Guru
|
||||||
/// <param name="balance"></param>
|
/// <param name="balance"></param>
|
||||||
/// <param name="levelName"></param>
|
/// <param name="levelName"></param>
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogSpendVirtualCurrencyWithBundles(string currencyName, string[] bundles,
|
public static void LogSpendVirtualCurrencyWithBundles(string currencyName, string[] bundles,
|
||||||
int value, int balance,
|
int value, int balance,
|
||||||
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
||||||
|
|
@ -1009,12 +952,14 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 消耗物品, 交换其他物品 (spend_virtual_currency) (prop)
|
/// 消耗物品, 交换其他物品 (spend_virtual_currency) (prop)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="currencyName"></param>
|
/// <param name="propName"></param>
|
||||||
/// <param name="bundles"></param>
|
/// <param name="otherName"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="balance"></param>
|
/// <param name="balance"></param>
|
||||||
/// <param name="levelName"></param>
|
/// <param name="levelName"></param>
|
||||||
/// <param name="scene"></param>
|
/// <param name="scene"></param>
|
||||||
|
/// <param name="extraCategory"></param>
|
||||||
|
/// <param name="extra"></param>
|
||||||
public static void LogSpendPropWithProp(string propName, string otherName,
|
public static void LogSpendPropWithProp(string propName, string otherName,
|
||||||
int value, int balance,
|
int value, int balance,
|
||||||
string levelName = "", string scene = "", string extraCategory = "", Dictionary<string, object> extra = null)
|
string levelName = "", string scene = "", string extraCategory = "", Dictionary<string, object> extra = null)
|
||||||
|
|
@ -1318,19 +1263,12 @@ namespace Guru
|
||||||
/// <param name="eventNames"></param>
|
/// <param name="eventNames"></param>
|
||||||
public static void SetEventPriority(EventPriority priority, string[] eventNames)
|
public static void SetEventPriority(EventPriority priority, string[] eventNames)
|
||||||
{
|
{
|
||||||
// if (!IsInitialSuccess)
|
|
||||||
// {
|
|
||||||
// UnityEngine.Debug.LogError($"{Tag} :: LogEvent {priority} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (Model.event_priorities == null) Model.event_priorities = new Dictionary<string, int>(10);
|
if (Model.event_priorities == null) Model.event_priorities = new Dictionary<string, int>(10);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
string evt = "";
|
|
||||||
while (i < eventNames.Length)
|
while (i < eventNames.Length)
|
||||||
{
|
{
|
||||||
evt = eventNames[i];
|
var evt = eventNames[i];
|
||||||
if (!string.IsNullOrEmpty(evt))
|
if (!string.IsNullOrEmpty(evt))
|
||||||
{
|
{
|
||||||
Model.event_priorities[evt] = (int)priority;
|
Model.event_priorities[evt] = (int)priority;
|
||||||
|
|
@ -1341,12 +1279,6 @@ namespace Guru
|
||||||
|
|
||||||
public static void SetEventPriority(EventPriority priority, string eventName)
|
public static void SetEventPriority(EventPriority priority, string eventName)
|
||||||
{
|
{
|
||||||
// if (!IsInitialSuccess)
|
|
||||||
// {
|
|
||||||
// UnityEngine.Debug.LogError($"{Tag} :: LogEvent {priority} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
SetEventPriority(priority, new string[]{eventName});
|
SetEventPriority(priority, new string[]{eventName});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
namespace Guru
|
namespace Guru
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
|
|
||||||
public partial class GuruSDK
|
public partial class GuruSDK
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 回调参数类
|
/// 回调参数类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -18,22 +15,28 @@ namespace Guru
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class App
|
public static class App
|
||||||
{
|
{
|
||||||
// TODO: 改为 Invoke 方法
|
private static Action<bool> _onAppPaused;
|
||||||
internal static Action<bool> _onAppPaused;
|
|
||||||
public static event Action<bool> OnAppPaused
|
public static event Action<bool> OnAppPaused
|
||||||
{
|
{
|
||||||
add => _onAppPaused += value;
|
add => _onAppPaused += value;
|
||||||
remove => _onAppPaused -= value;
|
remove => _onAppPaused -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnAppPaused(bool isPaused)
|
||||||
internal static Action _onAppQuit;
|
{
|
||||||
|
_onAppPaused?.Invoke(isPaused);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action _onAppQuit;
|
||||||
public static event Action OnAppQuit
|
public static event Action OnAppQuit
|
||||||
{
|
{
|
||||||
add => _onAppQuit += value;
|
add => _onAppQuit += value;
|
||||||
remove => _onAppQuit -= value;
|
remove => _onAppQuit -= value;
|
||||||
}
|
}
|
||||||
|
internal static void InvokeOnAppQuit()
|
||||||
|
{
|
||||||
|
_onAppQuit?.Invoke();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GDPR Consent
|
/// GDPR Consent
|
||||||
|
|
@ -48,8 +51,11 @@ namespace Guru
|
||||||
add => _onConsentResult += value;
|
add => _onConsentResult += value;
|
||||||
remove => _onConsentResult -= value;
|
remove => _onConsentResult -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
private static Action<int> _onConsentResult;
|
||||||
internal static Action<int> _onConsentResult;
|
internal static void InvokeOnConsentResult(int code)
|
||||||
|
{
|
||||||
|
_onConsentResult?.Invoke(code);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ATT 状态返回
|
/// ATT 状态返回
|
||||||
|
|
@ -59,9 +65,11 @@ namespace Guru
|
||||||
add => _onAttResult += value;
|
add => _onAttResult += value;
|
||||||
remove => _onAttResult -= value;
|
remove => _onAttResult -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
private static Action<int> _onAttResult;
|
||||||
internal static Action<int> _onAttResult;
|
internal static void InvokeOnAttResultCallback(int code)
|
||||||
|
{
|
||||||
|
_onAttResult?.Invoke(code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -69,89 +77,129 @@ namespace Guru
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Ads
|
public static class Ads
|
||||||
{
|
{
|
||||||
// TODO: 改为 Invoke 方法
|
private static Action _onAdsInitComplete;
|
||||||
internal static Action _onAdsInitComplete;
|
|
||||||
public static event Action OnAdsInitComplete
|
public static event Action OnAdsInitComplete
|
||||||
{
|
{
|
||||||
add => _onAdsInitComplete += value;
|
add => _onAdsInitComplete += value;
|
||||||
remove => _onAdsInitComplete -= value;
|
remove => _onAdsInitComplete -= value;
|
||||||
}
|
}
|
||||||
|
internal static void InvokeOnAdsInitComplete()
|
||||||
|
{
|
||||||
|
_onAdsInitComplete?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: 改为 Invoke 方法
|
|
||||||
//------------ BANNER -----------------
|
//------------ BANNER -----------------
|
||||||
internal static Action<string> _onBannerADStartLoad;
|
private static Action<string> _onBannerADStartLoad;
|
||||||
public static event Action<string> OnBannerADStartLoad
|
public static event Action<string> OnBannerADStartLoad
|
||||||
{
|
{
|
||||||
add => _onBannerADStartLoad += value;
|
add => _onBannerADStartLoad += value;
|
||||||
remove => _onBannerADStartLoad -= value;
|
remove => _onBannerADStartLoad -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnBannerADStartLoad(string adUnitId)
|
||||||
internal static Action _onBannerADLoaded;
|
{
|
||||||
|
_onBannerADStartLoad?.Invoke(adUnitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action _onBannerADLoaded;
|
||||||
public static event Action OnBannerADLoaded
|
public static event Action OnBannerADLoaded
|
||||||
{
|
{
|
||||||
add => _onBannerADLoaded += value;
|
add => _onBannerADLoaded += value;
|
||||||
remove => _onBannerADLoaded -= value;
|
remove => _onBannerADLoaded -= value;
|
||||||
}
|
}
|
||||||
|
internal static void InvokeOnBannerADLoaded()
|
||||||
|
{
|
||||||
|
_onBannerADLoaded?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
//------------ INTER -----------------
|
//------------ INTER -----------------
|
||||||
// TODO: 改为 Invoke 方法
|
private static Action<string> _onInterstitialADStartLoad;
|
||||||
internal static Action<string> _onInterstitialADStartLoad;
|
|
||||||
public static event Action<string> OnInterstitialADStartLoad
|
public static event Action<string> OnInterstitialADStartLoad
|
||||||
{
|
{
|
||||||
add => _onInterstitialADStartLoad += value;
|
add => _onInterstitialADStartLoad += value;
|
||||||
remove => _onInterstitialADStartLoad -= value;
|
remove => _onInterstitialADStartLoad -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnInterstitialADStartLoad(string adUnitId)
|
||||||
internal static Action _onInterstitialADLoaded;
|
{
|
||||||
|
_onInterstitialADStartLoad?.Invoke(adUnitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action _onInterstitialADLoaded;
|
||||||
public static event Action OnInterstitialADLoaded
|
public static event Action OnInterstitialADLoaded
|
||||||
{
|
{
|
||||||
add => _onInterstitialADLoaded += value;
|
add => _onInterstitialADLoaded += value;
|
||||||
remove => _onInterstitialADLoaded -= value;
|
remove => _onInterstitialADLoaded -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnInterstitialADLoaded()
|
||||||
internal static Action _onInterstitialADFailed;
|
{
|
||||||
|
_onInterstitialADLoaded?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action _onInterstitialADFailed;
|
||||||
public static event Action OnInterstitialADFailed
|
public static event Action OnInterstitialADFailed
|
||||||
{
|
{
|
||||||
add => _onInterstitialADFailed += value;
|
add => _onInterstitialADFailed += value;
|
||||||
remove => _onInterstitialADFailed -= value;
|
remove => _onInterstitialADFailed -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnInterstitialADFailed()
|
||||||
internal static Action _onInterstitialADClosed;
|
{
|
||||||
|
_onInterstitialADFailed?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action _onInterstitialADClosed;
|
||||||
public static event Action OnInterstitialADClosed
|
public static event Action OnInterstitialADClosed
|
||||||
{
|
{
|
||||||
add => _onInterstitialADClosed += value;
|
add => _onInterstitialADClosed += value;
|
||||||
remove => _onInterstitialADClosed -= value;
|
remove => _onInterstitialADClosed -= value;
|
||||||
}
|
}
|
||||||
|
internal static void InvokeOnInterstitialADClosed()
|
||||||
|
{
|
||||||
|
_onInterstitialADClosed?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
//------------ REWARD -----------------
|
//------------ REWARD -----------------
|
||||||
// TODO: 改为 Invoke 方法
|
private static Action<string> _onRewardedADStartLoad;
|
||||||
internal static Action<string> _onRewardedADStartLoad;
|
|
||||||
public static event Action<string> OnRewardedADStartLoad
|
public static event Action<string> OnRewardedADStartLoad
|
||||||
{
|
{
|
||||||
add => _onRewardedADStartLoad += value;
|
add => _onRewardedADStartLoad += value;
|
||||||
remove => _onRewardedADStartLoad -= value;
|
remove => _onRewardedADStartLoad -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnRewardedADStartLoad(string adUnitId)
|
||||||
internal static Action _onRewardedADLoaded;
|
{
|
||||||
|
_onRewardedADStartLoad?.Invoke(adUnitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action _onRewardedADLoaded;
|
||||||
public static event Action OnRewardedADLoaded
|
public static event Action OnRewardedADLoaded
|
||||||
{
|
{
|
||||||
add => _onRewardedADLoaded += value;
|
add => _onRewardedADLoaded += value;
|
||||||
remove => _onRewardedADLoaded -= value;
|
remove => _onRewardedADLoaded -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnRewardedADLoaded()
|
||||||
internal static Action _onRewardADClosed;
|
{
|
||||||
|
_onRewardedADLoaded?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action _onRewardADClosed;
|
||||||
public static event Action OnRewardedADClosed
|
public static event Action OnRewardedADClosed
|
||||||
{
|
{
|
||||||
add => _onRewardADClosed += value;
|
add => _onRewardADClosed += value;
|
||||||
remove => _onRewardADClosed -= value;
|
remove => _onRewardADClosed -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnRewardADClosed()
|
||||||
internal static Action _onRewardADFailed;
|
{
|
||||||
|
_onRewardADClosed?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action _onRewardADFailed;
|
||||||
public static event Action OnRewardADFailed
|
public static event Action OnRewardADFailed
|
||||||
{
|
{
|
||||||
add => _onRewardADFailed += value;
|
add => _onRewardADFailed += value;
|
||||||
remove => _onRewardADFailed -= value;
|
remove => _onRewardADFailed -= value;
|
||||||
}
|
}
|
||||||
|
internal static void InvokeOnRewardADFailed()
|
||||||
|
{
|
||||||
|
_onRewardADFailed?.Invoke();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -159,13 +207,16 @@ namespace Guru
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Remote
|
public static class Remote
|
||||||
{
|
{
|
||||||
// TODO: 改为 Invoke 方法
|
private static Action<bool> _onRemoteFetchComplete;
|
||||||
internal static Action<bool> _onRemoteFetchComplete;
|
|
||||||
public static event Action<bool> OnRemoteFetchComplete
|
public static event Action<bool> OnRemoteFetchComplete
|
||||||
{
|
{
|
||||||
add => _onRemoteFetchComplete += value;
|
add => _onRemoteFetchComplete += value;
|
||||||
remove => _onRemoteFetchComplete -= value;
|
remove => _onRemoteFetchComplete -= value;
|
||||||
}
|
}
|
||||||
|
internal static void InvokeOnRemoteFetchComplete(bool success)
|
||||||
|
{
|
||||||
|
_onRemoteFetchComplete?.Invoke(success);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -173,92 +224,137 @@ namespace Guru
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class IAP
|
public static class IAP
|
||||||
{
|
{
|
||||||
// TODO: 改为 Invoke 方法
|
private static Action _onIAPInitStart;
|
||||||
internal static Action _onIAPInitStart;
|
|
||||||
public static event Action OnIAPInitStart
|
public static event Action OnIAPInitStart
|
||||||
{
|
{
|
||||||
add => _onIAPInitStart += value;
|
add => _onIAPInitStart += value;
|
||||||
remove => _onIAPInitStart -= value;
|
remove => _onIAPInitStart -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnIAPInitStart()
|
||||||
internal static Action<bool> _onIAPInitComplete;
|
{
|
||||||
|
_onIAPInitStart?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static Action<bool> _onIAPInitComplete;
|
||||||
public static event Action<bool> OnIAPInitComplete
|
public static event Action<bool> OnIAPInitComplete
|
||||||
{
|
{
|
||||||
add => _onIAPInitComplete += value;
|
add => _onIAPInitComplete += value;
|
||||||
remove => _onIAPInitComplete -= value;
|
remove => _onIAPInitComplete -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnIAPInitComplete(bool success)
|
||||||
internal static Action<string> _onPurchaseStart;
|
{
|
||||||
|
_onIAPInitComplete?.Invoke(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static Action<string> _onPurchaseStart;
|
||||||
public static event Action<string> OnPurchaseStart
|
public static event Action<string> OnPurchaseStart
|
||||||
{
|
{
|
||||||
add => _onPurchaseStart += value;
|
add => _onPurchaseStart += value;
|
||||||
remove => _onPurchaseStart -= value;
|
remove => _onPurchaseStart -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnPurchaseStart(string productId)
|
||||||
internal static Action<string, bool> _onPurchaseEnd;
|
{
|
||||||
|
_onPurchaseStart?.Invoke(productId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static Action<string, bool> _onPurchaseEnd;
|
||||||
public static event Action<string, bool> OnPurchaseEnd
|
public static event Action<string, bool> OnPurchaseEnd
|
||||||
{
|
{
|
||||||
add => _onPurchaseEnd += value;
|
add => _onPurchaseEnd += value;
|
||||||
remove => _onPurchaseEnd -= value;
|
remove => _onPurchaseEnd -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnPurchaseEnd(string productId, bool success)
|
||||||
internal static Action<string, string> _onPurchaseFailed;
|
{
|
||||||
|
_onPurchaseEnd?.Invoke(productId, success);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static Action<string, string> _onPurchaseFailed;
|
||||||
public static event Action<string, string> OnPurchaseFailed
|
public static event Action<string, string> OnPurchaseFailed
|
||||||
{
|
{
|
||||||
add => _onPurchaseFailed += value;
|
add => _onPurchaseFailed += value;
|
||||||
remove => _onPurchaseFailed -= value;
|
remove => _onPurchaseFailed -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnPurchaseFailed(string productId, string error)
|
||||||
internal static Action<bool, string> _onIAPRestored;
|
{
|
||||||
|
_onPurchaseFailed?.Invoke(productId, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static Action<bool, string> _onIAPRestored;
|
||||||
public static event Action<bool, string> OnIAPRestored
|
public static event Action<bool, string> OnIAPRestored
|
||||||
{
|
{
|
||||||
add => _onIAPRestored += value;
|
add => _onIAPRestored += value;
|
||||||
remove => _onIAPRestored -= value;
|
remove => _onIAPRestored -= value;
|
||||||
}
|
}
|
||||||
|
internal static void InvokeOnIAPRestored(bool success, string productId)
|
||||||
|
{
|
||||||
|
_onIAPRestored?.Invoke(success, productId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class SDK
|
public static class SDK
|
||||||
{
|
{
|
||||||
// TODO: 改为 Invoke 方法
|
private static Action<bool> _onFirebaseReady;
|
||||||
internal static Action<bool> _onFirebaseReady;
|
|
||||||
public static event Action<bool> OnFirebaseReady
|
public static event Action<bool> OnFirebaseReady
|
||||||
{
|
{
|
||||||
add => _onFirebaseReady += value;
|
add => _onFirebaseReady += value;
|
||||||
remove => _onFirebaseReady -= value;
|
remove => _onFirebaseReady -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnFirebaseReady(bool success)
|
||||||
internal static Action _onGuruServiceReady;
|
{
|
||||||
|
_onFirebaseReady?.Invoke(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action _onGuruServiceReady;
|
||||||
public static event Action OnGuruServiceReady
|
public static event Action OnGuruServiceReady
|
||||||
{
|
{
|
||||||
add => _onGuruServiceReady += value;
|
add => _onGuruServiceReady += value;
|
||||||
remove => _onGuruServiceReady -= value;
|
remove => _onGuruServiceReady -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnGuruServiceReady()
|
||||||
internal static Action<bool> _onDebuggerDisplayed;
|
{
|
||||||
|
_onGuruServiceReady?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action<bool> _onDebuggerDisplayed;
|
||||||
public static event Action<bool> OnDisplayDebugger
|
public static event Action<bool> OnDisplayDebugger
|
||||||
{
|
{
|
||||||
add => _onDebuggerDisplayed += value;
|
add => _onDebuggerDisplayed += value;
|
||||||
remove => _onDebuggerDisplayed -= value;
|
remove => _onDebuggerDisplayed -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnDebuggerDisplayed(bool success)
|
||||||
internal static Action<bool> _onUserAuthResult;
|
{
|
||||||
|
_onDebuggerDisplayed?.Invoke(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action<bool> _onUserAuthResult;
|
||||||
public static event Action<bool> OnUserAuthResult
|
public static event Action<bool> OnUserAuthResult
|
||||||
{
|
{
|
||||||
add => _onUserAuthResult += value;
|
add => _onUserAuthResult += value;
|
||||||
remove => _onUserAuthResult -= value;
|
remove => _onUserAuthResult -= value;
|
||||||
}
|
}
|
||||||
// TODO: 改为 Invoke 方法
|
internal static void InvokeOnUserAuthResult(bool success)
|
||||||
internal static Action<bool> _onFirebaseAuthResult;
|
{
|
||||||
|
_onUserAuthResult?.Invoke(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Action<bool> _onFirebaseAuthResult;
|
||||||
public static event Action<bool> OnFirebaseAuthResult
|
public static event Action<bool> OnFirebaseAuthResult
|
||||||
{
|
{
|
||||||
add => _onFirebaseAuthResult += value;
|
add => _onFirebaseAuthResult += value;
|
||||||
remove => _onFirebaseAuthResult -= value;
|
remove => _onFirebaseAuthResult -= value;
|
||||||
}
|
}
|
||||||
|
internal static void InvokeOnFirebaseAuthResult(bool success)
|
||||||
|
{
|
||||||
|
_onFirebaseAuthResult?.Invoke(success);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: 改为 Inovk 方法
|
|
||||||
// DeepLink 回调
|
// DeepLink 回调
|
||||||
private static Action<string> _onDeeplinkCallback;
|
private static Action<string> _onDeeplinkCallback;
|
||||||
public static event Action<string> OnDeeplinkCallback
|
public static event Action<string> OnDeeplinkCallback
|
||||||
|
|
|
||||||
|
|
@ -266,6 +266,23 @@ namespace Guru
|
||||||
// SDK
|
// SDK
|
||||||
public const string EventSDKInfo = "sdk_info";
|
public const string EventSDKInfo = "sdk_info";
|
||||||
|
|
||||||
|
//----------------- 关卡开始类型 ---------------------
|
||||||
|
public const string EventLevelStartModePlay = "play";
|
||||||
|
public const string EventLevelStartModeReplay = "replay";
|
||||||
|
public const string EventLevelStartModeContinue= "continue";
|
||||||
|
|
||||||
|
//----------------- 关卡结束类型 ---------------------
|
||||||
|
public const string EventLevelEndSuccess = "success";
|
||||||
|
public const string EventLevelEndFail = "fail";
|
||||||
|
public const string EventLevelEndExit = "exit";
|
||||||
|
public const string EventLevelEndTimeout = "timeout";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 主线关卡类型
|
||||||
|
/// 只有传入此类型时才会进行 Blevel 的累加
|
||||||
|
/// </summary>
|
||||||
|
public const string LevelTypeMain = "main";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ namespace Guru
|
||||||
|
|
||||||
public partial class GuruSDK
|
public partial class GuruSDK
|
||||||
{
|
{
|
||||||
private static bool _isDebuggerInited = false;
|
private static readonly bool _useBaseOptions = true;
|
||||||
private static bool _useBaseOpions = true;
|
|
||||||
|
|
||||||
private static GuruDebugger _debugger;
|
private static GuruDebugger _debugger;
|
||||||
|
|
||||||
|
|
@ -18,7 +17,7 @@ namespace Guru
|
||||||
if (_debugger == null)
|
if (_debugger == null)
|
||||||
{
|
{
|
||||||
_debugger = GuruDebugger.Instance;
|
_debugger = GuruDebugger.Instance;
|
||||||
if (_useBaseOpions)
|
if (_useBaseOptions)
|
||||||
{
|
{
|
||||||
InitDebuggerLayout();
|
InitDebuggerLayout();
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +26,6 @@ namespace Guru
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示广告状态
|
/// 显示广告状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -39,8 +37,6 @@ namespace Guru
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示 Debugger
|
/// 显示 Debugger
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -98,17 +94,15 @@ namespace Guru
|
||||||
|
|
||||||
GuruDebugger.OnClosed -= OnDebuggerClosed;
|
GuruDebugger.OnClosed -= OnDebuggerClosed;
|
||||||
GuruDebugger.OnClosed += OnDebuggerClosed;
|
GuruDebugger.OnClosed += OnDebuggerClosed;
|
||||||
Callbacks.SDK._onDebuggerDisplayed?.Invoke(true);
|
Callbacks.SDK.InvokeOnDebuggerDisplayed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void OnDebuggerClosed()
|
private static void OnDebuggerClosed()
|
||||||
{
|
{
|
||||||
GuruDebugger.OnClosed -= OnDebuggerClosed;
|
GuruDebugger.OnClosed -= OnDebuggerClosed;
|
||||||
Callbacks.SDK._onDebuggerDisplayed?.Invoke(false);
|
Callbacks.SDK.InvokeOnDebuggerDisplayed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示 Debugger
|
/// 显示 Debugger
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
namespace Guru
|
namespace Guru
|
||||||
{
|
{
|
||||||
using UnityEngine;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
|
@ -32,7 +31,7 @@ namespace Guru
|
||||||
GuruIAP.Instance.OnBuyFailed += OnBuyFailed;
|
GuruIAP.Instance.OnBuyFailed += OnBuyFailed;
|
||||||
GuruIAP.Instance.OnGetProductReceipt += OnGetReceipt;
|
GuruIAP.Instance.OnGetProductReceipt += OnGetReceipt;
|
||||||
|
|
||||||
Callbacks.IAP._onIAPInitStart?.Invoke(); // 初始化之前进行调用
|
Callbacks.IAP.InvokeOnIAPInitStart(); // 初始化之前进行调用
|
||||||
|
|
||||||
GuruIAP.Instance.InitWithKeys(uid, googleKey, appleRootCerts, IsDebugMode);
|
GuruIAP.Instance.InitWithKeys(uid, googleKey, appleRootCerts, IsDebugMode);
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +44,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
LogI($"IAP init result: {success}");
|
LogI($"IAP init result: {success}");
|
||||||
IsIAPReady = success;
|
IsIAPReady = success;
|
||||||
Callbacks.IAP._onIAPInitComplete?.Invoke(success);
|
Callbacks.IAP.InvokeOnIAPInitComplete(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool CheckIAPReady()
|
private static bool CheckIAPReady()
|
||||||
|
|
@ -70,7 +69,7 @@ namespace Guru
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static ProductInfo GetProductInfo(string productName)
|
public static ProductInfo GetProductInfo(string productName)
|
||||||
{
|
{
|
||||||
return GuruIAP.Instance?.GetInfo(productName) ?? null;
|
return GuruIAP.Instance?.GetInfo(productName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -80,7 +79,7 @@ namespace Guru
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static ProductInfo GetProductInfoById(string productId)
|
public static ProductInfo GetProductInfoById(string productId)
|
||||||
{
|
{
|
||||||
return GuruIAP.Instance?.GetInfoById(productId) ?? null;
|
return GuruIAP.Instance?.GetInfoById(productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -127,7 +126,7 @@ namespace Guru
|
||||||
|
|
||||||
#region Purchase
|
#region Purchase
|
||||||
|
|
||||||
private static Action<string, bool> _onPurchaseCallback;
|
private static Action<string, bool> InvokeOnPurchaseCallback;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 老接口, 将会被废弃
|
/// 老接口, 将会被废弃
|
||||||
|
|
@ -150,7 +149,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
if (CheckIAPReady())
|
if (CheckIAPReady())
|
||||||
{
|
{
|
||||||
_onPurchaseCallback = purchaseCallback;
|
InvokeOnPurchaseCallback = purchaseCallback;
|
||||||
GuruIAP.Instance.Buy(productName, category);
|
GuruIAP.Instance.Buy(productName, category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -182,8 +181,8 @@ namespace Guru
|
||||||
private static void OnBuyEnd(string productName, bool success)
|
private static void OnBuyEnd(string productName, bool success)
|
||||||
{
|
{
|
||||||
if (success) Model.PurchasedCount++;
|
if (success) Model.PurchasedCount++;
|
||||||
_onPurchaseCallback?.Invoke(productName, success);
|
InvokeOnPurchaseCallback?.Invoke(productName, success);
|
||||||
Callbacks.IAP._onPurchaseEnd?.Invoke(productName, success);
|
Callbacks.IAP.InvokeOnPurchaseEnd(productName, success);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -192,7 +191,7 @@ namespace Guru
|
||||||
/// <param name="productName"></param>
|
/// <param name="productName"></param>
|
||||||
private static void OnBuyStart(string productName)
|
private static void OnBuyStart(string productName)
|
||||||
{
|
{
|
||||||
Callbacks.IAP._onPurchaseStart?.Invoke(productName);
|
Callbacks.IAP.InvokeOnPurchaseStart(productName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -202,7 +201,7 @@ namespace Guru
|
||||||
/// <param name="reason"></param>
|
/// <param name="reason"></param>
|
||||||
private static void OnBuyFailed(string productName, string reason)
|
private static void OnBuyFailed(string productName, string reason)
|
||||||
{
|
{
|
||||||
Callbacks.IAP._onPurchaseFailed?.Invoke(productName, reason);
|
Callbacks.IAP.InvokeOnPurchaseFailed(productName, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -223,7 +222,7 @@ namespace Guru
|
||||||
}
|
}
|
||||||
private static void OnRestored(bool success, string msg)
|
private static void OnRestored(bool success, string msg)
|
||||||
{
|
{
|
||||||
Callbacks.IAP._onIAPRestored?.Invoke(success, msg); // 更新回复购买回调
|
Callbacks.IAP.InvokeOnIAPRestored(success, msg); // 更新回复购买回调
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Guru
|
||||||
public const string Version = "1.1.0";
|
public const string Version = "1.1.0";
|
||||||
|
|
||||||
// Const
|
// Const
|
||||||
public const string Tag = "[Guru]";
|
private const string Tag = "[Guru]";
|
||||||
public const string ServicesConfigKey = "guru_services";
|
public const string ServicesConfigKey = "guru_services";
|
||||||
|
|
||||||
private static GuruSDK _instance;
|
private static GuruSDK _instance;
|
||||||
|
|
@ -36,8 +36,8 @@ namespace Guru
|
||||||
|
|
||||||
private GuruSDKInitConfig _initConfig;
|
private GuruSDKInitConfig _initConfig;
|
||||||
|
|
||||||
internal static GuruSDKInitConfig InitConfig => Instance._initConfig;
|
private static GuruSDKInitConfig InitConfig => Instance._initConfig;
|
||||||
internal static GuruSDKModel Model => GuruSDKModel.Instance;
|
private static GuruSDKModel Model => GuruSDKModel.Instance;
|
||||||
private static GuruServicesConfig _appServicesConfig;
|
private static GuruServicesConfig _appServicesConfig;
|
||||||
private static GuruSettings _guruSettings;
|
private static GuruSettings _guruSettings;
|
||||||
private static GuruSettings GuruSettings
|
private static GuruSettings GuruSettings
|
||||||
|
|
@ -92,6 +92,7 @@ namespace Guru
|
||||||
// GuruSDk.Callbacks -> GuruSDkCallbacks 所有的内置回调改为成员变量,
|
// GuruSDk.Callbacks -> GuruSDkCallbacks 所有的内置回调改为成员变量,
|
||||||
// 去掉所有的内部类, 去掉所有的 Static
|
// 去掉所有的内部类, 去掉所有的 Static
|
||||||
// Static 只用于常量
|
// Static 只用于常量
|
||||||
|
// TODO: 下一个版本改为标准的 Builder 模式
|
||||||
public static GuruSDKInitConfig BuildConfig(
|
public static GuruSDKInitConfig BuildConfig(
|
||||||
bool useCustomConsent = false,
|
bool useCustomConsent = false,
|
||||||
bool autoLoadAds = true,
|
bool autoLoadAds = true,
|
||||||
|
|
@ -99,8 +100,7 @@ namespace Guru
|
||||||
bool autoRecordFinishedLevels = true,
|
bool autoRecordFinishedLevels = true,
|
||||||
bool debugMode = false,
|
bool debugMode = false,
|
||||||
bool isBuyNoAds = false,
|
bool isBuyNoAds = false,
|
||||||
// TODO 直接在此处设置回调
|
Action<string> onAdjustDeeplinkCallback = null,
|
||||||
bool useAdjustDeeplink = false,
|
|
||||||
string bannerColor = "#00000000",
|
string bannerColor = "#00000000",
|
||||||
Dictionary<string, object> defaultRemoteData = null,
|
Dictionary<string, object> defaultRemoteData = null,
|
||||||
byte[] googleKeys = null,
|
byte[] googleKeys = null,
|
||||||
|
|
@ -109,7 +109,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
var config = GuruSDKInitConfig.Build(useCustomConsent, autoLoadAds, iapEnabled,
|
var config = GuruSDKInitConfig.Build(useCustomConsent, autoLoadAds, iapEnabled,
|
||||||
autoRecordFinishedLevels, isBuyNoAds, bannerColor,
|
autoRecordFinishedLevels, isBuyNoAds, bannerColor,
|
||||||
debugMode, useAdjustDeeplink, defaultRemoteData, googleKeys, appleRootCerts, debugEnableEventLog);
|
debugMode, onAdjustDeeplinkCallback, defaultRemoteData, googleKeys, appleRootCerts, debugEnableEventLog);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,20 +123,9 @@ namespace Guru
|
||||||
_initTime = DateTime.Now.ToUniversalTime();
|
_initTime = DateTime.Now.ToUniversalTime();
|
||||||
// ----- First Open Time -----
|
// ----- First Open Time -----
|
||||||
// SetFirstOpenTime(GetFirstOpenTime()); // FirstOpenTime
|
// SetFirstOpenTime(GetFirstOpenTime()); // FirstOpenTime
|
||||||
LogI($"#1 ---- Guru SDK [{Version}] ----\n{config.ToString()}");
|
LogI($"#1 ---- Guru SDK [{Version}] ----\n{config}");
|
||||||
Instance.StartWithConfig(config, onComplete);
|
Instance.StartWithConfig(config, onComplete);
|
||||||
}
|
}
|
||||||
private static string GetFirstOpenTime()
|
|
||||||
{
|
|
||||||
string firstOpenTime = IPMConfig.FirstOpenTime;
|
|
||||||
if (string.IsNullOrEmpty(firstOpenTime))
|
|
||||||
{
|
|
||||||
firstOpenTime = TimeUtil.GetCurrentTimeStamp().ToString();
|
|
||||||
IPMConfig.FirstOpenTime = firstOpenTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
return firstOpenTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启动SDK
|
/// 启动SDK
|
||||||
|
|
@ -157,10 +146,9 @@ namespace Guru
|
||||||
|
|
||||||
InitUpdaters(); // Updaters
|
InitUpdaters(); // Updaters
|
||||||
InitThreadHandler(); // 初始化线程处理器
|
InitThreadHandler(); // 初始化线程处理器
|
||||||
InitServices();
|
InitServices(); // 初始化所有的服务
|
||||||
|
|
||||||
InitNetworkMonitor(); // 网络状态
|
InitNetworkMonitor(); // 网络状态
|
||||||
|
InitiallyUpdateUserProperties(); // 上报所有初始化用户属性
|
||||||
|
|
||||||
onComplete?.Invoke(true);
|
onComplete?.Invoke(true);
|
||||||
}
|
}
|
||||||
|
|
@ -191,10 +179,10 @@ namespace Guru
|
||||||
FirebaseUtil.OnUserAuthResult += OnUserAuthResult;
|
FirebaseUtil.OnUserAuthResult += OnUserAuthResult;
|
||||||
FirebaseUtil.OnFirebaseAuthResult += OnFirebaseAuthResult;
|
FirebaseUtil.OnFirebaseAuthResult += OnFirebaseAuthResult;
|
||||||
|
|
||||||
// TODO: 应该直接判断 Callback 是否存在
|
if (InitConfig.OnAdjustDeeplinkCallback != null)
|
||||||
if (InitConfig.UseAdjustDeeplink)
|
|
||||||
{
|
{
|
||||||
FirebaseUtil.OnAdjustDeeplinkCallback = OnDeeplinkCallback; // 挂载 Deeplink 的回调
|
//TODO: 下个版本 AdjustService 和 Firebase 解耦
|
||||||
|
FirebaseUtil.OnAdjustDeeplinkCallback = InitConfig.OnAdjustDeeplinkCallback; // 挂载 Deeplink 的回调
|
||||||
}
|
}
|
||||||
|
|
||||||
FirebaseUtil.InitFirebase(Analytics.OnFirebaseInitCompleted); // 确保所有的逻辑提前被调用到
|
FirebaseUtil.InitFirebase(Analytics.OnFirebaseInitCompleted); // 确保所有的逻辑提前被调用到
|
||||||
|
|
@ -207,7 +195,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
Callbacks.SDK._onUserAuthResult?.Invoke(success);
|
Callbacks.SDK.InvokeOnUserAuthResult(success);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
|
@ -218,13 +206,13 @@ namespace Guru
|
||||||
GuruIAP.Instance.SetUUID(UUID);
|
GuruIAP.Instance.SetUUID(UUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateAllUserProperties(); // 同步所有用户属性打点
|
SetUID(UID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFirebaseAuthResult(bool success)
|
private void OnFirebaseAuthResult(bool success)
|
||||||
{
|
{
|
||||||
Callbacks.SDK._onFirebaseAuthResult?.Invoke(success);
|
Callbacks.SDK.InvokeOnFirebaseAuthResult(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -235,7 +223,7 @@ namespace Guru
|
||||||
FirebaseUtil.onInitComplete -= OnFirebaseReady;
|
FirebaseUtil.onInitComplete -= OnFirebaseReady;
|
||||||
LogI($"#3 --- On FirebaseDeps: {success} ---");
|
LogI($"#3 --- On FirebaseDeps: {success} ---");
|
||||||
IsFirebaseReady = success;
|
IsFirebaseReady = success;
|
||||||
Callbacks.SDK._onFirebaseReady?.Invoke(success);
|
Callbacks.SDK.InvokeOnFirebaseReady(success);
|
||||||
// LogFirebaseDeps(success);
|
// LogFirebaseDeps(success);
|
||||||
|
|
||||||
LogI($"#3.5 --- Call InitRemoteConfig ---");
|
LogI($"#3.5 --- Call InitRemoteConfig ---");
|
||||||
|
|
@ -245,14 +233,7 @@ namespace Guru
|
||||||
|
|
||||||
LogI($"#4 --- Apply remote services config ---");
|
LogI($"#4 --- Apply remote services config ---");
|
||||||
// 根据缓存的云控配置来初始化参数
|
// 根据缓存的云控配置来初始化参数
|
||||||
InitAllServices();
|
InitAllGuruServices();
|
||||||
|
|
||||||
LogI($"#5 --- sync sdk time ---");
|
|
||||||
var sp = DateTime.Now.ToUniversalTime() - _initTime;
|
|
||||||
LogSDKInitTime(sp.TotalSeconds);
|
|
||||||
|
|
||||||
// 上报所有初始化用户属性
|
|
||||||
UpdateAllUserProperties();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -280,7 +261,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
LogI($"#6 --- Remote fetch complete: {success} ---");
|
LogI($"#6 --- Remote fetch complete: {success} ---");
|
||||||
ABTestManager.Init(); // 启动AB测试解析器
|
ABTestManager.Init(); // 启动AB测试解析器
|
||||||
Callbacks.Remote._onRemoteFetchComplete?.Invoke(success);
|
Callbacks.Remote.InvokeOnRemoteFetchComplete(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -298,18 +279,18 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply Cloud guru-service configs for sdk assets
|
/// Apply Cloud guru-service configs for sdk assets
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitAllServices()
|
private void InitAllGuruServices()
|
||||||
{
|
{
|
||||||
// -------- Init Analytics ---------
|
// -------- Init Analytics ---------
|
||||||
InitUserProperties();
|
InitUserProperties();
|
||||||
SetSDKEventPriority();
|
SetSDKEventPriority();
|
||||||
// -------- Init Noti -----------
|
// -------- Init Notification -----------
|
||||||
InitNotiPermission();
|
InitNotiPermission();
|
||||||
|
|
||||||
bool useKeywords = false;
|
bool useKeywords = false;
|
||||||
bool useIAP = _initConfig.IAPEnabled;
|
bool useIAP = _initConfig.IAPEnabled;
|
||||||
bool appleReview = false;
|
bool appleReview = false;
|
||||||
bool enableAnaErrorLog = false;
|
// bool enableAnaErrorLog = false;
|
||||||
|
|
||||||
//----------- Set GuruServices ----------------
|
//----------- Set GuruServices ----------------
|
||||||
var services = GetRemoteServicesConfig();
|
var services = GetRemoteServicesConfig();
|
||||||
|
|
@ -319,7 +300,7 @@ namespace Guru
|
||||||
useKeywords = _appServicesConfig.KeywordsEnabled();
|
useKeywords = _appServicesConfig.KeywordsEnabled();
|
||||||
// 使用初始化配置中的 IAPEnable来联合限定, 如果本地写死关闭则不走云控开启
|
// 使用初始化配置中的 IAPEnable来联合限定, 如果本地写死关闭则不走云控开启
|
||||||
useIAP = _initConfig.IAPEnabled && _appServicesConfig.IsIAPEnabled();
|
useIAP = _initConfig.IAPEnabled && _appServicesConfig.IsIAPEnabled();
|
||||||
enableAnaErrorLog = _appServicesConfig.EnableAnaErrorLog();
|
// enableAnaErrorLog = _appServicesConfig.EnableAnaErrorLog();
|
||||||
|
|
||||||
Try(() =>
|
Try(() =>
|
||||||
{
|
{
|
||||||
|
|
@ -340,7 +321,7 @@ namespace Guru
|
||||||
GuruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events);
|
GuruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogI($"#4.2 --- Start GuruSttings ---");
|
LogI($"#4.2 --- Start GuruSettings ---");
|
||||||
// GuruSettings 设置
|
// GuruSettings 设置
|
||||||
if (null != _appServicesConfig.app_settings)
|
if (null != _appServicesConfig.app_settings)
|
||||||
{
|
{
|
||||||
|
|
@ -381,7 +362,7 @@ namespace Guru
|
||||||
//---------------------------------
|
//---------------------------------
|
||||||
}, ex =>
|
}, ex =>
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"--- ERROR on apply services: {ex.Message}");
|
Debug.LogError($"--- ERROR on apply services: {ex.Message}");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -402,7 +383,7 @@ namespace Guru
|
||||||
InitIAP(UID, _initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP
|
InitIAP(UID, _initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP
|
||||||
}, ex =>
|
}, ex =>
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"--- ERROR on useIAP: {ex.Message}");
|
Debug.LogError($"--- ERROR on useIAP: {ex.Message}");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//----------- Set Keywords ----------------
|
//----------- Set Keywords ----------------
|
||||||
|
|
@ -415,7 +396,7 @@ namespace Guru
|
||||||
KeywordsManager.Install(Model.IsIapUser, Model.SuccessLevelId); // 启动Keyword管理器
|
KeywordsManager.Install(Model.IsIapUser, Model.SuccessLevelId); // 启动Keyword管理器
|
||||||
}, ex =>
|
}, ex =>
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"--- ERROR on Keywords: {ex.Message}");
|
Debug.LogError($"--- ERROR on Keywords: {ex.Message}");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -439,24 +420,25 @@ namespace Guru
|
||||||
{
|
{
|
||||||
// LogI($"--- #3 Start Consent Flow ---");
|
// LogI($"--- #3 Start Consent Flow ---");
|
||||||
// StartConsentFlow();
|
// StartConsentFlow();
|
||||||
Try(() =>
|
Try(StartConsentFlow, ex =>
|
||||||
{
|
{
|
||||||
StartConsentFlow();
|
Debug.LogError($"--- ERROR on StartConsentFlow: {ex.Message}");
|
||||||
}, ex =>
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogError($"--- ERROR on StartConsentFlow: {ex.Message}");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
IsServiceReady = true;
|
IsServiceReady = true;
|
||||||
|
|
||||||
// 中台服务初始化结束
|
// 中台服务初始化结束
|
||||||
Callbacks.SDK._onGuruServiceReady?.Invoke();
|
Callbacks.SDK.InvokeOnGuruServiceReady();
|
||||||
|
|
||||||
#if UNITY_ANDROID
|
#if UNITY_ANDROID
|
||||||
// Android 命令行调试
|
// Android 命令行调试
|
||||||
StartAndroidDebugCmds();
|
StartAndroidDebugCmds();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
LogI($"#5 --- sync sdk time ---");
|
||||||
|
// TODO: 本调用放在这里不合适, 应该和 Firebase 解耦
|
||||||
|
LogSDKInitTime((DateTime.Now.ToUniversalTime() - _initTime).TotalSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -482,7 +464,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
// No remote data fetched from cloud, should use default values
|
// No remote data fetched from cloud, should use default values
|
||||||
json = defaultJson;
|
json = defaultJson;
|
||||||
UnityEngine.Debug.Log($"{Tag} --- No remote data found with: {key} -> Using default key {ServicesConfigKey} and local data!!!");
|
Debug.Log($"{Tag} --- No remote data found with: {key} -> Using default key {ServicesConfigKey} and local data!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(json))
|
if (!string.IsNullOrEmpty(json))
|
||||||
|
|
@ -529,14 +511,14 @@ namespace Guru
|
||||||
|
|
||||||
#region 数据
|
#region 数据
|
||||||
|
|
||||||
private void OnBLevelChanged(int blevel)
|
private void OnBLevelChanged(int bLevel)
|
||||||
{
|
{
|
||||||
SetUserBLevel(blevel);
|
SetUserBLevel(bLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBPlayChanged(int bplay)
|
private void OnBPlayChanged(int bPlay)
|
||||||
{
|
{
|
||||||
SetUserBPlay(bplay);
|
SetUserBPlay(bPlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -545,17 +527,17 @@ namespace Guru
|
||||||
|
|
||||||
internal static void LogI(object message)
|
internal static void LogI(object message)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log($"{Tag} {message}");
|
Debug.Log($"{Tag} {message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void LogW(object message)
|
internal static void LogW(object message)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogWarning($"{Tag} {message}");
|
Debug.LogWarning($"{Tag} {message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void LogE(object message)
|
internal static void LogE(object message)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"{Tag} {message}");
|
Debug.LogError($"{Tag} {message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -566,7 +548,7 @@ namespace Guru
|
||||||
|
|
||||||
internal static void LogException(Exception e)
|
internal static void LogException(Exception e)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogException(e);
|
Debug.LogException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -607,7 +589,7 @@ namespace Guru
|
||||||
private void OnAppPauseHandler(bool paused)
|
private void OnAppPauseHandler(bool paused)
|
||||||
{
|
{
|
||||||
if(paused) Model.Save(true); // 强制保存数据
|
if(paused) Model.Save(true); // 强制保存数据
|
||||||
Callbacks.App._onAppPaused?.Invoke(paused);
|
Callbacks.App.InvokeOnAppPaused(paused);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnApplicationPause(bool paused)
|
private void OnApplicationPause(bool paused)
|
||||||
|
|
@ -623,7 +605,7 @@ namespace Guru
|
||||||
private void OnApplicationQuit()
|
private void OnApplicationQuit()
|
||||||
{
|
{
|
||||||
Model.Save(true);
|
Model.Save(true);
|
||||||
Callbacks.App._onAppQuit?.Invoke();
|
Callbacks.App.InvokeOnAppQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -686,14 +668,13 @@ namespace Guru
|
||||||
private void UpdateAllUpdates()
|
private void UpdateAllUpdates()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
IUpdater updater;
|
|
||||||
// ---- Updater Trigger ----
|
// ---- Updater Trigger ----
|
||||||
if (_updaterRunningList.Count > 0)
|
if (_updaterRunningList.Count > 0)
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < _updaterRunningList.Count)
|
while (i < _updaterRunningList.Count)
|
||||||
{
|
{
|
||||||
updater = _updaterRunningList[i];
|
var updater = _updaterRunningList[i];
|
||||||
if (updater != null)
|
if (updater != null)
|
||||||
{
|
{
|
||||||
if (updater.State == UpdaterState.Running)
|
if (updater.State == UpdaterState.Running)
|
||||||
|
|
@ -759,7 +740,7 @@ namespace Guru
|
||||||
private static int _messageRetry = 0;
|
private static int _messageRetry = 0;
|
||||||
public static void SetPushNotificationEnabled(bool enabled)
|
public static void SetPushNotificationEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
DeviceInfoUploadRequest request = new DeviceInfoUploadRequest()
|
DeviceInfoUploadRequest request = (DeviceInfoUploadRequest) new DeviceInfoUploadRequest()
|
||||||
.SetRetryTimes(1)
|
.SetRetryTimes(1)
|
||||||
.SetSuccessCallBack(() =>
|
.SetSuccessCallBack(() =>
|
||||||
{
|
{
|
||||||
|
|
@ -771,14 +752,13 @@ namespace Guru
|
||||||
double retryDelay = Math.Pow(2, _messageRetry);
|
double retryDelay = Math.Pow(2, _messageRetry);
|
||||||
_messageRetry++;
|
_messageRetry++;
|
||||||
CoroutineHelper.Instance.StartDelayed((float)retryDelay, ()=> SetPushNotificationEnabled(enabled));
|
CoroutineHelper.Instance.StartDelayed((float)retryDelay, ()=> SetPushNotificationEnabled(enabled));
|
||||||
}) as DeviceInfoUploadRequest;
|
});
|
||||||
|
|
||||||
|
if (request == null) return;
|
||||||
|
|
||||||
if (request != null)
|
|
||||||
{
|
|
||||||
request.SetPushEnabled(enabled);
|
request.SetPushEnabled(enabled);
|
||||||
request.Send();
|
request.Send();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Deeplink
|
#region Deeplink
|
||||||
|
|
@ -804,36 +784,17 @@ namespace Guru
|
||||||
|
|
||||||
private void InitNetworkMonitor()
|
private void InitNetworkMonitor()
|
||||||
{
|
{
|
||||||
_networkStatusMonitor = new NetworkStatusMonitor();
|
// SetUserProperty(Consts.PropertyNetwork, GetNetworkStatus());
|
||||||
_networkStatusMonitor.Init(OnNetworkMonitorInitComplete);
|
// TODO: 下个版本加入真正的自动更新网络状态的实现
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnNetworkMonitorInitComplete(bool success)
|
|
||||||
{
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
// 上报用户network属性
|
|
||||||
_networkStatus = _networkStatusMonitor.GetNetworkStatus();
|
|
||||||
SetUserProperty(Consts.PropertyNetwork, _networkStatus);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError($"[SDK] --- NetworkStatusMonitor init failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private string GetNetworkStatus()
|
private string GetNetworkStatus()
|
||||||
{
|
{
|
||||||
if(_networkStatusMonitor != null)
|
if(_networkStatusMonitor == null)
|
||||||
{
|
{
|
||||||
_networkStatus = _networkStatusMonitor.GetNetworkStatus();
|
_networkStatusMonitor = new NetworkStatusMonitor();
|
||||||
}
|
}
|
||||||
else
|
return _networkStatusMonitor.GetNetworkStatus();
|
||||||
{
|
|
||||||
_networkStatus = "none";
|
|
||||||
}
|
|
||||||
return _networkStatus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue