Open simsherpa opened 1 year ago
Thank you for your very helpful review, commentary and example code for these StoreKit changes. They have been very helpful in understanding and using the new views and APIs.
One thing that is still unclear to me is if the new views, apis and .subscriptionStatusTask modifier eliminates the need to persist subscription status using AppStorage, Keychain or App Receipts. Can you share your thoughts on this?
In fact, these persistence methods are still useful. A simple example is, suppose there is a permanently purchased in-app purchase item such as a song. After the purchase is completed, the user can listen to the music at any time. When there is a network, your software verifies if the user purchased this music through network in the background. However, the situation is different when the user is on a plane. In theory, the user can listen to the song when there is no network, because it is a permanent purchase, but your software needs to be connected to the Internet to complete the verification. If you store the purchase results inside the software, users can also listen to the song when there is no network.
Thank you. This is very helpful. Can you provide an example of how to extend the sample code you provided to persist subscription status? Ive looked at a number of tutorials for this but they are not based on the new APIs.
Also, I think I might have found a bug in the code to determine subscription status, but it's possible that I am missing something. I will file a separate issue outlining that.
Thanks again, and any suggestion on how to persist subscription status is appreciated!
Hi, I don't have much time recently, so for the bug review I won't regard it as the first thing but I will review it as soon as possible. You can find the official documentation and official code about SubscriptionView
and StoreKit
in Apple's WWDC23 sample code Backyard Birds: Building an app with SwiftData and widgets. To be honest, the sample code's subscription status won't update once expired, but it still helpful. And if you find any solution to the issue you filed please update the code and pull a request, thanks.
Thanks for the follow-up. Can you explain the following statement?
the sample code's subscription status won't update once expired
Wouldn't the following ProductSubscription status function code fragment catch an expired subscription and report status as .notSubscribed ?
if case .autoRenewable = transaction.productType {
if !(transaction.revocationDate == nil && transaction.revocationReason == nil) {
return .notSubscribed
}
if let subscriptionExpirationDate = transaction.expirationDate {
if subscriptionExpirationDate.timeIntervalSince1970 < Date().timeIntervalSince1970 {
return .notSubscribed
}
}
}
I may be misunderstanding your comment.
Thoughts?
I mean the code from Apple Backyard Birds: Building an app with SwiftData and widgets has one problem that I think it might be a bug. When the subscription expired, the view does not update to the not subscribed view, it still shows the last subscription plan.
I see. Thank you. I'll check it out.
Have you check Apple's code? Any thoughts?
Thank you for your very helpful review, commentary and example code for these StoreKit changes. They have been very helpful in understanding and using the new views and APIs.
One thing that is still unclear to me is if the new views, apis and .subscriptionStatusTask modifier eliminates the need to persist subscription status using AppStorage, Keychain or App Receipts. Can you share your thoughts on this?