diff --git a/Runtime/Code/Config/GuruSDKInitConfig.cs b/Runtime/Code/Config/GuruSDKInitConfig.cs index 0662e43..c57a14c 100644 --- a/Runtime/Code/Config/GuruSDKInitConfig.cs +++ b/Runtime/Code/Config/GuruSDKInitConfig.cs @@ -48,6 +48,10 @@ namespace Guru /// /// public Dictionary DefaultRemoteData = new Dictionary(); + /// + /// 启用 AdjustDeeplink + /// + public bool UseAdjustDeeplink = false; /// /// 支付初始化Keys @@ -69,6 +73,7 @@ namespace Guru bool isBuyNoAds = false, string bannerBackgroundColor = "#00000000", bool debugMode = false, + bool useAdjustDeeplink = false, Dictionary defaultRemoteData = null, byte[] googleKeys = null, byte[] appleRootCerts = null) @@ -83,6 +88,7 @@ namespace Guru IsBuyNoAds = isBuyNoAds, BannerBackgroundColor = bannerBackgroundColor, DebugMode = debugMode, + UseAdjustDeeplink = useAdjustDeeplink, GoogleKeys = googleKeys, AppleRootCerts = appleRootCerts, DefaultRemoteData = defaultRemoteData ?? new Dictionary(), diff --git a/Runtime/Code/SDK/GuruSDK.Callbacks.cs b/Runtime/Code/SDK/GuruSDK.Callbacks.cs index dea014c..2c7b1d9 100644 --- a/Runtime/Code/SDK/GuruSDK.Callbacks.cs +++ b/Runtime/Code/SDK/GuruSDK.Callbacks.cs @@ -249,6 +249,14 @@ namespace Guru } + // DeepLink 回调 + internal static Action _onDeeplinkCallback; + public static event Action OnDeeplinkCallback + { + add => _onDeeplinkCallback += value; + remove => _onDeeplinkCallback -= value; + } + } } diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index ba2ca8c..50ddb87 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -95,6 +95,7 @@ namespace Guru bool autoRecordFinishedLevels = true, bool debugMode = false, bool isBuyNoAds = false, + bool useAdjustDeeplink = false, string bannerColor = "#00000000", Dictionary defaultRemoteData = null, byte[] googleKeys = null, @@ -102,7 +103,7 @@ namespace Guru { var config = GuruSDKInitConfig.Build(useCustomConsent, autoLoadAds, iapEnabled, autoRecordFinishedLevels, isBuyNoAds, bannerColor, - debugMode, defaultRemoteData, googleKeys, appleRootCerts); + debugMode, useAdjustDeeplink, defaultRemoteData, googleKeys, appleRootCerts); return config; } @@ -162,10 +163,7 @@ namespace Guru //---- Start All tools ---- LogI($"#2 --- InitFirebase ---"); //---------- Start Firebase ------------ - FirebaseUtil.onInitComplete += OnFirebaseReady; - FirebaseUtil.OnUserAuthResult += OnUserAuthResult; - FirebaseUtil.OnFirebaseAuthResult += OnFirebaseAuthResult; - FirebaseUtil.InitFirebase(null); // 确保所有的逻辑提前被调用到 + Analytics.Init TODO:之后需要改为事件驱动 + StartFirebaseService(); LogI($"#2.1 --- InitFacebook ---"); //---------- Start Facebook ------------ @@ -175,8 +173,23 @@ namespace Guru IsInitialSuccess = true; _onCompleteCallback?.Invoke(true); } - + /// + /// 启动 Firebase 服务 + /// + private void StartFirebaseService() + { + FirebaseUtil.onInitComplete += OnFirebaseReady; + FirebaseUtil.OnUserAuthResult += OnUserAuthResult; + FirebaseUtil.OnFirebaseAuthResult += OnFirebaseAuthResult; + + if (InitConfig.UseAdjustDeeplink) + { + FirebaseUtil.OnAdjustDeeplinkCallback = OnDeeplinkCallback; // 挂载 Deeplink 的回调 + } + + FirebaseUtil.InitFirebase(null); // 确保所有的逻辑提前被调用到 + } private void OnUserAuthResult(bool success) { @@ -757,6 +770,20 @@ namespace Guru request.Send(); } } + #endregion + + #region Deeplink + + /// + /// 添加回调链接 + /// + /// + private void OnDeeplinkCallback(string deeplink) + { + Callbacks.SDK._onDeeplinkCallback?.Invoke(deeplink); // 尝试调用回调 + } + + #endregion }