<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "StoreKitTest",
  "identifier" : "/documentation/StoreKitTest/SKTestSession/expireSubscription(productIdentifier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "StoreKit Test"
    ],
    "preciseIdentifier" : "c:objc(cs)SKTestSession(im)expireSubscriptionWithProductIdentifier:error:"
  },
  "title" : "expireSubscription(productIdentifier:)"
}
-->

# expireSubscription(productIdentifier:)

Causes the identified auto-renewable subscription to expire immediately in the test environment.

```
func expireSubscription(productIdentifier: String) throws
```

## Parameters

`productIdentifier`

The [`productIdentifier`](/documentation/StoreKitTest/SKTestTransaction/productIdentifier) of the auto-renewable subscription to expire.

## Discussion

Use this method to test how your app handles expired subscriptions and revoking access to content or service. This method forces the subscription to expire. Specifically, the testing environment disables auto-renew and changes the subscription’s expiration date to the current system time.

You can also test subscription expiration by accelerating the time in the testing environment to speed up subscription renewal periods. See [`timeRate`](/documentation/StoreKitTest/SKTestSession/timeRate-swift.property) for more information.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)