如何查看苹果收据的有效期?
How to check expiration date of apple receipt?
我正在使用 expo-in-app-purchase.in 在 react-native.am 中使用应用内购买来验证应用商店的收据我得到这样的东西:
result [
{
.........................
purchase_date: '2021-05-03 11:34:17 Etc/GMT',
purchase_date_ms: '1620041657000',
purchase_date_pst: '2021-05-03 04:34:17 America/Los_Angeles',
original_purchase_date: '2021-05-03 11:33:20 Etc/GMT',
original_purchase_date_ms: '1620041600000',
original_purchase_date_pst: '2021-05-03 04:33:20 America/Los_Angeles',
expires_date: '2021-05-03 11:39:17 Etc/GMT',
expires_date_ms: '1620041957000',
expires_date_pst: '2021-05-03 04:39:17 America/Los_Angeles',
...............................................
}
]
pending_renewal_info:[{
expiration_intent: '1',
auto_renew_product_id: '******************',
is_in_billing_retry_period: '0',
product_id: '****************************',
original_transaction_id: '1000000785803993',
auto_renew_status: '0'
}]
然后我会像这样检查订阅的到期时间:
const expirationDate = result.data.latest_receipt_info[0].expires_date_ms,
expiry=Date.now() > expirationDate;//it is always true.
过期总是正确的,因为苹果给出的日期比我的 date.ie 早 5 小时,如果我在 2021-05-04 10:00:00 这个日期购买东西,在苹果收据中过期日期显示类似 2021-05-04 5:00:00.ie 5 小时 behind.then 我如何查看收据过期时间?
这应该有效
const expirationDate = parseInt(result.data.latest_receipt_info[0].expires_date_ms);
// Need to parse it to Int as it is in string format originally
const expirationDateObject = new Date(expirationDate);
const current = Date.now();
const currentDateObj = new Date(current);
const isExpired = currentDateObj.getTime() > expirationDateObject.getTime()
console.log(isExpired);
我正在使用 expo-in-app-purchase.in 在 react-native.am 中使用应用内购买来验证应用商店的收据我得到这样的东西:
result [
{
.........................
purchase_date: '2021-05-03 11:34:17 Etc/GMT',
purchase_date_ms: '1620041657000',
purchase_date_pst: '2021-05-03 04:34:17 America/Los_Angeles',
original_purchase_date: '2021-05-03 11:33:20 Etc/GMT',
original_purchase_date_ms: '1620041600000',
original_purchase_date_pst: '2021-05-03 04:33:20 America/Los_Angeles',
expires_date: '2021-05-03 11:39:17 Etc/GMT',
expires_date_ms: '1620041957000',
expires_date_pst: '2021-05-03 04:39:17 America/Los_Angeles',
...............................................
}
]
pending_renewal_info:[{
expiration_intent: '1',
auto_renew_product_id: '******************',
is_in_billing_retry_period: '0',
product_id: '****************************',
original_transaction_id: '1000000785803993',
auto_renew_status: '0'
}]
然后我会像这样检查订阅的到期时间:
const expirationDate = result.data.latest_receipt_info[0].expires_date_ms,
expiry=Date.now() > expirationDate;//it is always true.
过期总是正确的,因为苹果给出的日期比我的 date.ie 早 5 小时,如果我在 2021-05-04 10:00:00 这个日期购买东西,在苹果收据中过期日期显示类似 2021-05-04 5:00:00.ie 5 小时 behind.then 我如何查看收据过期时间?
这应该有效
const expirationDate = parseInt(result.data.latest_receipt_info[0].expires_date_ms);
// Need to parse it to Int as it is in string format originally
const expirationDateObject = new Date(expirationDate);
const current = Date.now();
const currentDateObj = new Date(current);
const isExpired = currentDateObj.getTime() > expirationDateObject.getTime()
console.log(isExpired);