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(); } ///