From 16a99087d9fbcca88208768c9f91659b7d28d1fe Mon Sep 17 00:00:00 2001 From: huyufei Date: Fri, 15 Mar 2024 17:12:36 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=B7=BB=E5=8A=A0=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E7=9A=84=E5=BF=AB=E6=8D=B7=E6=96=B9=E5=BC=8F?= =?UTF-8?q?,=20=E5=B9=B6=E4=B8=94=E6=B7=BB=E5=8A=A0=E5=8E=BB=E5=B9=BF?= =?UTF-8?q?=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