StoreKitError.unknown when resuming subscription

Hi everyone,

I'm encountering an issue with StoreKit 2 and subscriptions that I hope someone can help clarify.

Here's the scenario:

  1. A user purchases a subscription.
  2. The user cancels the subscription in their Apple ID settings (it remains active until the end of the billing period).
  3. While the subscription is still active, the user reopens the app and tries to repurchase the same subscription.

The problem:

  • The purchase() method start well a new billing flow, but once confirmed throws a StoreKitError.unknown.
  • Despite this error, the subscription gets re-enabled and appears active again in the currentEntitlements.

So my question is why the purchase method throw an error and how to deal with this case ?

I precise I'm currently only working in sandbox, maybe the behavior is different in production (but even in that case there is still a bug in Sandbox that should not happen). Also in that case the Apple Server Notification API send the webhook with type DID_CHANGE_RENEWAL_STATUS (and subtype AUTO_RENEW_ENABLED), which is expected.

Thanks for help, Gregoire.

StoreKitError.unknown when resuming subscription
 
 
Q