<!--
{
  "availability" : [
    "iOS: 10.3.0 -",
    "iPadOS: 10.3.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.4 -",
    "tvOS: 10.2.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVContentKeySession",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVContentKeySession"
  },
  "title" : "AVContentKeySession"
}
-->

# AVContentKeySession

An object that creates and tracks decryption keys for media data.

```
class AVContentKeySession
```

## Topics

### Creating a session

[`+  contentKeySessionWithKeySystem:`](/documentation/AVFoundation/AVContentKeySession/init(keySystem:))

Creates a content key session to manage a collection of content decryption keys.

[`+  contentKeySessionWithKeySystem:storageDirectoryAtURL:`](/documentation/AVFoundation/AVContentKeySession/init(keySystem:storageDirectoryAt:))

Creates a content key session to manage a collection of content decryption keys; points to a directory that stores abnormal session termination reports.

### Inspecting the session

[`keySystem`](/documentation/AVFoundation/AVContentKeySession/keySystem)

The type of key system used to retrieve keys.

[`AVContentKeySystem`](/documentation/AVFoundation/AVContentKeySystem)

A key-delivery method for a content key session.

[`storageURL`](/documentation/AVFoundation/AVContentKeySession/storageURL)

A URL that points to a writable storage directory.

### Managing the delegate object

[`-  setDelegate:queue:`](/documentation/AVFoundation/AVContentKeySession/setDelegate(_:queue:))

Sets the session’s delegate object and the dispatch queue on which to call the delegate’s methods.

[`delegate`](/documentation/AVFoundation/AVContentKeySession/delegate)

The content key session’s delegate object.

[`delegateQueue`](/documentation/AVFoundation/AVContentKeySession/delegateQueue)

The dispatch queue the session uses to invoke delegate callbacks.

### Managing content key recipients

[`contentKeyRecipients`](/documentation/AVFoundation/AVContentKeySession/contentKeyRecipients)

An array of content key recipients.

[`AVContentKeyRecipient`](/documentation/AVFoundation/AVContentKeyRecipient)

A protocol for requiring decryption keys for media data.

[`-  addContentKeyRecipient:`](/documentation/AVFoundation/AVContentKeySession/addContentKeyRecipient(_:))

Tells the delegate that the specified recipient should have access to the decryption keys loaded with the session.

[`-  removeContentKeyRecipient:`](/documentation/AVFoundation/AVContentKeySession/removeContentKeyRecipient(_:))

Tells the delegate to remove the specified recipient.

### Processing requests

[`-  processContentKeyRequestWithIdentifier:initializationData:options:`](/documentation/AVFoundation/AVContentKeySession/processContentKeyRequest(withIdentifier:initializationData:options:))

Tells the delegate to start loading the content decryption key with the specified identifier and initialization data.

### Managing expiration

[`-  expire`](/documentation/AVFoundation/AVContentKeySession/expire())

Tells the delegate that the session expired as the result of normal, intentional processes.

[`-  makeSecureTokenForExpirationDateOfPersistableContentKey:completionHandler:`](/documentation/AVFoundation/AVContentKeySession/makeSecureTokenForExpirationDate(ofPersistableContentKey:completionHandler:))

Creates a secure server playback context that the client sends to the key server to get an expiration date for the given persistable content key data.

[`-  renewExpiringResponseDataForContentKeyRequest:`](/documentation/AVFoundation/AVContentKeySession/renewExpiringResponseData(for:))

Tells the delegate that previously provided response data for a content key request is about to expire.

[`contentProtectionSessionIdentifier`](/documentation/AVFoundation/AVContentKeySession/contentProtectionSessionIdentifier)

The identifier for the current content protection session.

### Invalidating content keys

[`-  invalidatePersistableContentKey:options:completionHandler:`](/documentation/AVFoundation/AVContentKeySession/invalidatePersistableContentKey(_:options:completionHandler:))

Invalidates the persistable content key and creates a secure server playback context (SPC) to verify the outcome of an invalidation request.

[`-  invalidateAllPersistableContentKeysForApp:options:completionHandler:`](/documentation/AVFoundation/AVContentKeySession/invalidateAllPersistableContentKeys(forApp:options:completionHandler:))

Invalidates all of an app’s persistable content keys and creates a secure server playback context (SPC) to verify the outcome of an invalidation request.

[`AVContentKeySessionServerPlaybackContextOption`](/documentation/AVFoundation/AVContentKeySessionServerPlaybackContextOption)

Options for specifying additional information for generating server playback context (SPC).

### Handling expired session reports

[`+  pendingExpiredSessionReportsWithAppIdentifier:storageDirectoryAtURL:`](/documentation/AVFoundation/AVContentKeySession/pendingExpiredSessionReports(withAppIdentifier:storageDirectoryAt:))

Returns the expired session reports for content key sessions created with the specified app identifier.

[`+  removePendingExpiredSessionReports:withAppIdentifier:storageDirectoryAtURL:`](/documentation/AVFoundation/AVContentKeySession/removePendingExpiredSessionReports(_:withAppIdentifier:storageDirectoryAt:))

Removes expired session reports from storage.

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)