update: 更新生命周期和对应的逻辑
parent
bb4073aa2f
commit
b1bf57cbed
|
|
@ -54,6 +54,7 @@ namespace Guru
|
||||||
//-------------------------------- Parameters --------------------------------
|
//-------------------------------- Parameters --------------------------------
|
||||||
public double Tch02Value() => parameters?.tch_020 ?? 0;
|
public double Tch02Value() => parameters?.tch_020 ?? 0;
|
||||||
public bool IsAppReview() => parameters?.apple_review ?? false;
|
public bool IsAppReview() => parameters?.apple_review ?? false;
|
||||||
|
public bool EnableErrorLog() => parameters?.enable_errorlog ?? false;
|
||||||
public bool DMACountryCheck() => parameters?.dma_country_check ?? false;
|
public bool DMACountryCheck() => parameters?.dma_country_check ?? false;
|
||||||
public string DMAMapRule() => parameters?.dma_map_rule ?? "";
|
public string DMAMapRule() => parameters?.dma_map_rule ?? "";
|
||||||
public bool UseUUID() => parameters?.using_uuid ?? false;
|
public bool UseUUID() => parameters?.using_uuid ?? false;
|
||||||
|
|
@ -93,6 +94,7 @@ namespace Guru
|
||||||
public string dma_map_rule = "";
|
public string dma_map_rule = "";
|
||||||
public bool dma_country_check = false;
|
public bool dma_country_check = false;
|
||||||
public bool apple_review = false; // 苹果审核标志位
|
public bool apple_review = false; // 苹果审核标志位
|
||||||
|
public bool enable_errorlog = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,8 @@ namespace Guru
|
||||||
return _guruSettings;
|
return _guruSettings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static DateTime _initTime;
|
private static DateTime _initTime;
|
||||||
|
|
||||||
|
|
||||||
private static bool _isDebugEnabled = false;
|
private static bool _isDebugEnabled = false;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Debug Mode
|
/// Debug Mode
|
||||||
|
|
@ -104,7 +101,7 @@ namespace Guru
|
||||||
public static void Init(GuruSDKInitConfig config, Action<bool> onComplete)
|
public static void Init(GuruSDKInitConfig config, Action<bool> onComplete)
|
||||||
{
|
{
|
||||||
_initTime = DateTime.Now.ToUniversalTime();
|
_initTime = DateTime.Now.ToUniversalTime();
|
||||||
LogI($"---- Guru SDK init ----\n{config.ToString()}");
|
LogI($"#1 ---- Guru SDK init ----\n{config.ToString()}");
|
||||||
Instance.StartWithConfig(config, onComplete);
|
Instance.StartWithConfig(config, onComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,25 +120,21 @@ namespace Guru
|
||||||
_initConfig = config;
|
_initConfig = config;
|
||||||
_onCompleteCallback = onComplete;
|
_onCompleteCallback = onComplete;
|
||||||
_isDebugEnabled = config.DebugMode;
|
_isDebugEnabled = config.DebugMode;
|
||||||
GuruRepoter.Install(); // Install Crashlytics Logger
|
|
||||||
|
|
||||||
bool isDebug = false;
|
|
||||||
#if DEBUG
|
|
||||||
isDebug = true;
|
|
||||||
#endif
|
|
||||||
Analytics.InstallGuruAnalytics(isDebug); // 提前初始化 GuruAnalytics
|
|
||||||
//--- 之后的逻辑放在 Start 方法内 ---
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
//---- Init All tools ----
|
//---- Init All tools ----
|
||||||
LogI($"--- InitFirebase ---");
|
LogI($"#2 --- InitFirebase ---");
|
||||||
//---------- Start Firebase ------------
|
//---------- Start Firebase ------------
|
||||||
FirebaseUtil.InitFirebase(OnFirebaseReady);
|
FirebaseUtil.InitFirebase(OnFirebaseReady); // 确保所有的逻辑提前被调用到
|
||||||
// FirebaseUtil.OnFetchRemoteSuccess+= OnFetchRemoteCallback;
|
|
||||||
|
LogI($"#2.1 --- InitFacebook ---");
|
||||||
//---------- Start Facebook ------------
|
//---------- Start Facebook ------------
|
||||||
FBService.Instance.StartService();
|
FBService.Instance.StartService();
|
||||||
|
|
||||||
|
LogI($"#2.2 --- Call SDK init complete -> callback: { (_onCompleteCallback == null ? "Null" : _onCompleteCallback.ToString()) } ---");
|
||||||
|
_onCompleteCallback?.Invoke(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -150,28 +143,21 @@ namespace Guru
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnFirebaseReady()
|
private void OnFirebaseReady()
|
||||||
{
|
{
|
||||||
LogI($"--- OnFirebaseReady ---");
|
LogI($"#3 --- On FirebaseReady ---");
|
||||||
IsInitialSuccess = true;
|
IsInitialSuccess = true;
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID);
|
if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID); ;
|
||||||
LogI($"--- UID:{IPMConfig.IPM_UID} ---");
|
|
||||||
|
|
||||||
LogI($"--- Init RemoteConfig ---");
|
LogI($"#3.5 --- Call InitRemoteConfig ---");
|
||||||
// 开始Remote Manager初始化
|
// 开始Remote Manager初始化
|
||||||
RemoteConfigManager.Init(BuildDefaultRemoteData(_initConfig.DefaultRemoteData));
|
RemoteConfigManager.Init(BuildDefaultRemoteData(_initConfig.DefaultRemoteData));
|
||||||
RemoteConfigManager.OnFetchCompleted += OnFetchRemoteCallback;
|
RemoteConfigManager.OnFetchCompleted += OnFetchRemoteCallback;
|
||||||
|
|
||||||
// 延迟执行 SDK 回调
|
LogI($"#4 --- Apply remote services config ---");
|
||||||
// Delay(0, () =>
|
// 根据缓存的云控配置来初始化参数
|
||||||
// {
|
InitAllServices();
|
||||||
LogI($"--- SDK Init Complete -> Callback: { (_onCompleteCallback == null ? "Null" : "NotNull") } ---");
|
|
||||||
_onCompleteCallback?.Invoke(true);
|
|
||||||
// });
|
|
||||||
|
|
||||||
LogI($"--- Apply online services config ---");
|
|
||||||
// 根据上次的云控配置来初始化参数
|
|
||||||
SetupServicesConfig();
|
|
||||||
|
|
||||||
|
LogI($"#5 --- sync sdk time ---");
|
||||||
var sp = DateTime.Now.ToUniversalTime() - _initTime;
|
var sp = DateTime.Now.ToUniversalTime() - _initTime;
|
||||||
LogSDKInitTime(sp.TotalSeconds);
|
LogSDKInitTime(sp.TotalSeconds);
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +184,7 @@ namespace Guru
|
||||||
/// <param name="success"></param>
|
/// <param name="success"></param>
|
||||||
private void OnFetchRemoteCallback(bool success)
|
private void OnFetchRemoteCallback(bool success)
|
||||||
{
|
{
|
||||||
LogI($"--- Remote fetch complete: {success} ---");
|
LogI($"#6 --- Remote fetch complete: {success} ---");
|
||||||
ABTestManager.Init(); // 启动AB测试解析器
|
ABTestManager.Init(); // 启动AB测试解析器
|
||||||
Callbacks.Remote._onRemoteFetchComplete?.Invoke(success);
|
Callbacks.Remote._onRemoteFetchComplete?.Invoke(success);
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +196,7 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply Cloud guru-service configs for sdk assets
|
/// Apply Cloud guru-service configs for sdk assets
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void SetupServicesConfig()
|
private void InitAllServices()
|
||||||
{
|
{
|
||||||
bool useKeywords = false;
|
bool useKeywords = false;
|
||||||
bool useIAP = true;
|
bool useIAP = true;
|
||||||
|
|
@ -226,9 +212,13 @@ namespace Guru
|
||||||
|
|
||||||
Try(() =>
|
Try(() =>
|
||||||
{
|
{
|
||||||
LogI($"--- Init apply services ---");
|
LogI($"#4.1 --- Init apply services ---");
|
||||||
//--------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
|
// 自打点设置错误上报
|
||||||
|
GuruAnalytics.EnableErrorLog = _appServicesConfig.EnableErrorLog();
|
||||||
|
|
||||||
|
// adjust 事件设置
|
||||||
if (null != _appServicesConfig.adjust_settings && null != GuruSettings)
|
if (null != _appServicesConfig.adjust_settings && null != GuruSettings)
|
||||||
{
|
{
|
||||||
// 更新 Adjust Tokens
|
// 更新 Adjust Tokens
|
||||||
|
|
@ -239,6 +229,8 @@ namespace Guru
|
||||||
GuruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events);
|
GuruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogI($"#4.2 --- Init GuruSttings ---");
|
||||||
|
// GuruSettings 设置
|
||||||
if (null != _appServicesConfig.app_settings)
|
if (null != _appServicesConfig.app_settings)
|
||||||
{
|
{
|
||||||
if (_appServicesConfig.Tch02Value() > 0)
|
if (_appServicesConfig.Tch02Value() > 0)
|
||||||
|
|
@ -251,6 +243,9 @@ namespace Guru
|
||||||
if (_appServicesConfig.UseUUID())
|
if (_appServicesConfig.UseUUID())
|
||||||
{
|
{
|
||||||
IPMConfig.UsingUUID = true; // 开始使用 UUID 作为 DeviceID 标识
|
IPMConfig.UsingUUID = true; // 开始使用 UUID 作为 DeviceID 标识
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_IOS
|
#if UNITY_IOS
|
||||||
|
|
@ -285,7 +280,7 @@ namespace Guru
|
||||||
// InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP
|
// InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP
|
||||||
Try(() =>
|
Try(() =>
|
||||||
{
|
{
|
||||||
LogI($"--- Init IAP ---");
|
LogI($"#4.3 --- Init IAP ---");
|
||||||
InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP
|
InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP
|
||||||
}, ex =>
|
}, ex =>
|
||||||
{
|
{
|
||||||
|
|
@ -299,7 +294,7 @@ namespace Guru
|
||||||
// KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器
|
// KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器
|
||||||
Try(() =>
|
Try(() =>
|
||||||
{
|
{
|
||||||
LogI($"--- Init Keywords ---");
|
LogI($"#4.4 --- Init Keywords ---");
|
||||||
KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器
|
KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器
|
||||||
}, ex =>
|
}, ex =>
|
||||||
{
|
{
|
||||||
|
|
@ -313,7 +308,7 @@ namespace Guru
|
||||||
// StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程
|
// StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程
|
||||||
Try(() =>
|
Try(() =>
|
||||||
{
|
{
|
||||||
LogI($"--- StartAppleReviewFlow ---");
|
LogI($"#4.5.0 --- StartAppleReviewFlow ---");
|
||||||
StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程
|
StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程
|
||||||
}, ex =>
|
}, ex =>
|
||||||
{
|
{
|
||||||
|
|
@ -328,7 +323,7 @@ namespace Guru
|
||||||
// StartConsentFlow();
|
// StartConsentFlow();
|
||||||
Try(() =>
|
Try(() =>
|
||||||
{
|
{
|
||||||
LogI($"--- #1. StartConsentFlow ---");
|
LogI($"#4.5 --- StartConsentFlow ---");
|
||||||
StartConsentFlow();
|
StartConsentFlow();
|
||||||
}, ex =>
|
}, ex =>
|
||||||
{
|
{
|
||||||
|
|
@ -452,7 +447,7 @@ namespace Guru
|
||||||
/// <param name="message"></param>
|
/// <param name="message"></param>
|
||||||
public static void Report(string message)
|
public static void Report(string message)
|
||||||
{
|
{
|
||||||
GuruRepoter.Log(message);
|
Analytics.LogCrashlytics(message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -461,7 +456,7 @@ namespace Guru
|
||||||
/// <param name="message"></param>
|
/// <param name="message"></param>
|
||||||
public static void ReportException(string message)
|
public static void ReportException(string message)
|
||||||
{
|
{
|
||||||
GuruRepoter.LogException(message);
|
Analytics.LogCrashlytics(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -470,7 +465,7 @@ namespace Guru
|
||||||
/// <param name="ex"></param>
|
/// <param name="ex"></param>
|
||||||
public static void ReportException(Exception ex)
|
public static void ReportException(Exception ex)
|
||||||
{
|
{
|
||||||
GuruRepoter.LogException(ex);
|
Analytics.LogCrashlytics(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue