I'm creating a standalone WatchOS app using StoreKit 2. The code I have for making the purchase and checking the subscription status works under iOS 15. On WatchOS 8, after confirming the purchase, the product.subscription.status array is empty. I'm testing using the Xcode sandbox and I can see the purchase transaction there. I've talked with an Apple engineer and they think it may be a bug in WatchOS, but I'm reaching out here to see if anyone else has encountered this issue.
Here's a code snippet:
guard let product = store.subscriptions.first else { print("No Subscriptions"); return }
guard let sub = product.subscription else { print("Not Subscription",product.id); return }
let statuses = try await sub.status
After the purchase, statuses has a value on iOS 15, but it's empty on WatchOS 8.
"store" is my object to deal with StoreKit. Here's some relevant code that populates the store.subscriptions array.
class Store: ObservableObject {
@Published private(set) var subscriptions: [Product]
@MainActor
func requestProducts() async {
do {
//... keys are my product identifiers
let storeProducts = try await Product.products(for: keys)
for product in storeProducts {
switch product.type {
// [snip]
case .autoRenewable:
newSubscriptions.append(product)
}
}
subscriptions = sortByPrice(newSubscriptions)
}
// [snip]
}
}
I have tested this with Xcode 13.1 and 13.2b2.