update: 修复IOS 打包报错的问题

deeplink
huyufei 2024-03-17 22:22:58 +08:00
parent c9301aa45e
commit fdf1dd7c0e
2 changed files with 15 additions and 12 deletions

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 811ed48c0c0a487486c74abd56463199
timeCreated: 1709268219

View File

@ -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<T>: IStoreListener where T: IAPServiceBase<T> , 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<JObject>(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}"));
}
}