From 957f60e7978162f06a8de0c7853a5bd6f4a1caf4 Mon Sep 17 00:00:00 2001 From: huyufei Date: Fri, 12 Jul 2024 10:29:30 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=20Adjust=20?= =?UTF-8?q?=E7=9A=84=20DeepLink=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1020917 --user=yufei.hu 【中台】【SDK】新增 Adjust Deeplink 接口 https://www.tapd.cn/33527076/s/1156644 --- Runtime/Code/Config/GuruSDKInitConfig.cs | 6 ++++ Runtime/Code/SDK/GuruSDK.Callback.cs | 8 +++++ Runtime/Code/SDK/GuruSDK.cs | 39 ++++++++++++++++++++---- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/Runtime/Code/Config/GuruSDKInitConfig.cs b/Runtime/Code/Config/GuruSDKInitConfig.cs index df86a33..de50086 100644 --- a/Runtime/Code/Config/GuruSDKInitConfig.cs +++ b/Runtime/Code/Config/GuruSDKInitConfig.cs @@ -44,6 +44,10 @@ namespace Guru /// /// public Dictionary DefaultRemoteData = new Dictionary(); + /// + /// 启用 AdjustDeeplink + /// + public bool UseAdjustDeeplink = false; /// /// 支付初始化Keys @@ -65,6 +69,7 @@ namespace Guru bool isBuyNoAds = false, string bannerBackgroundColor = "#00000000", bool debugMode = false, + bool useAdjustDeeplink = false, Dictionary defaultRemoteData = null, byte[] googleKeys = null, byte[] appleRootCerts = null) @@ -79,6 +84,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.Callback.cs b/Runtime/Code/SDK/GuruSDK.Callback.cs index adb01ac..8e1eb56 100644 --- a/Runtime/Code/SDK/GuruSDK.Callback.cs +++ b/Runtime/Code/SDK/GuruSDK.Callback.cs @@ -232,6 +232,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 1ab68c9..bbe8c2b 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -94,6 +94,7 @@ namespace Guru bool autoRecordFinishedLevels = true, bool debugMode = false, bool isBuyNoAds = false, + bool useAdjustDeeplink = false, string bannerColor = "#00000000", Dictionary defaultRemoteData = null, byte[] googleKeys = null, @@ -101,7 +102,7 @@ namespace Guru { var config = GuruSDKInitConfig.Build(useCustomConsent, autoLoadAds, iapEnabled, autoRecordFinishedLevels, isBuyNoAds, bannerColor, - debugMode, defaultRemoteData, googleKeys, appleRootCerts); + debugMode, useAdjustDeeplink, defaultRemoteData, googleKeys, appleRootCerts); return config; } @@ -161,10 +162,7 @@ namespace Guru //---- Start All tools ---- LogI($"#2 --- InitFirebase ---"); //---------- Start Firebase ------------ - FirebaseUtil.onInitComplete += OnFirebaseReady; - FirebaseUtil.OnUserAuthResult += OnUserAuthResult; - FirebaseUtil.OnFirebaseAuthResult += OnFirebaseAuthResult; - FirebaseUtil.InitFirebase(null); // 确保所有的逻辑提前被调用到 + StartFirebaseService(); LogI($"#2.1 --- InitFacebook ---"); //---------- Start Facebook ------------ @@ -174,8 +172,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) { @@ -751,6 +764,20 @@ namespace Guru } + #endregion + + #region Deeplink + + /// + /// 添加回调链接 + /// + /// + private void OnDeeplinkCallback(string deeplink) + { + Callbacks.SDK._onDeeplinkCallback?.Invoke(deeplink); // 尝试调用回调 + } + + #endregion } } \ No newline at end of file