I'm currently testing subscriptions in Sandbox. In AppstoreConnect, I set a grace period of 3 days. I subscribed for a service which expired and now it's inBillingRetryPeriod state. I thought it had to do with my payment method. After updating my payment method, it still remains in that state. I am checking Status.RenewalInfo's gracePeriodExpiration
and expirationReason
values produce nil. How do I exit the inBillingRetry state? I'm new to in-app purchases. Thanks. Here's the relevant code:
...
@MainActor
func updateSubscriptionStatus() async {
do {
guard let product = storeManager.renewables.first,
let statuses = try await product.subscription?.status else {return}
var highestProduct: Product? = nil
var highestStatus: Product.SubscriptionInfo.Status? = nil
for status in statuses {
switch status.state {
case .expired, .revoked:
continue
default:
let verifiedRenewalInfo = try storeManager.checkVerified(status.renewalInfo)
//Find the first subscription in the store that matches id on the `status.renewalInfo`
guard let newSubscription = storeManager.renewables.first(where: {$0.id == verifiedRenewalInfo.autoRenewPreference}) else { continue }
guard let currentProduct = highestProduct else {
highestProduct = newSubscription
highestStatus = status
// next status
continue
}
let currentProductTier = storeManager.tierDuration(for: currentProduct.id)
let newTier = storeManager.tierDuration(for: newSubscription.id)
if newTier > currentProductTier {
//updated product and status
highestProduct = newSubscription
highestStatus = status
}
}
}
currentSubscription = highestProduct // currentSubscription is an @State
status = highestStatus // status is an @State
if let mySubcriptionStatus = status,
case .verified(let renewalInfo) = highestStatus?.renewalInfo {
print(mySubcriptionStatus.state) // StoreKit.Product.SubscriptionInfo.RenewalState(rawValue: 3) -- inBillingRetry
print(renewalInfo.expirationReason) // nil
print(renewalInfo.gracePeriodExpirationDate) // nil
}
} catch {
print(error)
}
}