Compare commits

..

18 Commits

Author SHA1 Message Date
胡宇飞 25f4d7e588 Merge branch 'hotfix/v1.0.13' into release/v1.0.14 2024-07-17 09:34:34 +08:00
胡宇飞 1841edcbf3 update: 新增赋值接口 2024-07-17 09:34:23 +08:00
胡宇飞 6e5ede3958 fix: 修复 GuruSDK.UID 初始化时为空值的 BUG 2024-07-08 19:10:33 +08:00
胡宇飞 2724683377 fix: 修复 ServiceBuilder 上的输出数据带有换行的 BUG 2024-07-04 17:23:07 +08:00
胡宇飞 d89de67e44 update: 添加IV广告和 RV 广告的关闭回调事件 2024-07-02 12:36:15 +08:00
胡宇飞 3be05511e4 update: 修复编译 bug 2024-07-01 18:45:07 +08:00
胡宇飞 6fc0c24823 update: 完善 JsonBuilder 2024-07-01 18:41:22 +08:00
胡宇飞 52b6af9fd0 update: 更新 JsonBuilder 的数据源 2024-07-01 16:06:48 +08:00
胡宇飞 d574ec5757 update: add json builder 2024-06-27 21:13:21 +08:00
胡宇飞 855cc61936 fix: 去掉不需要的报错 2024-06-27 18:37:17 +08:00
胡宇飞 bcaed876f7 update: 更新经济打点接口参数 2024-06-27 17:41:05 +08:00
胡宇飞 42966759b3 update: 更新场景使用接口和名称 2024-06-27 11:28:34 +08:00
胡宇飞 4a39747d3d update:更新 SDK version -> 1.0.14 2024-06-26 14:31:31 +08:00
胡宇飞 d51759bbd1 update: 取消初始化锁限制 2024-06-24 14:35:30 +08:00
胡宇飞 68e90a4ed9 【中台】【SDK】完善经济打点接口
--story=1020672 --user=yufei.hu 【中台】【SDK】完善经济打点接口 https://www.tapd.cn/33527076/s/1152293
2024-06-24 10:17:26 +08:00
胡宇飞 3d8bc1c642 update: 更新推送状态接口和对应的log
--story=1020629 --user=yufei.hu 【中台】【SDK】加入消息弹框管理,中台 noti_perm 打点逻辑优化 https://www.tapd.cn/33527076/s/1152197
2024-06-21 16:52:11 +08:00
胡宇飞 338c886ef6 update: version 2024-06-21 14:39:55 +08:00
胡宇飞 fa3ec5adef update: 新增 Notification 接口 2024-06-20 18:30:37 +08:00
9 changed files with 278 additions and 97 deletions

View File

@ -20,6 +20,10 @@ namespace Guru
/// </summary> /// </summary>
public bool IAPEnabled = true; public bool IAPEnabled = true;
/// <summary> /// <summary>
/// 自动申请推送授权信息
/// </summary>
public bool AutoNotificationPermission = true;
/// <summary>
/// 自动记录完成的关卡 /// 自动记录完成的关卡
/// </summary> /// </summary>
public bool AutoRecordFinishedLevels = true; public bool AutoRecordFinishedLevels = true;
@ -97,12 +101,18 @@ namespace Guru
public override string ToString() public override string ToString()
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.AppendLine($"------- Custom init Config -------"); sb.AppendLine($"------- Custom InitConfig -------");
sb.AppendLine($"\tUseCustomConsent: {UseCustomConsent}"); sb.AppendLine($"\t UseCustomConsent: {UseCustomConsent}");
sb.AppendLine($"\tAutoLoadWhenAdsReady: {AutoLoadWhenAdsReady}"); sb.AppendLine($"\t AutoLoadWhenAdsReady: {AutoLoadWhenAdsReady}");
sb.AppendLine($"\tIAPEnabled: {IAPEnabled}"); sb.AppendLine($"\t IAPEnabled: {IAPEnabled}");
sb.AppendLine($"\tShowDebugLog: {DebugMode}"); sb.AppendLine($"\t AutoNotificationPermission: {AutoNotificationPermission}");
sb.AppendLine($"------- Custom init Config -------"); sb.AppendLine($"\t AutoRecordFinishedLevels: {AutoRecordFinishedLevels}");
sb.AppendLine($"\t CustomServiceKey: {CustomServiceKey}");
sb.AppendLine($"\t BannerBackgroundColor: {BannerBackgroundColor}");
sb.AppendLine($"\t IsBuyNoAds: {IsBuyNoAds}");
sb.AppendLine($"\t DebugMode: {DebugMode}");
sb.AppendLine($"\t DefaultRemote: Count: {DefaultRemoteData.Count}");
sb.AppendLine($"------- Custom InitConfig -------");
return sb.ToString(); return sb.ToString();
} }

