From b1bf57cbed5de295631f39a17e3387ac79f87548 Mon Sep 17 00:00:00 2001 From: huyufei Date: Wed, 13 Mar 2024 17:26:20 +0800 Subject: [PATCH 1/9] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E7=94=9F?= =?UTF-8?q?=E5=91=BD=E5=91=A8=E6=9C=9F=E5=92=8C=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/Config/GuruServicesConfig.cs | 2 + Runtime/Code/SDK/GuruSDK.cs | 77 +++++++++++------------ 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/Runtime/Code/Config/GuruServicesConfig.cs b/Runtime/Code/Config/GuruServicesConfig.cs index fa0963e..0f43e98 100644 --- a/Runtime/Code/Config/GuruServicesConfig.cs +++ b/Runtime/Code/Config/GuruServicesConfig.cs @@ -54,6 +54,7 @@ namespace Guru //-------------------------------- Parameters -------------------------------- public double Tch02Value() => parameters?.tch_020 ?? 0; public bool IsAppReview() => parameters?.apple_review ?? false; + public bool EnableErrorLog() => parameters?.enable_errorlog ?? false; public bool DMACountryCheck() => parameters?.dma_country_check ?? false; public string DMAMapRule() => parameters?.dma_map_rule ?? ""; public bool UseUUID() => parameters?.using_uuid ?? false; @@ -93,6 +94,7 @@ namespace Guru public string dma_map_rule = ""; public bool dma_country_check = false; public bool apple_review = false; // 苹果审核标志位 + public bool enable_errorlog = false; } [Serializable] diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index 9aee671..02ee0f0 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -46,11 +46,8 @@ namespace Guru return _guruSettings; } } - - + private static DateTime _initTime; - - private static bool _isDebugEnabled = false; /// /// Debug Mode @@ -104,7 +101,7 @@ namespace Guru public static void Init(GuruSDKInitConfig config, Action onComplete) { _initTime = DateTime.Now.ToUniversalTime(); - LogI($"---- Guru SDK init ----\n{config.ToString()}"); + LogI($"#1 ---- Guru SDK init ----\n{config.ToString()}"); Instance.StartWithConfig(config, onComplete); } @@ -123,25 +120,21 @@ namespace Guru _initConfig = config; _onCompleteCallback = onComplete; _isDebugEnabled = config.DebugMode; - GuruRepoter.Install(); // Install Crashlytics Logger - - bool isDebug = false; -#if DEBUG - isDebug = true; -#endif - Analytics.InstallGuruAnalytics(isDebug); // 提前初始化 GuruAnalytics - //--- 之后的逻辑放在 Start 方法内 --- } void Start() { //---- Init All tools ---- - LogI($"--- InitFirebase ---"); + LogI($"#2 --- InitFirebase ---"); //---------- Start Firebase ------------ - FirebaseUtil.InitFirebase(OnFirebaseReady); - // FirebaseUtil.OnFetchRemoteSuccess+= OnFetchRemoteCallback; + FirebaseUtil.InitFirebase(OnFirebaseReady); // 确保所有的逻辑提前被调用到 + + LogI($"#2.1 --- InitFacebook ---"); //---------- Start Facebook ------------ 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 /// private void OnFirebaseReady() { - LogI($"--- OnFirebaseReady ---"); + LogI($"#3 --- On FirebaseReady ---"); IsInitialSuccess = true; - if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID); - LogI($"--- UID:{IPMConfig.IPM_UID} ---"); + if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID); ; - LogI($"--- Init RemoteConfig ---"); + LogI($"#3.5 --- Call InitRemoteConfig ---"); // 开始Remote Manager初始化 RemoteConfigManager.Init(BuildDefaultRemoteData(_initConfig.DefaultRemoteData)); RemoteConfigManager.OnFetchCompleted += OnFetchRemoteCallback; - // 延迟执行 SDK 回调 - // Delay(0, () => - // { - LogI($"--- SDK Init Complete -> Callback: { (_onCompleteCallback == null ? "Null" : "NotNull") } ---"); - _onCompleteCallback?.Invoke(true); - // }); - - LogI($"--- Apply online services config ---"); - // 根据上次的云控配置来初始化参数 - SetupServicesConfig(); + LogI($"#4 --- Apply remote services config ---"); + // 根据缓存的云控配置来初始化参数 + InitAllServices(); + LogI($"#5 --- sync sdk time ---"); var sp = DateTime.Now.ToUniversalTime() - _initTime; LogSDKInitTime(sp.TotalSeconds); } @@ -198,7 +184,7 @@ namespace Guru /// private void OnFetchRemoteCallback(bool success) { - LogI($"--- Remote fetch complete: {success} ---"); + LogI($"#6 --- Remote fetch complete: {success} ---"); ABTestManager.Init(); // 启动AB测试解析器 Callbacks.Remote._onRemoteFetchComplete?.Invoke(success); } @@ -210,7 +196,7 @@ namespace Guru /// /// Apply Cloud guru-service configs for sdk assets /// - private void SetupServicesConfig() + private void InitAllServices() { bool useKeywords = false; bool useIAP = true; @@ -226,9 +212,13 @@ namespace Guru Try(() => { - LogI($"--- Init apply services ---"); - //-------------------------------- + LogI($"#4.1 --- Init apply services ---"); + //---------------------------------------------------------------- + + // 自打点设置错误上报 + GuruAnalytics.EnableErrorLog = _appServicesConfig.EnableErrorLog(); + // adjust 事件设置 if (null != _appServicesConfig.adjust_settings && null != GuruSettings) { // 更新 Adjust Tokens @@ -239,6 +229,8 @@ namespace Guru GuruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events); } + LogI($"#4.2 --- Init GuruSttings ---"); + // GuruSettings 设置 if (null != _appServicesConfig.app_settings) { if (_appServicesConfig.Tch02Value() > 0) @@ -251,6 +243,9 @@ namespace Guru if (_appServicesConfig.UseUUID()) { IPMConfig.UsingUUID = true; // 开始使用 UUID 作为 DeviceID 标识 + + + } #if UNITY_IOS @@ -285,7 +280,7 @@ namespace Guru // InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP Try(() => { - LogI($"--- Init IAP ---"); + LogI($"#4.3 --- Init IAP ---"); InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP }, ex => { @@ -299,7 +294,7 @@ namespace Guru // KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器 Try(() => { - LogI($"--- Init Keywords ---"); + LogI($"#4.4 --- Init Keywords ---"); KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器 }, ex => { @@ -313,7 +308,7 @@ namespace Guru // StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程 Try(() => { - LogI($"--- StartAppleReviewFlow ---"); + LogI($"#4.5.0 --- StartAppleReviewFlow ---"); StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程 }, ex => { @@ -328,7 +323,7 @@ namespace Guru // StartConsentFlow(); Try(() => { - LogI($"--- #1. StartConsentFlow ---"); + LogI($"#4.5 --- StartConsentFlow ---"); StartConsentFlow(); }, ex => { @@ -452,7 +447,7 @@ namespace Guru /// public static void Report(string message) { - GuruRepoter.Log(message); + Analytics.LogCrashlytics(message, false); } /// @@ -461,7 +456,7 @@ namespace Guru /// public static void ReportException(string message) { - GuruRepoter.LogException(message); + Analytics.LogCrashlytics(message); } /// @@ -470,7 +465,7 @@ namespace Guru /// public static void ReportException(Exception ex) { - GuruRepoter.LogException(ex); + Analytics.LogCrashlytics(ex); } #endregion From 19be8b5d481e446ca17af401d1c04bc27202f6db Mon Sep 17 00:00:00 2001 From: huyufei Date: Fri, 15 Mar 2024 12:26:34 +0800 Subject: [PATCH 2/9] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=89=93?= =?UTF-8?q?=E7=82=B9=E5=92=8C=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F=E7=9A=84?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.Analytics.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Runtime/Code/SDK/GuruSDK.Analytics.cs b/Runtime/Code/SDK/GuruSDK.Analytics.cs index e5a7611..2913829 100644 --- a/Runtime/Code/SDK/GuruSDK.Analytics.cs +++ b/Runtime/Code/SDK/GuruSDK.Analytics.cs @@ -36,7 +36,7 @@ namespace Guru { if (!IsInitialSuccess) { - Debug.LogError($"{Tag} Please call first, before you call ."); + Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call first, before you call ."); return; } Analytics.Track(eventName, data); @@ -46,7 +46,7 @@ namespace Guru { if (!IsInitialSuccess) { - Debug.LogError($"{Tag} Please call first, before you call ."); + Debug.LogError($"{Tag} :: SetScreen {screen} :: Please call first, before you call ."); return; } Analytics.SetCurrentScreen(screen, extra); @@ -71,7 +71,7 @@ namespace Guru { if (!IsInitialSuccess) { - Debug.LogError($"{Tag} Please call first, before you call ."); + Debug.LogError($"{Tag} :: LogLevelStart {level} :: Please call first, before you call ."); return; } @@ -113,7 +113,7 @@ namespace Guru { if (!IsInitialSuccess) { - Debug.LogError($"{Tag} Please call first, before you call ."); + Debug.LogError($"{Tag} :: LogLevelEnd {level} :: Please call first, before you call ."); return; } @@ -177,7 +177,7 @@ namespace Guru { if (!IsInitialSuccess) { - Debug.LogError($"{Tag} Please call first, before you call ."); + Debug.LogError($"{Tag} :: LogLevelUp {playerLevel} :: Please call first, before you call ."); return; } Analytics.LevelUp(playerLevel, playerName); @@ -191,7 +191,7 @@ namespace Guru { if (!IsInitialSuccess) { - Debug.LogError($"{Tag} Please call first, before you call ."); + Debug.LogError($"{Tag} :: LogAchievement {achievementName} :: Please call first, before you call ."); return; } Analytics.UnlockAchievement(achievementName); @@ -210,7 +210,7 @@ namespace Guru { if (!IsInitialSuccess) { - Debug.LogError($"{Tag} Please call first, before you call ."); + Debug.LogError($"{Tag} :: SetUserProperty {key}:{value} ::Please call first, before you call ."); return; } Analytics.SetUserProperty(key, value); From 1f71522fa69c8ed0accb27a9bb94e4c61f60f943 Mon Sep 17 00:00:00 2001 From: huyufei Date: Fri, 15 Mar 2024 12:59:20 +0800 Subject: [PATCH 3/9] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E6=89=93?= =?UTF-8?q?=E7=82=B9=E5=92=8C=20Firebase=20=E5=9B=9E=E8=B0=83=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.Analytics.cs | 21 +++++++++++++++++---- Runtime/Code/SDK/GuruSDK.Callback.cs | 11 +++++++++++ Runtime/Code/SDK/GuruSDK.cs | 16 +++++++++------- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/Runtime/Code/SDK/GuruSDK.Analytics.cs b/Runtime/Code/SDK/GuruSDK.Analytics.cs index 2913829..f1fdc27 100644 --- a/Runtime/Code/SDK/GuruSDK.Analytics.cs +++ b/Runtime/Code/SDK/GuruSDK.Analytics.cs @@ -265,6 +265,9 @@ namespace Guru #endregion #region SDK 打点 + + public const string EventUnitySDK = "guru_unity_sdk"; + /// /// Log SDK boost time @@ -272,16 +275,26 @@ namespace Guru /// private static void LogSDKInitTime(double time) { - Analytics.Track("sdk_init_time", new Dictionary() + Analytics.Track(EventUnitySDK, new Dictionary() { - {"time", time.ToString("F6")}, - {"device_id", DeviceId}, + { "init_time", time.ToString("F6") }, + { Consts.PropertyDeviceID, DeviceId }, + }, new Analytics.EventSetting() + { + EnableFirebaseAnalytics = true, + }); + } + + private static void LogFirebaseDeps(bool success) + { + Analytics.Track(EventUnitySDK, new Dictionary() + { + {"firebase_deps", success? "true" : "false"}, }, new Analytics.EventSetting() { EnableFirebaseAnalytics = true, }); } - #endregion } diff --git a/Runtime/Code/SDK/GuruSDK.Callback.cs b/Runtime/Code/SDK/GuruSDK.Callback.cs index 5c352e6..3c7911c 100644 --- a/Runtime/Code/SDK/GuruSDK.Callback.cs +++ b/Runtime/Code/SDK/GuruSDK.Callback.cs @@ -158,6 +158,17 @@ namespace Guru } + + public static class SDK + { + internal static Action _onFirebaseReady; + public static event Action OnFirebaseReady + { + add => _onFirebaseReady += value; + remove => _onFirebaseReady -= value; + } + } + } diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index 02ee0f0..5524e62 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -127,13 +127,15 @@ namespace Guru //---- Init All tools ---- LogI($"#2 --- InitFirebase ---"); //---------- Start Firebase ------------ - FirebaseUtil.InitFirebase(OnFirebaseReady); // 确保所有的逻辑提前被调用到 + FirebaseUtil.onInitComplete += OnFirebaseReady; + FirebaseUtil.InitFirebase(null); // 确保所有的逻辑提前被调用到 LogI($"#2.1 --- InitFacebook ---"); //---------- Start Facebook ------------ FBService.Instance.StartService(); LogI($"#2.2 --- Call SDK init complete -> callback: { (_onCompleteCallback == null ? "Null" : _onCompleteCallback.ToString()) } ---"); + IsInitialSuccess = true; _onCompleteCallback?.Invoke(true); } @@ -141,13 +143,13 @@ namespace Guru /// /// 开始各种组件初始化 /// - private void OnFirebaseReady() + private void OnFirebaseReady(bool success) { - LogI($"#3 --- On FirebaseReady ---"); - IsInitialSuccess = true; - - if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID); ; - + FirebaseUtil.onInitComplete -= OnFirebaseReady; + LogI($"#3 --- On FirebaseDeps:{success} ---"); + Callbacks.SDK._onFirebaseReady?.Invoke(success); + LogFirebaseDeps(success); + LogI($"#3.5 --- Call InitRemoteConfig ---"); // 开始Remote Manager初始化 RemoteConfigManager.Init(BuildDefaultRemoteData(_initConfig.DefaultRemoteData)); From 4fadb2b469b2845a52e45235d91a8be2e4e4a37e Mon Sep 17 00:00:00 2001 From: huyufei Date: Fri, 15 Mar 2024 17:00:40 +0800 Subject: [PATCH 4/9] =?UTF-8?q?update:=20=E6=B7=BB=E5=8A=A0=E5=B9=BF?= =?UTF-8?q?=E5=91=8A=E5=90=AF=E5=8A=A8=E5=88=9D=E5=A7=8B=E5=8C=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.Ads.cs | 33 ++++++++++++++++------------ Runtime/Code/SDK/GuruSDK.Callback.cs | 9 ++++++++ Runtime/Code/SDK/GuruSDK.cs | 3 +++ 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/Runtime/Code/SDK/GuruSDK.Ads.cs b/Runtime/Code/SDK/GuruSDK.Ads.cs index 64c9e46..daf0043 100644 --- a/Runtime/Code/SDK/GuruSDK.Ads.cs +++ b/Runtime/Code/SDK/GuruSDK.Ads.cs @@ -8,21 +8,23 @@ namespace Guru public partial class GuruSDK { - + + private static AdsInitSpec _adInitSpec; + /// /// 启动广告服务 /// - public static void StartAds() + public static void StartAds(AdsInitSpec spec = null) { + _adInitSpec = spec; if (InitConfig.UseCustomConsent) { Debug.Log($"{Tag} --- Call StartAdsWithCustomConsent when you use custom consent, and pass the result (boolean) to the method."); + return; } - else - { - // 默认的启动顺序是先启动Consent后, 根据用户回调的结果来启动广告 - Instance.StartConsentFlow(); - } + + // 默认的启动顺序是先启动Consent后, 根据用户回调的结果来启动广告 + Instance.StartConsentFlow(); } /// @@ -30,7 +32,7 @@ namespace Guru /// /// /// Consent 引导的类型, 如果使用了 MAX 的 consent 请填写 max - public static void StartAdsWithCustomConsent(bool userAllow = true, string guideType = "custom") + public static void StartAdsWithCustomConsent(bool userAllow = true, string guideType = "custom", AdsInitSpec spec = null) { #if UNITY_IOS _attType = guideType; @@ -41,7 +43,7 @@ namespace Guru #if UNITY_IOS CheckAttStatus(); #else - StartAdService(); + StartAdService(spec); #endif } else @@ -87,7 +89,7 @@ namespace Guru private void OnGuruConsentOver(int code) { // 无论状态如何, 都在回调内启动广告初始化 - StartAdService(); + StartAdService(_adInitSpec); // 调用回调 Callbacks.ConsentFlow._onConsentResult?.Invoke(code); @@ -187,11 +189,11 @@ namespace Guru /// /// 启动广告服务 /// - public static void StartAdService() + internal static void StartAdService(AdsInitSpec spec = null) { LogI($"StartAdService"); - ADService.Instance.StartService(OnAdsInitComplete, - InitConfig.AutoLoadWhenAdsReady, IsDebugMode); + if(spec == null) spec = AdsInitSpec.BuildDefault(InitConfig.AutoLoadWhenAdsReady, IsDebugMode); + ADService.Instance.StartService(OnAdsInitComplete, spec); //--------- Callbacks ----------- ADService.OnBannerLoaded = OnBannerLoaded; @@ -203,7 +205,6 @@ namespace Guru private static void OnBannerLoaded() => Callbacks.Ads._onBannerADLoaded?.Invoke(); - private static void OnInterstitialLoaded() => Callbacks.Ads._onInterstitialADLoaded?.Invoke(); private static void OnInterstitialFailed() @@ -323,4 +324,8 @@ namespace Guru #endregion } + + + + } \ No newline at end of file diff --git a/Runtime/Code/SDK/GuruSDK.Callback.cs b/Runtime/Code/SDK/GuruSDK.Callback.cs index 3c7911c..3a6c280 100644 --- a/Runtime/Code/SDK/GuruSDK.Callback.cs +++ b/Runtime/Code/SDK/GuruSDK.Callback.cs @@ -167,6 +167,15 @@ namespace Guru add => _onFirebaseReady += value; remove => _onFirebaseReady -= value; } + + internal static Action _onGuruServiceReady; + public static event Action OnGuruServiceReady + { + add => _onGuruServiceReady += value; + remove => _onGuruServiceReady -= value; + } + + } } diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index 5524e62..4e30de9 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -332,6 +332,9 @@ namespace Guru Debug.LogError($"--- ERROR on StartConsentFlow: {ex.Message}"); }); } + + // 中台服务初始化结束 + Callbacks.SDK._onGuruServiceReady?.Invoke(); } /// From 16a99087d9fbcca88208768c9f91659b7d28d1fe Mon Sep 17 00:00:00 2001 From: huyufei Date: Fri, 15 Mar 2024 17:12:36 +0800 Subject: [PATCH 5/9] =?UTF-8?q?update:=20=E6=B7=BB=E5=8A=A0=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=B9=BF=E5=91=8A=E7=9A=84=E5=BF=AB=E6=8D=B7=E6=96=B9?= =?UTF-8?q?=E5=BC=8F,=20=E5=B9=B6=E4=B8=94=E6=B7=BB=E5=8A=A0=E5=8E=BB?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E6=A0=87=E5=BF=97=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.Ads.cs | 39 +++++++++++++++++++++++++++++---- Runtime/Code/SDK/GuruSDK.IAP.cs | 14 ++++++++++++ Runtime/Code/SDK/GuruSDK.cs | 3 --- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/Runtime/Code/SDK/GuruSDK.Ads.cs b/Runtime/Code/SDK/GuruSDK.Ads.cs index daf0043..e9e774a 100644 --- a/Runtime/Code/SDK/GuruSDK.Ads.cs +++ b/Runtime/Code/SDK/GuruSDK.Ads.cs @@ -27,15 +27,27 @@ namespace Guru Instance.StartConsentFlow(); } + /// + /// 是否已经购买了去广告 + /// + /// + public static void StartAds(bool buyNoAds = false) + { + StartAds(AdsInitSpec.BuildWithNoAds()); // 按照默认的去广告来生成广告启动配置 + } + + /// /// 使用自定义的Consent, 获取用户授权后, 调用此方法 /// /// - /// Consent 引导的类型, 如果使用了 MAX 的 consent 请填写 max - public static void StartAdsWithCustomConsent(bool userAllow = true, string guideType = "custom", AdsInitSpec spec = null) + /// Consent 引导的类型, 如果使用了 MAX 的 consent 请填写 max + /// 广告启动配置 + public static void StartAdsWithCustomConsent(bool userAllow = true, + string consentName = "custom", AdsInitSpec spec = null) { #if UNITY_IOS - _attType = guideType; + _attType = consentName; InitAttStatus(); #endif if (userAllow) @@ -52,6 +64,17 @@ namespace Guru } } + /// + /// 使用自定义的Consent, 获取用户授权后, 调用此方法 + /// + /// 自定义 Consent 的用户授权结果 + /// Consent引导名称 + /// 是否已经购买了去广告 + public static void StartAdsWithCustomConsent(bool userAllow = true, string consentName = "custom", + bool buyNoAds = false) + { + StartAdsWithCustomConsent(userAllow, consentName, AdsInitSpec.BuildWithNoAds()); + } #region Guru Consent @@ -88,6 +111,7 @@ namespace Guru /// private void OnGuruConsentOver(int code) { + // 无论状态如何, 都在回调内启动广告初始化 StartAdService(_adInitSpec); @@ -192,7 +216,14 @@ namespace Guru internal static void StartAdService(AdsInitSpec spec = null) { LogI($"StartAdService"); - if(spec == null) spec = AdsInitSpec.BuildDefault(InitConfig.AutoLoadWhenAdsReady, IsDebugMode); + if (spec == null) + { + spec = AdsInitSpec.BuildDefault(InitConfig.AutoLoadWhenAdsReady, IsDebugMode); + if (ADService.Instance.IsBuyNoAds) + { + spec = AdsInitSpec.BuildWithNoAds(InitConfig.AutoLoadWhenAdsReady, IsDebugMode); + } + } ADService.Instance.StartService(OnAdsInitComplete, spec); //--------- Callbacks ----------- diff --git a/Runtime/Code/SDK/GuruSDK.IAP.cs b/Runtime/Code/SDK/GuruSDK.IAP.cs index 6b130aa..305f634 100644 --- a/Runtime/Code/SDK/GuruSDK.IAP.cs +++ b/Runtime/Code/SDK/GuruSDK.IAP.cs @@ -228,5 +228,19 @@ namespace Guru #endregion + #region Buy NoAds + + + /// + /// 设置购买去广告道具的标志位 + /// + /// + public static void SetBuyNoAds(bool value = true) + { + ADService.Instance.IsBuyNoAds = value; + } + + + #endregion } } \ No newline at end of file diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index 4e30de9..8635e0f 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -245,9 +245,6 @@ namespace Guru if (_appServicesConfig.UseUUID()) { IPMConfig.UsingUUID = true; // 开始使用 UUID 作为 DeviceID 标识 - - - } #if UNITY_IOS From a962f7bb8c46d054451cb1637f13678f248914c5 Mon Sep 17 00:00:00 2001 From: huyufei Date: Mon, 18 Mar 2024 15:03:22 +0800 Subject: [PATCH 6/9] =?UTF-8?q?update:=20=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E5=8F=8A=E5=AF=B9=E5=BA=94=E7=9A=84=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.Ads.cs | 2 +- Runtime/Code/SDK/GuruSDK.cs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Runtime/Code/SDK/GuruSDK.Ads.cs b/Runtime/Code/SDK/GuruSDK.Ads.cs index e9e774a..a2fc020 100644 --- a/Runtime/Code/SDK/GuruSDK.Ads.cs +++ b/Runtime/Code/SDK/GuruSDK.Ads.cs @@ -215,7 +215,7 @@ namespace Guru /// internal static void StartAdService(AdsInitSpec spec = null) { - LogI($"StartAdService"); + LogI($"--- StartAdService :: IsBuyNoAds:{ADService.Instance.IsBuyNoAds}"); if (spec == null) { spec = AdsInitSpec.BuildDefault(InitConfig.AutoLoadWhenAdsReady, IsDebugMode); diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index 8635e0f..c1cc02a 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -201,7 +201,7 @@ namespace Guru private void InitAllServices() { bool useKeywords = false; - bool useIAP = true; + bool useIAP = _initConfig.IAPEnabled; bool appleReview = false; var services = GetRemoteServicesConfig(); @@ -209,8 +209,7 @@ namespace Guru { _appServicesConfig = services; useKeywords = _appServicesConfig.KeywordsEnabled(); - useIAP = _appServicesConfig.IsIAPEnabled(); - + useIAP = _initConfig.IAPEnabled && _appServicesConfig.IsIAPEnabled(); Try(() => { From 01008ca8c7945c1223602534f4a0c3eb054863fb Mon Sep 17 00:00:00 2001 From: huyufei Date: Mon, 18 Mar 2024 15:38:11 +0800 Subject: [PATCH 7/9] =?UTF-8?q?update:=20=E5=BB=B6=E8=BF=9F=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=B9=BF=E5=91=8A=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.Ads.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Runtime/Code/SDK/GuruSDK.Ads.cs b/Runtime/Code/SDK/GuruSDK.Ads.cs index a2fc020..675cb2b 100644 --- a/Runtime/Code/SDK/GuruSDK.Ads.cs +++ b/Runtime/Code/SDK/GuruSDK.Ads.cs @@ -1,5 +1,7 @@ +using System.Threading.Tasks; + namespace Guru { using UnityEngine; @@ -111,9 +113,10 @@ namespace Guru /// private void OnGuruConsentOver(int code) { - + + // StartAdService(_adInitSpec); // 无论状态如何, 都在回调内启动广告初始化 - StartAdService(_adInitSpec); + OnDelayStartAdService(); // 延迟启动广告服务 // 调用回调 Callbacks.ConsentFlow._onConsentResult?.Invoke(code); @@ -132,7 +135,15 @@ namespace Guru break; } } - + + + private async void OnDelayStartAdService() + { + await Task.Delay(2000); + StartAdService(_adInitSpec); + } + + #endregion #region IOS ATT 广告授权流程 From 407e242b8cf9b8f4830dd3503084bac4b651b6e6 Mon Sep 17 00:00:00 2001 From: huyufei Date: Wed, 20 Mar 2024 14:29:43 +0800 Subject: [PATCH 8/9] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=20Firebase=20=E6=9C=8D=E5=8A=A1=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E7=9A=84=E6=A0=87=E5=BF=97=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index c1cc02a..0645403 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -68,6 +68,9 @@ namespace Guru /// public static bool IsInitialSuccess { get; private set; } = false; + + public static bool IsFirebaseReady { get; private set; } = false; + #region 初始化 private static GuruSDK CreateInstance() @@ -147,6 +150,7 @@ namespace Guru { FirebaseUtil.onInitComplete -= OnFirebaseReady; LogI($"#3 --- On FirebaseDeps:{success} ---"); + IsFirebaseReady = success; Callbacks.SDK._onFirebaseReady?.Invoke(success); LogFirebaseDeps(success); From fb492af6335fbf095e6191370f692116a30e942f Mon Sep 17 00:00:00 2001 From: huyufei Date: Wed, 20 Mar 2024 15:40:22 +0800 Subject: [PATCH 9/9] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=20Crashlytics?= =?UTF-8?q?=20=E4=B8=8A=E6=8A=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.Analytics.cs | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Runtime/Code/SDK/GuruSDK.Analytics.cs b/Runtime/Code/SDK/GuruSDK.Analytics.cs index f1fdc27..673157e 100644 --- a/Runtime/Code/SDK/GuruSDK.Analytics.cs +++ b/Runtime/Code/SDK/GuruSDK.Analytics.cs @@ -1,6 +1,9 @@ + + namespace Guru { + using System; using System.Collections.Generic; using UnityEngine; @@ -297,5 +300,32 @@ namespace Guru } #endregion + + #region Crashlytics 接口 + + public static void CrashLog(string message) + { + if (!IsFirebaseReady) return; + CrashlyticsAgent.Log(message); + } + + public static void CrashException(string message) + { + if (!IsFirebaseReady) return; + CrashlyticsAgent.LogException(message); + } + + public static void CrashException(Exception ex) + { + if (!IsFirebaseReady) return; + CrashlyticsAgent.LogException(ex); + } + + public static void CrashCustomKeys(string key, string value) + { + if (!IsFirebaseReady) return; + CrashlyticsAgent.SetCustomKey(key, value); + } + #endregion } } \ No newline at end of file