Compare commits
18 Commits
2fc6faf831
...
25f4d7e588
| Author | SHA1 | Date |
|---|---|---|
|
|
25f4d7e588 | |
|
|
1841edcbf3 | |
|
|
6e5ede3958 | |
|
|
2724683377 | |
|
|
d89de67e44 | |
|
|
3be05511e4 | |
|
|
6fc0c24823 | |
|
|
52b6af9fd0 | |
|
|
d574ec5757 | |
|
|
855cc61936 | |
|
|
bcaed876f7 | |
|
|
42966759b3 | |
|
|
4a39747d3d | |
|
|
d51759bbd1 | |
|
|
68e90a4ed9 | |
|
|
3d8bc1c642 | |
|
|
338c886ef6 | |
|
|
fa3ec5adef |
|
|
@ -20,6 +20,10 @@ namespace Guru
|
|||
/// </summary>
|
||||
public bool IAPEnabled = true;
|
||||
/// <summary>
|
||||
/// 自动申请推送授权信息
|
||||
/// </summary>
|
||||
public bool AutoNotificationPermission = true;
|
||||
/// <summary>
|
||||
/// 自动记录完成的关卡
|
||||
/// </summary>
|
||||
public bool AutoRecordFinishedLevels = true;
|
||||
|
|
@ -97,12 +101,18 @@ namespace Guru
|
|||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"------- Custom init Config -------");
|
||||
sb.AppendLine($"\tUseCustomConsent: {UseCustomConsent}");
|
||||
sb.AppendLine($"\tAutoLoadWhenAdsReady: {AutoLoadWhenAdsReady}");
|
||||
sb.AppendLine($"\tIAPEnabled: {IAPEnabled}");
|
||||
sb.AppendLine($"\tShowDebugLog: {DebugMode}");
|
||||
sb.AppendLine($"------- Custom init Config -------");
|
||||
sb.AppendLine($"------- Custom InitConfig -------");
|
||||
sb.AppendLine($"\t UseCustomConsent: {UseCustomConsent}");
|
||||
sb.AppendLine($"\t AutoLoadWhenAdsReady: {AutoLoadWhenAdsReady}");
|
||||
sb.AppendLine($"\t IAPEnabled: {IAPEnabled}");
|
||||
sb.AppendLine($"\t AutoNotificationPermission: {AutoNotificationPermission}");
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
|
||||
|
||||
namespace Guru
|
||||
{
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
using Guru.Notification;
|
||||
|
||||
public partial class GuruSDK
|
||||
{
|
||||
|
||||
private const float CONSENT_FLOW_TIMEOUT = 10; // Consent Flow 超时时间(秒)
|
||||
private static AdsInitSpec _adInitSpec;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -53,7 +52,7 @@ namespace Guru
|
|||
if (userAllow)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
CheckAttStatus();
|
||||
Instance.CheckAttStatus();
|
||||
#else
|
||||
StartAdService(spec);
|
||||
#endif
|
||||
|
|
@ -81,6 +80,8 @@ namespace Guru
|
|||
|
||||
private bool _hasConsentCalled = false;
|
||||
private bool _adServiceHasStarted = false;
|
||||
private string _notiStatue = "";
|
||||
private bool _hasNotiGranted = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启动Consent流程
|
||||
|
|
@ -88,10 +89,12 @@ namespace Guru
|
|||
/// </summary>
|
||||
private void StartConsentFlow()
|
||||
{
|
||||
LogI($"#4.5 --- StartConsentFlow ---");
|
||||
|
||||
float time = 1;
|
||||
if (!_adServiceHasStarted && _appServicesConfig != null)
|
||||
{
|
||||
time = _appServicesConfig.IsAdsCompliance() ? 10 : 1f; // 启动合规判定后, 延迟最多 10 秒后启动广告
|
||||
time = _appServicesConfig.IsAdsCompliance() ? CONSENT_FLOW_TIMEOUT : 1f; // 启动合规判定后, 延迟最多 10 秒后启动广告
|
||||
}
|
||||
Delay(time, AdServiceHandler); // 广告延迟启动
|
||||
|
||||
|
|
@ -130,7 +133,7 @@ namespace Guru
|
|||
#if UNITY_IOS
|
||||
CheckAttStatus(); // [iOS] Consent 启动后检查 ATT 初始值
|
||||
#elif UNITY_ANDROID
|
||||
CheckPermission(); // [Android] Consent 回调后检查 Push 推送权限
|
||||
CheckNotiPermission(); // Consent 回调后检查 Notification 权限
|
||||
#endif
|
||||
|
||||
// 内部处理后继逻辑
|
||||
|
|
@ -154,6 +157,8 @@ namespace Guru
|
|||
StartAdService(_adInitSpec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region IOS ATT 广告授权流程
|
||||
|
|
@ -167,7 +172,7 @@ namespace Guru
|
|||
/// <summary>
|
||||
/// 显示系统的 ATT 弹窗
|
||||
/// </summary>
|
||||
public static void RequestAttDialog()
|
||||
public void RequestAttDialog()
|
||||
{
|
||||
LogI($"RequestATTDialog");
|
||||
ATTManager.RequestATTDailog(ReportAttStatus);
|
||||
|
|
@ -186,7 +191,7 @@ namespace Guru
|
|||
/// <summary>
|
||||
/// iOS 平台检查 ATT 状态
|
||||
/// </summary>
|
||||
private static void CheckAttStatus(bool autoReCall = false)
|
||||
private void CheckAttStatus(bool autoReCall = false)
|
||||
{
|
||||
_autoReCallAtt = autoReCall;
|
||||
|
||||
|
|
@ -194,7 +199,7 @@ namespace Guru
|
|||
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}");
|
||||
SetUserProperty(Analytics.ParameterATTStatus, status); // 当前的状态
|
||||
|
|
@ -221,45 +226,85 @@ namespace Guru
|
|||
// ATT 状态已授权
|
||||
break;
|
||||
}
|
||||
|
||||
CheckNotiPermission(); // Consent 回调后检查 Notification 权限
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
#region Android 13 PushNotification Permission
|
||||
|
||||
private const string PERMISSION_POST_NOTIFICATION = "android.permission.POST_NOTIFICATIONS";
|
||||
|
||||
private void CheckPermission()
|
||||
{
|
||||
float delay = 1;
|
||||
UnityEngine.Debug.Log($"---- Check PushPermission ---");
|
||||
#if UNITY_ANDROID
|
||||
// 如果已经请求过权限的话, 则不做动作
|
||||
if (UnityEngine.Android.Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION))
|
||||
{
|
||||
UnityEngine.Debug.Log($"--- PushPermission has passed ---");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
Invoke(nameof(RequestNotification), delay);
|
||||
}
|
||||
|
||||
#region Notification Permission Check
|
||||
|
||||
/// <summary>
|
||||
/// 请求Notification
|
||||
/// 初始化 Noti Service
|
||||
/// </summary>
|
||||
private void RequestNotification()
|
||||
private void InitNotiPermission()
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
UnityEngine.Debug.Log("--- Target 33 Request Notification ---");
|
||||
// Android直接申请授权
|
||||
if (!UnityEngine.Android.Permission.HasUserAuthorizedPermission(PERMISSION_POST_NOTIFICATION))
|
||||
{
|
||||
UnityEngine.Android.Permission.RequestUserPermission(PERMISSION_POST_NOTIFICATION);
|
||||
}
|
||||
#endif
|
||||
bool hasNotiGranted = false;
|
||||
_notiStatue = "no_determined";
|
||||
NotificationService.Initialize(); // 初始化 Noti 服务
|
||||
SetNotiPerm(NotificationService.GetStatus());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查 Noti 状态
|
||||
/// </summary>
|
||||
private void CheckNotiPermission()
|
||||
{
|
||||
var status = NotificationService.GetStatus();
|
||||
|
||||
// 如果未启用自动 Noti 授权,则直接上报状态
|
||||
if (!_initConfig.AutoNotificationPermission)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"[SDK] ---- AutoNotificationPermission is OFF, Project should request permission own.");
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -306,10 +351,12 @@ namespace Guru
|
|||
ADService.OnInterstitialStartLoad = OnInterstitialStartLoad;
|
||||
ADService.OnInterstitialLoaded = OnInterstitialLoaded;
|
||||
ADService.OnInterstitialFailed = OnInterstitialFailed;
|
||||
ADService.OnInterstitialClosed = OnInterstitialClosed;
|
||||
// RADS
|
||||
ADService.OnRewardedStartLoad = OnRewardedStartLoad;
|
||||
ADService.OnRewardLoaded = OnRewardedLoaded;
|
||||
ADService.OnRewardFailed = OnRewardedFailed;
|
||||
ADService.OnRewardedStartLoad = OnRewardStartLoad;
|
||||
ADService.OnRewardLoaded = OnRewardLoaded;
|
||||
ADService.OnRewardFailed = OnRewardFailed;
|
||||
ADService.OnRewardClosed = OnRewardClosed;
|
||||
|
||||
// ---------- Start Services ----------
|
||||
ADService.Instance.StartService(OnAdsInitComplete, spec);
|
||||
|
|
@ -338,12 +385,16 @@ namespace Guru
|
|||
=> Callbacks.Ads._onInterstitialADLoaded?.Invoke();
|
||||
private static void OnInterstitialFailed()
|
||||
=> 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);
|
||||
private static void OnRewardedLoaded()
|
||||
private static void OnRewardLoaded()
|
||||
=> Callbacks.Ads._onRewardedADLoaded?.Invoke();
|
||||
private static void OnRewardedFailed()
|
||||
private static void OnRewardFailed()
|
||||
=> Callbacks.Ads._onRewardADFailed?.Invoke();
|
||||
private static void OnRewardClosed()
|
||||
=> Callbacks.Ads._onRewardADClosed?.Invoke();
|
||||
|
||||
private static void OnAdsInitComplete()
|
||||
{
|
||||
|
|
@ -494,6 +545,7 @@ namespace Guru
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ namespace Guru
|
|||
/// <param name="priority"></param>
|
||||
public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null, int priority = -1)
|
||||
{
|
||||
if (!IsInitialSuccess)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
|
||||
return;
|
||||
}
|
||||
// if (!IsInitialSuccess)
|
||||
// {
|
||||
// UnityEngine.Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(priority < 0) priority = GetEventPriorityInt(eventName);
|
||||
|
||||
|
|
@ -452,7 +452,11 @@ namespace Guru
|
|||
{
|
||||
SetUserProperty(Consts.PropertyATTStatus, status);
|
||||
}
|
||||
|
||||
|
||||
public static void SetAdjustId(string adjustId)
|
||||
{
|
||||
SetUserProperty(Consts.PropertyAdjustId, adjustId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化时调用一下所有的属性打点 </br>
|
||||
|
|
@ -613,6 +617,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 LogEarnVirtualCurrency(string currencyName,
|
||||
int value, int balance,
|
||||
string category = "", string itemName = "",
|
||||
|
|
@ -621,19 +626,55 @@ namespace Guru
|
|||
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>
|
||||
/// 赚取组合: 货币+道具 (earn_virtual_currency) (props)
|
||||
/// </summary>
|
||||
/// <param name="currencyName"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="balance"></param>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="itemName"></param>
|
||||
/// <param name="props"></param>
|
||||
/// <param name="levelName"></param>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="currencyName">货币名称</param>
|
||||
/// <param name="value">货币增加值 10</param>
|
||||
/// <param name="balance">结算后货币总量 20 -> 30</param>
|
||||
/// <param name="category">消耗类型, 默认值请赋 reward</param>
|
||||
/// <param name="itemName">购买道具名称</param>
|
||||
/// <param name="props">获取的道具组合</param>
|
||||
/// <param name="levelName">当前关卡或者人物等级名称</param>
|
||||
/// <param name="scene">购买场景如 Store, Workbench, Sign, Ads....</param>
|
||||
/// <param name="extra">自定义数据</param>
|
||||
private static void LogEarnVirtualCurrencyAndProps(string currencyName,
|
||||
int value = 0, int balance = 0,
|
||||
string category = "", string itemName = "",
|
||||
|
|
@ -767,22 +808,23 @@ namespace Guru
|
|||
|
||||
|
||||
/// <summary>
|
||||
/// 通过使用 Currency 购买获得 Prop (earn_virtual_currency) (reward:level)
|
||||
/// 购买获得 Prop (earn_virtual_currency) (reward:level)
|
||||
/// 记录 Prop 增加的打点, 消费游戏内货币
|
||||
/// </summary>
|
||||
/// <param name="currencyName">货币名称</param>
|
||||
/// <param name="props">获取的道具名称列表</param>
|
||||
/// <param name="currencyName">购买的道具名称</param>
|
||||
/// <param name="spendCurrencyName">消费货币名称</param>
|
||||
/// <param name="scene">应用场景</param>
|
||||
/// <param name="value">赚取金额</param>
|
||||
/// <param name="balance">货币总量(累加后)</param>
|
||||
/// <param name="value">购入数量</param>
|
||||
/// <param name="balance">道具总量(累加后)</param>
|
||||
/// <param name="levelName">当前关卡名称</param>
|
||||
public static void LogEarnPropsByVirtualCurrency(string currencyName, string[] props,
|
||||
string scene = Consts.ParameterDefaultScene,
|
||||
int value = 1, int balance = 0, string levelName = "", Dictionary<string, object> extra = null)
|
||||
/// <param name="extra"></param>
|
||||
public static void LogEarnVirtualCurrencyByIGC(string currencyName, string spendCurrencyName, int value = 0, int balance = 0,
|
||||
string levelName = "", string scene = "", Dictionary<string, object> extra = null)
|
||||
{
|
||||
string category = Consts.CurrencyCategoryIGC;
|
||||
string itemName = currencyName;
|
||||
LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, props, extra);
|
||||
string itemName = spendCurrencyName;
|
||||
if (string.IsNullOrEmpty(scene)) scene = Consts.ParameterDefaultScene;
|
||||
LogEarnVirtualCurrencyAndProps(currencyName, value, balance, category, itemName, levelName, scene, null, extra); // TODO 这里的打点不对
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -845,8 +887,25 @@ namespace Guru
|
|||
{
|
||||
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>
|
||||
/// 消耗货币购买道具 (spend_virtual_currency) (props)
|
||||
/// </summary>
|
||||
|
|
@ -860,7 +919,8 @@ namespace Guru
|
|||
int value, int balance,
|
||||
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>
|
||||
|
|
@ -1241,11 +1301,11 @@ 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 (!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);
|
||||
|
||||
|
|
@ -1264,11 +1324,11 @@ 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;
|
||||
}
|
||||
// if (!IsInitialSuccess)
|
||||
// {
|
||||
// UnityEngine.Debug.LogError($"{Tag} :: LogEvent {priority} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
SetEventPriority(priority, new string[]{eventName});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ namespace Guru
|
|||
remove => _onAdsInitComplete -= value;
|
||||
}
|
||||
|
||||
//------------ BANNER -----------------
|
||||
internal static Action<string> _onBannerADStartLoad;
|
||||
public static event Action<string> OnBannerADStartLoad
|
||||
{
|
||||
|
|
@ -87,6 +88,7 @@ namespace Guru
|
|||
remove => _onBannerADLoaded -= value;
|
||||
}
|
||||
|
||||
//------------ INTER -----------------
|
||||
internal static Action<string> _onInterstitialADStartLoad;
|
||||
public static event Action<string> OnInterstitialADStartLoad
|
||||
{
|
||||
|
|
@ -107,7 +109,15 @@ namespace Guru
|
|||
add => _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;
|
||||
public static event Action<string> OnRewardedADStartLoad
|
||||
{
|
||||
|
|
@ -121,6 +131,13 @@ namespace Guru
|
|||
add => _onRewardedADLoaded += value;
|
||||
remove => _onRewardedADLoaded -= value;
|
||||
}
|
||||
|
||||
internal static Action _onRewardADClosed;
|
||||
public static event Action OnRewardedADClosed
|
||||
{
|
||||
add => _onRewardADClosed += value;
|
||||
remove => _onRewardADClosed -= value;
|
||||
}
|
||||
|
||||
internal static Action _onRewardADFailed;
|
||||
public static event Action OnRewardADFailed
|
||||
|
|
@ -241,11 +241,12 @@ namespace Guru
|
|||
public const string PropertyNoAds = "no_ads"; // 玩家是否去广告
|
||||
public const string PropertyATTStatus = "att_status"; // ATT 状态
|
||||
public const string PropertyNotiPerm = "noti_perm"; // Notification Permission 状态
|
||||
public const string PropertyAdjustId = "adjust_id"; // AdjustId
|
||||
public const string PropertyGDPR = "gdpr"; // GDPR状态
|
||||
|
||||
// 经济相关
|
||||
public const string ParameterBalance = "balance"; // 用于余额
|
||||
public const string ParameterDefaultScene = "ingame"; // 货币消费默认场景
|
||||
public const string ParameterDefaultScene = "in_game"; // 货币消费默认场景
|
||||
public const string ParameterVirtualCurrencyName = "virtual_currency_name"; // 虚拟货币名称
|
||||
|
||||
|
||||
|
|
@ -259,7 +260,7 @@ namespace Guru
|
|||
public const string CurrencyCategoryProp = "prop"; // prop
|
||||
public const string CurrencyCategoryProps = "props"; // props
|
||||
public const string CurrencyCategoryBundle = "bundle"; // prop groups
|
||||
|
||||
public const string CurrencyCategoryBoost = "boost"; // boost
|
||||
|
||||
// SDK
|
||||
public const string EventSDKInfo = "sdk_info";
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Guru
|
||||
{
|
||||
public partial class GuruSDK
|
||||
|
|
@ -41,5 +44,41 @@ namespace Guru
|
|||
}
|
||||
|
||||
#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
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,10 @@ namespace Guru
|
|||
|
||||
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 ServicesConfigKey = "guru_services";
|
||||
|
||||
|
|
@ -163,7 +165,7 @@ namespace Guru
|
|||
FirebaseUtil.onInitComplete += OnFirebaseReady;
|
||||
FirebaseUtil.OnUserAuthResult += OnUserAuthResult;
|
||||
FirebaseUtil.OnFirebaseAuthResult += OnFirebaseAuthResult;
|
||||
FirebaseUtil.InitFirebase(null); // 确保所有的逻辑提前被调用到
|
||||
FirebaseUtil.InitFirebase(null); // 确保所有的逻辑提前被调用到 + Analytics.Init TODO:之后需要改为事件驱动
|
||||
|
||||
LogI($"#2.1 --- InitFacebook ---");
|
||||
//---------- Start Facebook ------------
|
||||
|
|
@ -209,7 +211,7 @@ namespace Guru
|
|||
private void OnFirebaseReady(bool success)
|
||||
{
|
||||
FirebaseUtil.onInitComplete -= OnFirebaseReady;
|
||||
LogI($"#3 --- On FirebaseDeps:{success} ---");
|
||||
LogI($"#3 --- On FirebaseDeps: {success} ---");
|
||||
IsFirebaseReady = success;
|
||||
Callbacks.SDK._onFirebaseReady?.Invoke(success);
|
||||
// LogFirebaseDeps(success);
|
||||
|
|
@ -276,9 +278,11 @@ namespace Guru
|
|||
/// </summary>
|
||||
private void InitAllServices()
|
||||
{
|
||||
//-------- Init Analytics ---------
|
||||
// -------- Init Analytics ---------
|
||||
InitUserProperties();
|
||||
SetSDKEventPriority();
|
||||
// -------- Init Noti -----------
|
||||
InitNotiPermission();
|
||||
|
||||
bool useKeywords = false;
|
||||
bool useIAP = _initConfig.IAPEnabled;
|
||||
|
|
@ -415,7 +419,6 @@ namespace Guru
|
|||
// StartConsentFlow();
|
||||
Try(() =>
|
||||
{
|
||||
LogI($"#4.5 --- StartConsentFlow ---");
|
||||
StartConsentFlow();
|
||||
}, ex =>
|
||||
{
|
||||
|
|
@ -754,8 +757,7 @@ namespace Guru
|
|||
request.Send();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "com.guru.unity.sdk",
|
||||
"displayName": "Guru SDK",
|
||||
"version": "1.0.13",
|
||||
"version": "1.0.14",
|
||||
"description": "Guru SDK for unity project",
|
||||
"unity": "2020.3",
|
||||
"author":{
|
||||
|
|
|
|||
Loading…
Reference in New Issue