View File

@ -1,14 +1,13 @@
namespace Guru namespace Guru
{ {
using UnityEngine; using UnityEngine;
using System; using System;
using Guru.Notification;
public partial class GuruSDK public partial class GuruSDK
{ {
private const float CONSENT_FLOW_TIMEOUT = 10; // Consent Flow 超时时间(秒)
private static AdsInitSpec _adInitSpec; private static AdsInitSpec _adInitSpec;
/// <summary> /// <summary>
@ -53,7 +52,7 @@ namespace Guru
if (userAllow) if (userAllow)
{ {
#if UNITY_IOS #if UNITY_IOS
CheckAttStatus(); Instance.CheckAttStatus();
#else #else
StartAdService(spec); StartAdService(spec);
#endif #endif
@ -81,6 +80,8 @@ namespace Guru
private bool _hasConsentCalled = false; private bool _hasConsentCalled = false;
private bool _adServiceHasStarted = false; private bool _adServiceHasStarted = false;
private string _notiStatue = "";
private bool _hasNotiGranted = false;
/// <summary> /// <summary>
/// 启动Consent流程 /// 启动Consent流程
@ -88,10 +89,12 @@ namespace Guru
/// </summary> /// </summary>
private void StartConsentFlow() private void StartConsentFlow()
{ {
LogI($"#4.5 --- StartConsentFlow ---");
float time = 1; float time = 1;
if (!_adServiceHasStarted && _appServicesConfig != null) if (!_adServiceHasStarted && _appServicesConfig != null)
{ {
time = _appServicesConfig.IsAdsCompliance() ? 10 : 1f; // 启动合规判定后, 延迟最多 10 秒后启动广告 time = _appServicesConfig.IsAdsCompliance() ? CONSENT_FLOW_TIMEOUT : 1f; // 启动合规判定后, 延迟最多 10 秒后启动广告
} }
Delay(time, AdServiceHandler); // 广告延迟启动 Delay(time, AdServiceHandler); // 广告延迟启动
@ -130,7 +133,7 @@ namespace Guru
#if UNITY_IOS #if UNITY_IOS
CheckAttStatus(); // [iOS] Consent 启动后检查 ATT 初始值 CheckAttStatus(); // [iOS] Consent 启动后检查 ATT 初始值
#elif UNITY_ANDROID #elif UNITY_ANDROID
CheckPermission(); // [Android] Consent 回调后检查 Push 推送权限 CheckNotiPermission(); // Consent 回调后检查 Notification 权限
#endif #endif
// 内部处理后继逻辑 // 内部处理后继逻辑
@ -154,6 +157,8 @@ namespace Guru
StartAdService(_adInitSpec); StartAdService(_adInitSpec);
} }
#endregion #endregion
#region IOS ATT 广告授权流程 #region IOS ATT 广告授权流程
@ -167,7 +172,7 @@ namespace Guru
/// <summary> /// <summary>
/// 显示系统的 ATT 弹窗 /// 显示系统的 ATT 弹窗
/// </summary> /// </summary>
public static void RequestAttDialog() public void RequestAttDialog()
{ {
LogI($"RequestATTDialog"); LogI($"RequestATTDialog");
ATTManager.RequestATTDailog(ReportAttStatus); ATTManager.RequestATTDailog(ReportAttStatus);
@ -186,7 +191,7 @@ namespace Guru
/// <summary> /// <summary>
/// iOS 平台检查 ATT 状态 /// iOS 平台检查 ATT 状态
/// </summary> /// </summary>
private static void CheckAttStatus(bool autoReCall = false) private void CheckAttStatus(bool autoReCall = false)
{ {
_autoReCallAtt = autoReCall; _autoReCallAtt = autoReCall;
@ -194,7 +199,7 @@ namespace Guru
Delay(1, () => ATTManager.CheckStatus(ReportAttStatus)); Delay(1, () => ATTManager.CheckStatus(ReportAttStatus));
} }
private static void ReportAttStatus(string status) private void ReportAttStatus(string status)
{ {
LogI($"{Tag} --- Get Att status:{status} att Type:{_attType} recall:{_autoReCallAtt}"); LogI($"{Tag} --- Get Att status:{status} att Type:{_attType} recall:{_autoReCallAtt}");
SetUserProperty(Analytics.ParameterATTStatus, status); // 当前的状态 SetUserProperty(Analytics.ParameterATTStatus, status); // 当前的状态
@ -221,45 +226,85 @@ namespace Guru
// ATT 状态已授权 // ATT 状态已授权
break; break;
} }
CheckNotiPermission(); // Consent 回调后检查 Notification 权限
} }
#endif #endif
#endregion #endregion
#region Android 13 PushNotification Permission #region Notification Permission Check
private const string PERMISSION_POST_NOTIFICATION = "android.permission.POST_NOTIFICATIONS"; /// <summary>
/// 初始化 Noti Service
private void CheckPermission() /// </summary>
private void InitNotiPermission()
{ {
float delay = 1; bool hasNotiGranted = false;
UnityEngine.Debug.Log($"---- Check PushPermission ---"); _notiStatue = "no_determined";
#if UNITY_ANDROID NotificationService.Initialize(); // 初始化 Noti 服务
// 如果已经请求过权限的话, 则不做动作 SetNotiPerm(NotificationService.GetStatus());
if (UnityEngine.Android.Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION))
{
UnityEngine.Debug.Log($"--- PushPermission has passed ---");
return;
}
#endif
Invoke(nameof(RequestNotification), delay);
} }
/// <summary> /// <summary>
/// 请求Notification /// 检查 Noti 状态
/// </summary> /// </summary>
private void RequestNotification() private void CheckNotiPermission()
{ {
#if UNITY_ANDROID var status = NotificationService.GetStatus();
UnityEngine.Debug.Log("--- Target 33 Request Notification ---");
// Android直接申请授权 // 如果未启用自动 Noti 授权,则直接上报状态
if (!UnityEngine.Android.Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION)) if (!_initConfig.AutoNotificationPermission)
{ {
UnityEngine.Android.Permission.RequestUserPermission(PERMISSION_POST_NOTIFICATION); UnityEngine.Debug.LogWarning($"[SDK] ---- AutoNotificationPermission is OFF, Project should request permission own.");
} return;
#endif
} }
bool isGranted = NotificationService.IsPermissionGranted();
UnityEngine.Debug.Log($"[SDK] ---- Check Noti Permission: {isGranted}");
if (isGranted)
{
UnityEngine.Debug.Log($"[SDK] ---- Set Notification Permission: {status}");
SetNotiPerm(status);
return;
}
RequestNotificationPermission(); // 请求授权
}
/// <summary>
/// 请求推送授权
/// </summary>
/// <param name="callback"></param>
public static void RequestNotificationPermission(Action<string> callback = null)
{
UnityEngine.Debug.Log($"[SDK] ---- RequestNotificationPermission");
NotificationService.RequestPermission(status =>
{
UnityEngine.Debug.Log($"[SDK] ---- Set Notification Permission: {status}");
if(!string.IsNullOrEmpty(status)) SetNotiPerm(status);
callback?.Invoke(status);
});
}
/// <summary>
/// 获取 Notification 状态值
/// </summary>
/// <returns></returns>
public static string GetNotificationStatus()
{
return NotificationService.GetStatus();
}
/// <summary>
/// 用户是否已经获取了 Notification 授权了
/// </summary>
/// <returns></returns>
public static bool IsNotificationPermissionGranted()
{
return NotificationService.IsPermissionGranted();
}
#endregion #endregion
@ -306,10 +351,12 @@ namespace Guru
ADService.OnInterstitialStartLoad = OnInterstitialStartLoad; ADService.OnInterstitialStartLoad = OnInterstitialStartLoad;
ADService.OnInterstitialLoaded = OnInterstitialLoaded; ADService.OnInterstitialLoaded = OnInterstitialLoaded;
ADService.OnInterstitialFailed = OnInterstitialFailed; ADService.OnInterstitialFailed = OnInterstitialFailed;
ADService.OnInterstitialClosed = OnInterstitialClosed;
// RADS // RADS
ADService.OnRewardedStartLoad = OnRewardedStartLoad; ADService.OnRewardedStartLoad = OnRewardStartLoad;
ADService.OnRewardLoaded = OnRewardedLoaded; ADService.OnRewardLoaded = OnRewardLoaded;
ADService.OnRewardFailed = OnRewardedFailed; ADService.OnRewardFailed = OnRewardFailed;
ADService.OnRewardClosed = OnRewardClosed;
// ---------- Start Services ---------- // ---------- Start Services ----------
ADService.Instance.StartService(OnAdsInitComplete, spec); ADService.Instance.StartService(OnAdsInitComplete, spec);
@ -338,12 +385,16 @@ namespace Guru
=> Callbacks.Ads._onInterstitialADLoaded?.Invoke(); => Callbacks.Ads._onInterstitialADLoaded?.Invoke();
private static void OnInterstitialFailed() private static void OnInterstitialFailed()
=> Callbacks.Ads._onInterstitialADFailed?.Invoke(); => Callbacks.Ads._onInterstitialADFailed?.Invoke();
private static void OnRewardedStartLoad(string adUnitId) private static void OnInterstitialClosed()
=> Callbacks.Ads._onInterstitialADClosed?.Invoke();
private static void OnRewardStartLoad(string adUnitId)
=> Callbacks.Ads._onRewardedADStartLoad?.Invoke(adUnitId); => Callbacks.Ads._onRewardedADStartLoad?.Invoke(adUnitId);
private static void OnRewardedLoaded() private static void OnRewardLoaded()
=> Callbacks.Ads._onRewardedADLoaded?.Invoke(); => Callbacks.Ads._onRewardedADLoaded?.Invoke();
private static void OnRewardedFailed() private static void OnRewardFailed()
=> Callbacks.Ads._onRewardADFailed?.Invoke(); => Callbacks.Ads._onRewardADFailed?.Invoke();
private static void OnRewardClosed()
=> Callbacks.Ads._onRewardADClosed?.Invoke();
private static void OnAdsInitComplete() private static void OnAdsInitComplete()
{ {
@ -494,6 +545,7 @@ namespace Guru
} }
#endregion #endregion
} }

View File

@ -39,11 +39,11 @@ namespace Guru
/// <param name="priority"></param> /// <param name="priority"></param>
public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null, int priority = -1) public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null, int priority = -1)
{ {
if (!IsInitialSuccess) // if (!IsInitialSuccess)
{ // {
UnityEngine.Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>."); // UnityEngine.Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
return; // return;
} // }
if(priority < 0) priority = GetEventPriorityInt(eventName); if(priority < 0) priority = GetEventPriorityInt(eventName);
@ -453,6 +453,10 @@ namespace Guru
SetUserProperty(Consts.PropertyATTStatus, status); SetUserProperty(Consts.PropertyATTStatus, status);
} }
public static void SetAdjustId(string adjustId)
{
SetUserProperty(Consts.PropertyAdjustId, adjustId);
}
/// <summary> /// <summary>
/// 初始化时调用一下所有的属性打点 </br> /// 初始化时调用一下所有的属性打点 </br>
@ -613,6 +617,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 LogEarnVirtualCurrency(string currencyName, public static void LogEarnVirtualCurrency(string currencyName,
int value, int balance, int value, int balance,
string category = "", string itemName = "", string category = "", string itemName = "",
@ -621,19 +626,55 @@ namespace Guru
Analytics.EarnVirtualCurrency(currencyName, value, balance, category, itemName,levelName, scene, extra); Analytics.EarnVirtualCurrency(currencyName, value, balance, category, itemName,levelName, scene, extra);
} }
/// <summary>
/// 游戏初次启动/用户获得初始道具
/// </summary>
/// <param name="currencyName">货币名称</param>
/// <param name="value">货币增加值 10</param>
/// <param name="balance">结算后货币总量 20 -> 30</param>
/// <param name="levelName">购入道具 ID / 道具名称</param>
/// <param name="scene">购买场景如 Store, Workbench, Sign, Ads....</param>
/// <param name="extra">自定义数据</param>
public static void LogEarnVirtualCurrencyByFirstOpen(string currencyName,
int value, int balance,
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
{
string item_category = Consts.CurrencyCategoryReward;
string item_name = "first_open";
Analytics.EarnVirtualCurrency(currencyName, value, balance, item_category, item_name,levelName, scene, extra);
}
/// <summary>
/// 出售道具后获取货币
/// </summary>
/// <param name="currencyName">货币名称</param>
/// <param name="value">货币增加值 10</param>
/// <param name="balance">结算后货币总量 20 -> 30</param>
/// <param name="itemName">购买道具名称</param>
/// <param name="levelName">当前关卡或者人物等级名称</param>
/// <param name="scene">购买场景如 Store, Workbench, Sign, Ads....</param>
/// <param name="extra">自定义数据</param>
public static void LogEarnVirtualCurrencyBySellItem(string currencyName,
int value, int balance, string itemName,
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
{
string item_category = Consts.CurrencyCategoryIGC;
Analytics.EarnVirtualCurrency(currencyName, value, balance, item_category, itemName,levelName, scene, extra);
}
/// <summary> /// <summary>
/// 赚取组合: 货币+道具 (earn_virtual_currency) (props) /// 赚取组合: 货币+道具 (earn_virtual_currency) (props)
/// </summary> /// </summary>
/// <param name="currencyName"></param> /// <param name="currencyName">货币名称</param>
/// <param name="value"></param> /// <param name="value">货币增加值 10</param>
/// <param name="balance"></param> /// <param name="balance">结算后货币总量 20 -> 30</param>
/// <param name="category"></param> /// <param name="category">消耗类型, 默认值请赋 reward</param>
/// <param name="itemName"></param> /// <param name="itemName">购买道具名称</param>
/// <param name="props"></param> /// <param name="props">获取的道具组合</param>
/// <param name="levelName"></param> /// <param name="levelName">当前关卡或者人物等级名称</param>
/// <param name="scene"></param> /// <param name="scene">购买场景如 Store, Workbench, Sign, Ads....</param>
/// <param name="extra">自定义数据</param>
private static void LogEarnVirtualCurrencyAndProps(string currencyName, private static void LogEarnVirtualCurrencyAndProps(string currencyName,
int value = 0, int balance = 0, int value = 0, int balance = 0,
string category = "", string itemName = "", string category = "", string itemName = "",
@ -767,22 +808,23 @@ namespace Guru
/// <summary> /// <summary>
/// 通过使用 Currency 购买获得 Prop (earn_virtual_currency) (reward:level) /// 购买获得 Prop (earn_virtual_currency) (reward:level)
/// 记录 Prop 增加的打点, 消费游戏内货币 /// 记录 Prop 增加的打点, 消费游戏内货币
/// </summary> /// </summary>
/// <param name="currencyName">货币名称</param> /// <param name="currencyName">购买的道具名称</param>
/// <param name="props">获取的道具名称列表</param> /// <param name="spendCurrencyName">消费货币名称</param>
/// <param name="scene">应用场景</param> /// <param name="scene">应用场景</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>
public static void LogEarnPropsByVirtualCurrency(string currencyName, string[] props, /// <param name="extra"></param>
string scene = Consts.ParameterDefaultScene, public static void LogEarnVirtualCurrencyByIGC(string currencyName, string spendCurrencyName, int value = 0, int balance = 0,
int value = 1, int balance = 0, string levelName = "", Dictionary<string, object> extra = null) string levelName = "", string scene = "", Dictionary<string, object> extra = null)
{ {
string category = Consts.CurrencyCategoryIGC; string category = Consts.CurrencyCategoryIGC;
string itemName = currencyName; string itemName = spendCurrencyName;
LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra); if (string.IsNullOrEmpty(scene)) scene = Consts.ParameterDefaultScene;
LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, null, extra); // TODO 这里的打点不对
} }
/// <summary> /// <summary>
@ -846,6 +888,23 @@ namespace Guru
Analytics.SpendVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene, extra); Analytics.SpendVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene, extra);
} }
/// <summary>
/// 消耗 Boost 道具
/// </summary>
/// <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>
/// <param name="extra"></param>
public static void LogSpendVirtualCurrencyAsBoost(string currencyName, int value, int balance, string itemName = "",
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
{
string category = Consts.CurrencyCategoryBoost;
Analytics.SpendVirtualCurrency(currencyName, value, balance, category, itemName, levelName, scene, extra);
}
/// <summary> /// <summary>
/// 消耗货币购买道具 (spend_virtual_currency) (props) /// 消耗货币购买道具 (spend_virtual_currency) (props)
@ -860,7 +919,8 @@ namespace Guru
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)
{ {
LogSpendVirtualCurrencyWithProps(currencyName, new string[] {prop}, value, balance, levelName, scene, extra); string category = Consts.CurrencyCategoryProp;
LogSpendVirtualCurrency(currencyName, value, balance, category, prop, levelName, scene, extra);
} }
/// <summary> /// <summary>
@ -1241,11 +1301,11 @@ 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) // if (!IsInitialSuccess)
{ // {
UnityEngine.Debug.LogError($"{Tag} :: LogEvent {priority} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>."); // UnityEngine.Debug.LogError($"{Tag} :: LogEvent {priority} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
return; // 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);
@ -1264,11 +1324,11 @@ namespace Guru
public static void SetEventPriority(EventPriority priority, string eventName) public static void SetEventPriority(EventPriority priority, string eventName)
{ {
if (!IsInitialSuccess) // if (!IsInitialSuccess)
{ // {
UnityEngine.Debug.LogError($"{Tag} :: LogEvent {priority} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>."); // UnityEngine.Debug.LogError($"{Tag} :: LogEvent {priority} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
return; // return;
} // }
SetEventPriority(priority, new string[]{eventName}); SetEventPriority(priority, new string[]{eventName});
} }

View File

@ -73,6 +73,7 @@ namespace Guru
remove => _onAdsInitComplete -= value; remove => _onAdsInitComplete -= value;
} }
//------------ BANNER -----------------
internal static Action<string> _onBannerADStartLoad; internal static Action<string> _onBannerADStartLoad;
public static event Action<string> OnBannerADStartLoad public static event Action<string> OnBannerADStartLoad
{ {
@ -87,6 +88,7 @@ namespace Guru
remove => _onBannerADLoaded -= value; remove => _onBannerADLoaded -= value;
} }
//------------ INTER -----------------
internal static Action<string> _onInterstitialADStartLoad; internal static Action<string> _onInterstitialADStartLoad;
public static event Action<string> OnInterstitialADStartLoad public static event Action<string> OnInterstitialADStartLoad
{ {
@ -108,6 +110,14 @@ namespace Guru
remove => _onInterstitialADFailed -= value; remove => _onInterstitialADFailed -= value;
} }
internal static Action _onInterstitialADClosed;
public static event Action OnInterstitialADClosed
{
add => _onInterstitialADClosed += value;
remove => _onInterstitialADClosed -= value;
}
//------------ REWARD -----------------
internal static Action<string> _onRewardedADStartLoad; internal static Action<string> _onRewardedADStartLoad;
public static event Action<string> OnRewardedADStartLoad public static event Action<string> OnRewardedADStartLoad
{ {
@ -122,6 +132,13 @@ namespace Guru
remove => _onRewardedADLoaded -= value; remove => _onRewardedADLoaded -= value;
} }
internal static Action _onRewardADClosed;
public static event Action OnRewardedADClosed
{
add => _onRewardADClosed += value;
remove => _onRewardADClosed -= value;
}
internal static Action _onRewardADFailed; internal static Action _onRewardADFailed;
public static event Action OnRewardADFailed public static event Action OnRewardADFailed
{ {

View File

@ -241,11 +241,12 @@ namespace Guru
public const string PropertyNoAds = "no_ads"; // 玩家是否去广告 public const string PropertyNoAds = "no_ads"; // 玩家是否去广告
public const string PropertyATTStatus = "att_status"; // ATT 状态 public const string PropertyATTStatus = "att_status"; // ATT 状态
public const string PropertyNotiPerm = "noti_perm"; // Notification Permission 状态 public const string PropertyNotiPerm = "noti_perm"; // Notification Permission 状态
public const string PropertyAdjustId = "adjust_id"; // AdjustId
public const string PropertyGDPR = "gdpr"; // GDPR状态 public const string PropertyGDPR = "gdpr"; // GDPR状态
// 经济相关 // 经济相关
public const string ParameterBalance = "balance"; // 用于余额 public const string ParameterBalance = "balance"; // 用于余额
public const string ParameterDefaultScene = "ingame"; // 货币消费默认场景 public const string ParameterDefaultScene = "in_game"; // 货币消费默认场景
public const string ParameterVirtualCurrencyName = "virtual_currency_name"; // 虚拟货币名称 public const string ParameterVirtualCurrencyName = "virtual_currency_name"; // 虚拟货币名称
@ -259,7 +260,7 @@ namespace Guru
public const string CurrencyCategoryProp = "prop"; // prop public const string CurrencyCategoryProp = "prop"; // prop
public const string CurrencyCategoryProps = "props"; // props public const string CurrencyCategoryProps = "props"; // props
public const string CurrencyCategoryBundle = "bundle"; // prop groups public const string CurrencyCategoryBundle = "bundle"; // prop groups
public const string CurrencyCategoryBoost = "boost"; // boost
// SDK // SDK
public const string EventSDKInfo = "sdk_info"; public const string EventSDKInfo = "sdk_info";

View File

@ -1,3 +1,6 @@
using System;
using UnityEngine;
namespace Guru namespace Guru
{ {
public partial class GuruSDK public partial class GuruSDK
@ -41,5 +44,41 @@ namespace Guru
} }
#endregion #endregion
#region Android System
#if UNITY_ANDROID
/// <summary>
/// 获取 AndroidSDK 的系统版本号
/// </summary>
/// <returns></returns>
public static int GetAndroidSystemVersion()
{
try
{
// sdkInt 是 Android SDK 的整数版本号,例如 Android 10 对应 29。
// release 是 Android 版本的字符串表示,例如 "10"。
using (AndroidJavaClass jc = new AndroidJavaClass("android.os.Build$VERSION"))
{
int sdkInt = jc.GetStatic<int>("SDK_INT");
Debug.LogWarning($"[SDK] --- Android SDK Version:{sdkInt}");
return sdkInt;
}
}
catch (Exception ex)
{
Debug.LogError(ex);
}
return 0;
}
#endif
#endregion
} }
} }

