Following the sample code from the session, I received errors when verifying the renewal info:
[Default] [StoreKit] Failed to verify certificate chain due to client recoverable failure:
Error Domain=NSOSStatusErrorDomain Code=-67843 "“Test Apple Root CA - G3” certificate is not trusted" UserInfo={NSLocalizedDescription=“Test Apple Root CA - G3” certificate is not trusted, NSUnderlyingError=0x2800835d0 {Error Domain=NSOSStatusErrorDomain Code=-67843 "Certificate 2 “Test Apple Root CA - G3” has errors: Root is not trusted;" UserInfo={NSLocalizedDescription=Certificate 2 “Test Apple Root CA - G3” has errors: Root is not trusted;}}}
[Default] [StoreKit] Failed to verify signature for subscription status, will assume invalid:
failedToVerifyCertificateChain
Here's the code I'm using for getting subscription status
@MainActor
func subscriptionStatus() async -> (Product, Product.SubscriptionInfo.Status)? {
do {
// This app has only one subscription group so products in the subscriptions
// array all belong to the same group. The statuses returned by
// `product.subscription.status` apply to the entire subscription group.
guard let product = subscriptions.first,
let statuses = try await product.subscription?.status else {
return nil
}
var highestSubscriptionStatus: (product: Product, status: Product.SubscriptionInfo.Status)?
for status in statuses {
switch status.state {
case .expired, .revoked:
continue
default:
let renewalInfo = try checkVerified(status.renewalInfo)
guard let newSubscription = subscriptions.first(where: { $0.id == renewalInfo.currentProductID }) else {
continue
}
guard let currentProduct = highestSubscriptionStatus?.product else {
highestSubscriptionStatus = (newSubscription, status)
continue
}
let highestTier = tier(for: currentProduct.id)
let newTier = tier(for: renewalInfo.currentProductID)
if newTier > highestTier {
highestSubscriptionStatus = (newSubscription, status)
}
}
}
return highestSubscriptionStatus
} catch {
print("Could not update subscription status \(error)")
return nil
}
}
I'm running this on a real device without the storekit configuration file. Is this a known issue or am I missing something to get this working?
Thanks