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