View File

@ -9,8 +9,10 @@ namespace Guru
public partial class GuruSDK: MonoBehaviour public partial class GuruSDK: MonoBehaviour
{ {
// SDK_VERSION
public const string Version = "1.0.14";
public const string Version = "1.0.12"; //SDK_VERSION // Const
public const string Tag = "[Guru]"; public const string Tag = "[Guru]";
public const string ServicesConfigKey = "guru_services"; public const string ServicesConfigKey = "guru_services";
@ -163,7 +165,7 @@ namespace Guru
FirebaseUtil.onInitComplete += OnFirebaseReady; FirebaseUtil.onInitComplete += OnFirebaseReady;
FirebaseUtil.OnUserAuthResult += OnUserAuthResult; FirebaseUtil.OnUserAuthResult += OnUserAuthResult;
FirebaseUtil.OnFirebaseAuthResult += OnFirebaseAuthResult; FirebaseUtil.OnFirebaseAuthResult += OnFirebaseAuthResult;
FirebaseUtil.InitFirebase(null); // 确保所有的逻辑提前被调用到 FirebaseUtil.InitFirebase(null); // 确保所有的逻辑提前被调用到 + Analytics.Init TODO之后需要改为事件驱动
LogI($"#2.1 --- InitFacebook ---"); LogI($"#2.1 --- InitFacebook ---");
//---------- Start Facebook ------------ //---------- Start Facebook ------------
@ -209,7 +211,7 @@ namespace Guru
private void OnFirebaseReady(bool success) private void OnFirebaseReady(bool success)
{ {
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._onFirebaseReady?.Invoke(success);
// LogFirebaseDeps(success); // LogFirebaseDeps(success);
@ -276,9 +278,11 @@ namespace Guru
/// </summary> /// </summary>
private void InitAllServices() private void InitAllServices()
{ {
//-------- Init Analytics --------- // -------- Init Analytics ---------
InitUserProperties(); InitUserProperties();
SetSDKEventPriority(); SetSDKEventPriority();
// -------- Init Noti -----------
InitNotiPermission();
bool useKeywords = false; bool useKeywords = false;
bool useIAP = _initConfig.IAPEnabled; bool useIAP = _initConfig.IAPEnabled;
@ -415,7 +419,6 @@ namespace Guru
// StartConsentFlow(); // StartConsentFlow();
Try(() => Try(() =>
{ {
LogI($"#4.5 --- StartConsentFlow ---");
StartConsentFlow(); StartConsentFlow();
}, ex => }, ex =>
{ {
@ -755,7 +758,6 @@ namespace Guru
} }
} }
#endregion #endregion
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "com.guru.unity.sdk", "name": "com.guru.unity.sdk",
"displayName": "Guru SDK", "displayName": "Guru SDK",
"version": "1.0.13", "version": "1.0.14",
"description": "Guru SDK for unity project", "description": "Guru SDK for unity project",
"unity": "2020.3", "unity": "2020.3",
"author":{ "author":{