<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ShazamKit",
  "identifier" : "/documentation/ShazamKit/SHManagedSession",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "ShazamKit"
    ],
    "preciseIdentifier" : "s:9ShazamKit16SHManagedSessionC"
  },
  "title" : "SHManagedSession"
}
-->

# SHManagedSession

An object that records and matches a recording with captured sound in the Shazam catalog or your custom catalog.

```
final class SHManagedSession
```

## Overview

This session is an alternative for [`SHSession`](/documentation/ShazamKit/SHSession) if you prefer ShazamKit to manage recording.

There are two main differences between this managed session and the [`SHSession`](/documentation/ShazamKit/SHSession):

- [`SHManagedSession`](/documentation/ShazamKit/SHManagedSession) performs all recording of audio and signature generation.
- [`SHManagedSession`](/documentation/ShazamKit/SHManagedSession) won’t accept audio or Signatures that it didn’t generate.

Matching songs in Shazam requires enabling your app to access the catalog. For more information on enabling your app, see [Enable ShazamKit for an App ID](https://developer.apple.com/help/account/configure-app-services/shazamkit).

The code below shows searching for a match in the Shazam catalog using [`SHManagedSession`](/documentation/ShazamKit/SHManagedSession):

```swift
// Set up the session.
let session = SHManagedSession()

// Check for a match.
let result = await session.result()

// Use the result.
switch result {
  case .match(let match):
       // Match found.
  case .noMatch(let signature):
       // No match found.
  case .error(let error, let signature):
       // An error occurred.
}
```

## Topics

### Creating a managed session object

[`init()`](/documentation/ShazamKit/SHManagedSession/init())

Creates a new managed session object for matching songs in the Shazam Music catalog.

[`init(catalog: SHCatalog)`](/documentation/ShazamKit/SHManagedSession/init(catalog:))

Creates a new managed session object for matching audio in a custom catalog.

### Getting the session state

[`var state: SHManagedSession.State`](/documentation/ShazamKit/SHManagedSession/state-swift.property)

The current state of the managed session.

[`enum State`](/documentation/ShazamKit/SHManagedSession/State-swift.enum)

The state of a managed session.

### Returning queries

[`func result() async -> SHSession.Result`](/documentation/ShazamKit/SHManagedSession/result())

Performs an asynchronous match with a single signature.

[`var results: SHSession.Results`](/documentation/ShazamKit/SHManagedSession/results)

The results as an asynchronous sequence of matches.

[`func cancel()`](/documentation/ShazamKit/SHManagedSession/cancel())

Cancels the currently running match attempt.

[`func prepare() async`](/documentation/ShazamKit/SHManagedSession/prepare())

Preallocates the resources needed for a match, which increases the responsiveness of matches.

## Relationships

### Conforms To

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

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

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

[`Observable`](/documentation/Observation/Observable)

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

---

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)