update: Json 解析添加 TryCatch

deeplink
胡宇飞 2024-03-18 15:19:44 +08:00
parent a056a5c23d
commit 7bd9413a83
2 changed files with 49 additions and 33 deletions

View File

@ -1,5 +1,7 @@
using System;
namespace Guru namespace Guru
{ {
using System.Text; using System.Text;
@ -49,24 +51,31 @@ namespace Guru
protected override void RequestSuccessCallBack(string response) protected override void RequestSuccessCallBack(string response)
{ {
ResponseData<OrderResponse> responseData = JsonUtility.FromJson<ResponseData<OrderResponse>>(response); try
if (responseData != null && responseData.data != null)
{ {
double usdPrice = responseData.data.usdPrice; ResponseData<OrderResponse> responseData = JsonUtility.FromJson<ResponseData<OrderResponse>>(response);
Analytics.Tch001IAPRev(usdPrice); if (responseData != null && responseData.data != null)
Analytics.Tch02IAPRev(usdPrice);
if (orderType == 0)
{ {
AdjustService.TrackIAPPurchase(usdPrice, productId); double usdPrice = responseData.data.usdPrice;
Analytics.IAPPurchase(usdPrice, productId); Analytics.Tch001IAPRev(usdPrice);
Analytics.Tch02IAPRev(usdPrice);
if (orderType == 0)
{
AdjustService.TrackIAPPurchase(usdPrice, productId);
Analytics.IAPPurchase(usdPrice, productId);
}
else if (orderType == 1)
{
AdjustService.TrackSubPurchase(usdPrice, productId);
Analytics.SubPurchase(usdPrice, productId);
}
} }
else if (orderType == 1)
{
AdjustService.TrackSubPurchase(usdPrice, productId);
Analytics.SubPurchase(usdPrice, productId);
}
} }
catch (Exception ex)
{
Analytics.LogCrashlytics(ex);
}
} }
} }
} }

View File

@ -1,3 +1,4 @@
using System;
using System.Text; using System.Text;
using Guru.LitJson; using Guru.LitJson;
using UnityEngine; using UnityEngine;
@ -48,31 +49,37 @@ namespace Guru
protected override void RequestSuccessCallBack(string response) protected override void RequestSuccessCallBack(string response)
{ {
ResponseData<OrderResponse> responseData = JsonUtility.FromJson<ResponseData<OrderResponse>>(response); try
if (responseData != null && responseData.data != null)
{ {
// Analytics.Tch001IAPRev(responseData.data.usdPrice); ResponseData<OrderResponse> responseData = JsonUtility.FromJson<ResponseData<OrderResponse>>(response);
double usdPrice = responseData.data.usdPrice; if (responseData != null && responseData.data != null)
Analytics.Tch001IAPRev(usdPrice);
Analytics.Tch02IAPRev(usdPrice);
string pid = "";
if (!string.IsNullOrEmpty(productId))
{ {
pid = productId; // Analytics.Tch001IAPRev(responseData.data.usdPrice);
AdjustService.TrackIAPPurchase(usdPrice, productId); // 上报 IAP 支付事件 double usdPrice = responseData.data.usdPrice;
Analytics.IAPPurchase(usdPrice, pid); Analytics.Tch001IAPRev(usdPrice);
} Analytics.Tch02IAPRev(usdPrice);
if (!string.IsNullOrEmpty(subscriptionId)) string pid = "";
{
pid = subscriptionId; if (!string.IsNullOrEmpty(productId))
AdjustService.TrackSubPurchase(usdPrice, productId); // 上报 订阅 支付事件 {
Analytics.SubPurchase(usdPrice, productId); pid = productId;
AdjustService.TrackIAPPurchase(usdPrice, productId); // 上报 IAP 支付事件
Analytics.IAPPurchase(usdPrice, pid);
}
if (!string.IsNullOrEmpty(subscriptionId))
{
pid = subscriptionId;
AdjustService.TrackSubPurchase(usdPrice, productId); // 上报 订阅 支付事件
Analytics.SubPurchase(usdPrice, productId);
}
} }
} }
catch (Exception ex)
{
Analytics.LogCrashlytics(ex);
}
} }