StoreHelper icon indicating copy to clipboard operation
StoreHelper copied to clipboard

When the subscription expires, the returned purchased is still true, how to solve it

Open JLLJHD opened this issue 1 year ago • 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

JLLJHD avatar Oct 12 '24 06:10 JLLJHD

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.

russell-archer avatar Oct 12 '24 16:10 russell-archer

How to test the expiration of subscribed sku in sandbox environment

JLLJHD avatar Oct 14 '24 09:10 JLLJHD

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:

russell-archer avatar Oct 14 '24 15:10 russell-archer

OK, thank you for your answer

JLLJHD avatar Oct 15 '24 02:10 JLLJHD

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 }

JLLJHD avatar Oct 15 '24 02:10 JLLJHD