When the subscription expires, the returned purchased is still true, how to solve it
JLLJHD opened this issue · 5 comments
func fetchSubscriptionStatus() async {
for sku in Sku.allCases {
let purchased = (try? await storeHelper.isPurchased(productId: sku.rawValue)) ?? false
if purchased {
subscriptionManager.isSubscribed = purchased
}
}
}
When the subscription expires, the returned purchased is still true, how to solve it
Just tested it using the StoreHelperDemo project. Results were as follows:
- Subscribed to the "silver" product
- Both the "Subscriptions" and "Product List" views correctly show the subscription as active
- Cancelled the subscription
- Both the "Subscriptions" and "Product List" views correctly show the subscription as active but that it will not renew (you can use the product until the end of the subscription period)
- The subscription period expires
- Both the "Subscriptions" and "Product List" views correctly show the subscription as not purchased
So it all looks correct as far as I can see.
How to test the expiration of subscribed sku in sandbox environment
That's more tricky. Obviously, with Xcode StoreKit testing you can set the renewal period of subscriptions to be anything from real-time down to 2 seconds. You can do something similar in the sandbox environment, and you can also cancel a subscription on-device or in App Store Connect.
Have a look at the following:
OK, thank you for your answer
Is it correct to check the subscription status every time the app starts?
for sku in Sku.allCases {
let purchased = (try? await storeHelper?.isPurchased(productId: sku.rawValue)) ?? false
}