From b7051d3267e2abdc38b4d0ae8badf3e1aadd04b7 Mon Sep 17 00:00:00 2001 From: huyufei Date: Fri, 15 Mar 2024 17:00:40 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=B7=BB=E5=8A=A0=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E5=88=9D=E5=A7=8B=E5=8C=96=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=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 f3f4754..d24d2a3 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(); } ///