---
title: "expireSubscription(productIdentifier:)"
framework: storekittest
role: symbol
role_heading: Instance Method
path: "storekittest/sktestsession/expiresubscription(productidentifier:)"
---

# expireSubscription(productIdentifier:)

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

## Declaration

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

## Parameters

- `productIdentifier`: The doc://com.apple.storekittest/documentation/StoreKitTest/SKTestTransaction/productIdentifier of the auto-renewable subscription to expire.

## Discussion

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 for more information.

## See Also

### Testing subscription renewals

- [timeRate](storekittest/sktestsession/timerate-swift.property.md)
- [SKTestSession.TimeRate](storekittest/sktestsession/timerate-swift.enum.md)
- [enableAutoRenewForTransaction(identifier:)](storekittest/sktestsession/enableautorenewfortransaction(identifier:).md)
- [disableAutoRenewForTransaction(identifier:)](storekittest/sktestsession/disableautorenewfortransaction(identifier:).md)
- [forceRenewalOfSubscription(productIdentifier:)](storekittest/sktestsession/forcerenewalofsubscription(productidentifier:).md)
