What is the correct way how to get the renewalDate for subscription?
In documentation for Product.SubscriptionInfo.RenewalInfo is defined renewalDate
, but in code there is no such property available.
Only serialisation to json mention this field.
if let item = try await products[sku]?.subscription?.status.first {
if let verificationResult = item.renewalInfo as? VerificationResult<Product.SubscriptionInfo.RenewalInfo> {
let renewalInfo = try verificationResult.payloadValue
print(renewalInfo.jsonRepresentation)
print(renewalInfo)
}
}
output:
{
"originalTransactionId":"2000000425656293",
"autoRenewProductId":"product_A",
"productId":"product_B",
"autoRenewStatus":1,
"deviceVerification":"1234dummy",
"deviceVerificationNonce":"00aecdummy",
"signedDate":1696340799858,
"environment":"Sandbox",
"recentSubscriptionStartDate":1696335733000,
"renewalDate":1696341133000
}
But for
let renewalInfo = try verificationResult.payloadValue
print(renewalInfo.renewalDate)
the error is Value of type 'Product.SubscriptionInfo.RenewalInfo' has no member 'renewalDate'
.
context: XCode 14.2, Storekit2, iOS 15+
PS: Also there are other super confusing thing: autoRenewPreference
is in the jsonRepresentation as autoRenewProductId
.
Hello, thank you for reaching out. Please download and use Xcode 15 and your code should compile and run successfully. Also, if you are interested in the json representation, find more information about the field names in https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfodecodedpayload