From e956b89dd14a43c4693ebad7d89e04d0ea0db432 Mon Sep 17 00:00:00 2001 From: huyufei Date: Thu, 15 Aug 2024 10:50:42 +0800 Subject: [PATCH] =?UTF-8?q?update=EF=BC=9A=20=E6=8E=A5=E5=8F=A3=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=80=A7=E4=BF=AE=E5=A4=8D=EF=BC=8C=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BA=9F=E5=BC=83=E6=8E=A5=E5=8F=A3=E5=A3=B0=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/Config/GuruSDKInitConfig.cs | 128 +++++++++++++++++++++-- Runtime/Code/SDK/GuruSDK.cs | 21 +++- 2 files changed, 137 insertions(+), 12 deletions(-) diff --git a/Runtime/Code/Config/GuruSDKInitConfig.cs b/Runtime/Code/Config/GuruSDKInitConfig.cs index dd280c0..7d57e21 100644 --- a/Runtime/Code/Config/GuruSDKInitConfig.cs +++ b/Runtime/Code/Config/GuruSDKInitConfig.cs @@ -6,7 +6,7 @@ namespace Guru /// /// 启动参数配置 /// - public partial class GuruSDKInitConfig + public class GuruSDKInitConfig { /// /// 使用自定义的ConsentFlow启动流程 @@ -23,7 +23,7 @@ namespace Guru /// /// 自动记录完成的关卡 /// - public bool AutoRecordFinishedLevels = true; + public bool AutoRecordFinishedLevels = false; /// /// 自定义 Service 云控 Key /// @@ -31,7 +31,7 @@ namespace Guru /// /// DeepLink 回调 /// - public Action OnDeeplinkCallback; + public Action OnAdjustDeeplinkCallback; /// /// Banner 背景颜色 Hex 值 /// @@ -62,11 +62,12 @@ namespace Guru /// 构建启动配置 /// /// + [Obsolete("此方法将在下个版本中被废弃, 请直接使用 GuruSDKInitConfig.Builder 来进行初始化。 例如:GuruSDKInitConfig.Builder().SetIsBuyNoAds(true).Build()")] public static GuruSDKInitConfig Build( bool useCustomConsent = false, bool autoLoadAds = true, bool iapEnabled = true, - bool autoRecordFinishedLevels = true, + bool autoRecordFinishedLevels = false, bool isBuyNoAds = false, Action onDeeplinkCallback = null, string bannerBackgroundColor = "#00000000", @@ -87,7 +88,7 @@ namespace Guru DebugMode = debugMode, GoogleKeys = googleKeys, AppleRootCerts = appleRootCerts, - OnDeeplinkCallback = onDeeplinkCallback, + OnAdjustDeeplinkCallback = onDeeplinkCallback, DefaultRemoteData = defaultRemoteData ?? new Dictionary(), }; #if UNITY_EDITOR @@ -107,14 +108,127 @@ namespace Guru sb.AppendLine($"------- Custom init Config -------"); sb.AppendLine($"\tUseCustomConsent: {UseCustomConsent}"); sb.AppendLine($"\tAutoLoadWhenAdsReady: {AutoLoadWhenAdsReady}"); + sb.AppendLine($"\tAutoRecordFinishedLevels: {AutoRecordFinishedLevels}"); + sb.AppendLine($"\tIsBuyNoAds: {IsBuyNoAds}"); + sb.AppendLine($"\tOnDeeplinkCallback: {OnAdjustDeeplinkCallback}"); + sb.AppendLine($"\tDefaultRemoteData: {DefaultRemoteData}"); + sb.AppendLine($"\tGoogleKeys: {GoogleKeys}"); + sb.AppendLine($"\tAppleRootCerts: {AppleRootCerts}"); + sb.AppendLine($"\tDebugMode: {DebugMode}"); sb.AppendLine($"\tIAPEnabled: {IAPEnabled}"); - sb.AppendLine($"\tShowDebugLog: {DebugMode}"); + sb.AppendLine($"\tBannerBackgroundColor: {BannerBackgroundColor}"); + sb.AppendLine($"\tCustomServiceKey: {CustomServiceKey}"); sb.AppendLine($"------- Custom init Config -------"); return sb.ToString(); } + #endregion + + #region Builder + + /// + /// 构造器 + /// + /// + public static GuruSDKInitConfigBuilder Builder() => new GuruSDKInitConfigBuilder(); + #endregion } -} \ No newline at end of file + + /// + /// 构建器 + /// + public class GuruSDKInitConfigBuilder + { + + private GuruSDKInitConfig _config = new GuruSDKInitConfig(); + + /// + /// 构建配置 + /// + /// + public GuruSDKInitConfig Build() + { + return _config; + } + + public GuruSDKInitConfigBuilder SetUseCustomConsent(bool value) + { + _config.UseCustomConsent = value; + return this; + } + public GuruSDKInitConfigBuilder SetAutoLoadWhenAdsReady(bool value) + { + _config.AutoLoadWhenAdsReady = value; + return this; + } + public GuruSDKInitConfigBuilder SetIAPEnabled(bool value) + { + _config.IAPEnabled = value; + return this; + } + public GuruSDKInitConfigBuilder SetAutoRecordFinishedLevels(bool value) + { + _config.AutoRecordFinishedLevels = value; + return this; + } + public GuruSDKInitConfigBuilder SetIsBuyNoAds(bool value) + { + _config.IsBuyNoAds = value; + return this; + } + public GuruSDKInitConfigBuilder SetBannerBackgroundColor(string value) + { + _config.BannerBackgroundColor = value; + return this; + } + public GuruSDKInitConfigBuilder SetDebugMode(bool value) + { + _config.DebugMode = value; + return this; + } + public GuruSDKInitConfigBuilder SetOnAdjustDeeplinkCallback(Action callback) + { + _config.OnAdjustDeeplinkCallback = callback; + return this; + } + public GuruSDKInitConfigBuilder SetGoogleKeys(byte[] value) + { + _config.GoogleKeys = value; + return this; + } + public GuruSDKInitConfigBuilder SetAppleRootCerts(byte[] value) + { + _config.AppleRootCerts = value; + return this; + } + public GuruSDKInitConfigBuilder SetDefaultRemoteData(Dictionary value) + { + _config.DefaultRemoteData = value; + return this; + } + // public GuruSDKInitConfigBuilder SetEnableDebugLogEvent(bool value) + // { + // _config.EnableDebugLogEvent = value; + // return this; + // } + // public GuruSDKInitConfigBuilder SetCustomAnalyticsInitConfig(GuruAnalyticsInitConfig value) + // { + // _config.CustomAnalyticsInitConfig = value; + // return this; + // } + public GuruSDKInitConfigBuilder SetCustomServiceKey(string value) + { + _config.CustomServiceKey = value; + return this; + } + // public GuruSDKInitConfigBuilder SetAutoNotificationPermission(bool value) + // { + // _config.AutoNotificationPermission = value; + // return this; + // } + } +} + diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index c7f8985..124146b 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -87,11 +87,12 @@ namespace Guru return _instance; } + [Obsolete("BuildConfig 方法将在下个版本中被删除。 请使用 GuruInitConfig.Builder().Build() 来进行属性赋值和构造")] public static GuruSDKInitConfig BuildConfig( bool useCustomConsent = false, bool autoLoadAds = true, bool iapEnabled = true, - bool autoRecordFinishedLevels = true, + bool autoRecordFinishedLevels = false, bool debugMode = false, bool isBuyNoAds = false, Action onDeeplinkCallback = null, @@ -100,9 +101,19 @@ namespace Guru byte[] googleKeys = null, byte[] appleRootCerts = null) { - var config = GuruSDKInitConfig.Build(useCustomConsent, autoLoadAds, iapEnabled, - autoRecordFinishedLevels, isBuyNoAds, onDeeplinkCallback, bannerColor, - debugMode, defaultRemoteData, googleKeys, appleRootCerts); + var config = GuruSDKInitConfig.Builder() + .SetUseCustomConsent(useCustomConsent) + .SetAutoLoadWhenAdsReady(autoLoadAds) + .SetIAPEnabled(iapEnabled) + .SetAutoRecordFinishedLevels(autoRecordFinishedLevels) + .SetDebugMode(debugMode) + .SetIsBuyNoAds(isBuyNoAds) + .SetOnAdjustDeeplinkCallback(onDeeplinkCallback) + .SetBannerBackgroundColor(bannerColor) + .SetDefaultRemoteData(defaultRemoteData) + .SetGoogleKeys(googleKeys) + .SetAppleRootCerts(appleRootCerts) + .Build(); return config; } @@ -165,7 +176,7 @@ namespace Guru FirebaseUtil.onInitComplete += OnFirebaseReady; FirebaseUtil.OnUserAuthResult += OnUserAuthResult; FirebaseUtil.OnFirebaseAuthResult += OnFirebaseAuthResult; - FirebaseUtil.InitFirebase(null, InitConfig.OnDeeplinkCallback); // 确保所有的逻辑提前被调用到 + FirebaseUtil.InitFirebase(null, InitConfig.OnAdjustDeeplinkCallback); // 确保所有的逻辑提前被调用到 LogI($"#2.1 --- InitFacebook ---"); //---------- Start Facebook ------------