One Logo Pool Ball
ShazamKit · IOS API REFERENCE

SHManagedSession

class · iOS 17.0+ · SDK 27.1

final class SHManagedSession

An object that records and matches a recording with captured sound in the Shazam catalog or your custom catalog. This session is an alternative for ``SHSession`` if you prefer ShazamKit to manage recording. There are two main differences between this managed session and the ``SHSession``: - ``SHManagedSession`` performs all recording of audio and signature generation. - ``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``: ```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. } ```

Members (7)

get · iOS 17.0+

state

TypeScript
get state(): Promise<SHManagedSession_State>
Swift declaration
@MainActor final var state: SHManagedSession.State { get }

The current state of the managed session.

method · iOS 17.0+

cancel

TypeScript
cancel(): void
Swift declaration
final func cancel()

Cancels the currently running match attempt.

method · iOS 17.0+

result

TypeScript
result(): Promise<SHSession_Result>
Swift declaration
final func result() async -> SHSession.Result

Performs an asynchronous match with a single signature. - Returns: A ``SHSession/Result`` enumeration that indicates the result.

init · iOS 17.0+

init

TypeScript
static initCatalog(catalog: SHCatalog): SHManagedSession
Swift declaration
init(catalog: SHCatalog)

Creates a new managed session object for matching audio in a custom catalog. - Parameters: - catalog: The catalog that contains the reference audio signatures and their associated metadata.

method · iOS 17.0+

prepare

TypeScript
prepare(): Promise<void>
Swift declaration
final func prepare() async

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

get · iOS 17.0+

results

TypeScript
get results(): SHSession_Results
Swift declaration
final var results: SHSession.Results { get }

The results as an asynchronous sequence of matches. This session continues to return results until the sequence is exhausted or the app calls ``SHManagedSession/cancel()``.

init · iOS 17.0+

init

TypeScript
static init(): SHManagedSession
Swift declaration
init()

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

Skipped declarations

No declarations were skipped in this snapshot.

All ShazamKit types →