From ffff79d01291957f674bb18a4da15c88adae6f31 Mon Sep 17 00:00:00 2001 From: huyufei Date: Fri, 8 Mar 2024 17:05:36 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E5=A2=9E=E5=8A=A0=E6=89=93=E7=82=B9?= =?UTF-8?q?=E6=B5=8B=E8=AF=95SDK=20=E5=88=9D=E5=A7=8B=E5=8C=96=E4=B8=AD?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/SDK/GuruSDK.cs | 143 +++++++++++++++++++++++++++--------- 1 file changed, 107 insertions(+), 36 deletions(-) diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index b960e90..ad0166d 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -213,72 +213,121 @@ namespace Guru useKeywords = _appServicesConfig.KeywordsEnabled(); useIAP = _appServicesConfig.IsIAPEnabled(); - - if (null != _appServicesConfig.adjust_settings && null != GuruSettings) - { - // 更新 Adjust Tokens - GuruSettings.UpdateAdjustTokens( - _appServicesConfig.adjust_settings.AndroidToken(), - _appServicesConfig.adjust_settings.iOSToken()); - // 更新 Adjust Events - GuruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events); - } - if (null != _appServicesConfig.app_settings) + Try(() => { - if (_appServicesConfig.Tch02Value() > 0) + LogI($"--- Init apply services ---"); + //-------------------------------- + + if (null != _appServicesConfig.adjust_settings && null != GuruSettings) { - Analytics.EnableTch02Event = true; - Analytics.SetTch02TargetValue(_appServicesConfig.Tch02Value()); + // 更新 Adjust Tokens + GuruSettings.UpdateAdjustTokens( + _appServicesConfig.adjust_settings.AndroidToken(), + _appServicesConfig.adjust_settings.iOSToken()); + // 更新 Adjust Events + GuruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events); } + + if (null != _appServicesConfig.app_settings) + { + if (_appServicesConfig.Tch02Value() > 0) + { + Analytics.EnableTch02Event = true; + Analytics.SetTch02TargetValue(_appServicesConfig.Tch02Value()); + } - // 设置获取设备 UUID 的方法 - if (_appServicesConfig.UseUUID()) - { - IPMConfig.UsingUUID = true; // 开始使用 UUID 作为 DeviceID 标识 - } + // 设置获取设备 UUID 的方法 + if (_appServicesConfig.UseUUID()) + { + IPMConfig.UsingUUID = true; // 开始使用 UUID 作为 DeviceID 标识 + } #if UNITY_IOS // 苹果审核标志位 appleReview = _appServicesConfig.IsAppReview(); #endif - if (null != GuruSettings) - { - // 更新和升级 GuruSettings 对应的值 - GuruSettings.UpdateAppSettings( - _appServicesConfig.app_settings.bundle_id, - _appServicesConfig.fb_settings?.fb_app_id ?? "", - _appServicesConfig.app_settings.support_email, - _appServicesConfig.app_settings.privacy_url, - _appServicesConfig.app_settings.terms_url, - _appServicesConfig.app_settings.android_store, - _appServicesConfig.app_settings.ios_store); + if (null != GuruSettings) + { + // 更新和升级 GuruSettings 对应的值 + GuruSettings.UpdateAppSettings( + _appServicesConfig.app_settings.bundle_id, + _appServicesConfig.fb_settings?.fb_app_id ?? "", + _appServicesConfig.app_settings.support_email, + _appServicesConfig.app_settings.privacy_url, + _appServicesConfig.app_settings.terms_url, + _appServicesConfig.app_settings.android_store, + _appServicesConfig.app_settings.ios_store); + } } - } + + + + //--------------------------------- + }, ex => + { + Debug.LogError($"--- ERROR on apply services: {ex.Message}"); + }); + + } if (useIAP) { - InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP + // InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP + Try(() => + { + LogI($"--- Init IAP ---"); + InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP + }, ex => + { + Debug.LogError($"--- ERROR on useIAP: {ex.Message}"); + }); + } if (useKeywords) { - KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器 + // KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器 + Try(() => + { + LogI($"--- Init Keywords ---"); + KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器 + }, ex => + { + Debug.LogError($"--- ERROR on Keywords: {ex.Message}"); + }); } #if UNITY_IOS if (appleReview) { - StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程 + // StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程 + Try(() => + { + LogI($"--- StartAppleReviewFlow ---"); + StartAppleReviewFlow(); // 直接显示 ATT 弹窗, 跳过 Consent 流程 + }, ex => + { + Debug.LogError($"--- ERROR on StartAppleReviewFlow: {ex.Message}"); + }); + } return; } #endif if (!InitConfig.UseCustomConsent && !appleReview) { // LogI($"--- #3 Start Consent Flow ---"); - StartConsentFlow(); + // StartConsentFlow(); + Try(() => + { + LogI($"--- StartConsentFlow ---"); + StartConsentFlow(); + }, ex => + { + Debug.LogError($"--- ERROR on StartConsentFlow: {ex.Message}"); + }); } } @@ -291,7 +340,29 @@ namespace Guru } return null; } - + + private void Try(Action method, Action onException = null, Action onFinal = null) + { + if (method == null) return; + + try + { + method.Invoke(); + } + catch (Exception ex) + { + LogException(ex); + // ignored + onException?.Invoke(ex); + } + finally + { + // Finally + onFinal?.Invoke(); + } + } + + #endregion #region Apple 审核流程逻辑