From fdf1dd7c0efb993be2593c951e1f45c3d3b92a73 Mon Sep 17 00:00:00 2001 From: huyufei Date: Sun, 17 Mar 2024 22:22:58 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E4=BF=AE=E5=A4=8DIOS=20=E6=89=93?= =?UTF-8?q?=E5=8C=85=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/GuruAds/Common.meta | 3 --- .../GuruIAP/Runtime/Code/IAPServiceBase.cs | 24 ++++++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) delete mode 100644 Runtime/GuruAds/Common.meta diff --git a/Runtime/GuruAds/Common.meta b/Runtime/GuruAds/Common.meta deleted file mode 100644 index d6e7b7c..0000000 --- a/Runtime/GuruAds/Common.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 811ed48c0c0a487486c74abd56463199 -timeCreated: 1709268219 \ No newline at end of file diff --git a/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs b/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs index b40d318..f99852b 100644 --- a/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs +++ b/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs @@ -1,3 +1,4 @@ + namespace Guru { using System; @@ -6,7 +7,8 @@ namespace Guru using UnityEngine.Purchasing; using UnityEngine.Purchasing.Security; using System.Collections.Generic; - using Firebase.Crashlytics; + using Newtonsoft.Json; + using Newtonsoft.Json.Linq; public abstract class IAPServiceBase: IStoreListener where T: IAPServiceBase , new() { @@ -430,7 +432,7 @@ namespace Guru } else { - Crashlytics.LogException(new Exception($"[IAP] Init Validator failed -> googlePublicKey: {_googlePublicKey} appleRootCert: {_appleRootCert}")); + Analytics.LogCrashlytics(new Exception($"[IAP] Init Validator failed -> googlePublicKey: {_googlePublicKey} appleRootCert: {_appleRootCert}")); } } catch (NotImplementedException exception) @@ -574,7 +576,7 @@ namespace Guru { string msg = $"{Tag} --- Purchased product is null or has no receipt!!"; Debug.LogError(msg); - Crashlytics.LogException(new Exception(msg)); + Analytics.LogCrashlytics(new Exception(msg)); } else { @@ -700,7 +702,7 @@ namespace Guru { // Debug.Log($"############ --- Validator is null"); LogE($"{Tag} --- Validator is null. Report Order failed."); - Crashlytics.LogException(new Exception($"IAPService can not report order because Validator is null!")); + Analytics.LogCrashlytics(new Exception($"IAPService can not report order because Validator is null!")); return; } @@ -730,8 +732,14 @@ namespace Guru } #elif UNITY_IOS // iOS 订单验证, 上报打点信息 - var jsonData = JsonMapper.ToObject(args.purchasedProduct.receipt); - string receipt = jsonData["Payload"].ToString(); + var jsonData = JsonConvert.DeserializeObject(args.purchasedProduct.receipt); + if (jsonData.TryGetValue("Payload", out var receipt)) + { + ReportAppleOrder(orderType, args.purchasedProduct.definition.id, receipt.ToString(),blevel); + Debug.Log($"{Tag} --- Report iOS IAP Order -> orderType:{orderType} productID:{args.purchasedProduct.definition.id} blevel:{blevel}"); + } + + // string receipt = jsonData["Payload"].ToString(); // if (HasReceipt(receipt)) // { // Debug.Log($"[IAP] Receipt has already reported: {receipt}"); @@ -739,14 +747,12 @@ namespace Guru // } // AddReceipt(receipt); // new AppleOrderRequest(orderType, args.purchasedProduct.definition.id, receipt,blevel).Send(); - ReportAppleOrder(orderType, args.purchasedProduct.definition.id, receipt,blevel); - Debug.Log($"{Tag} --- Report iOS IAP Order -> orderType:{orderType} productID:{args.purchasedProduct.definition.id} blevel:{blevel}"); #endif } catch (Exception e) { LogE($" [IAPManager.RevenueUpload] got Exception: {e.Message}"); - Crashlytics.LogException(new Exception($"[IAP] Unity report purchase data with b_level={blevel} got error: {e.Message}")); + Analytics.LogCrashlytics(new Exception($"[IAP] Unity report purchase data with b_level={blevel} got error: {e.Message}")); } }