state
TypeScriptget state(): Promise<SHManagedSession_State>Swift declaration@MainActor final var state: SHManagedSession.State { get }The current state of the managed session.
class · iOS 17.0+ · SDK 27.1
final class SHManagedSessionAn 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. } ```
get state(): Promise<SHManagedSession_State>Swift declaration@MainActor final var state: SHManagedSession.State { get }The current state of the managed session.
cancel(): voidSwift declarationfinal func cancel()Cancels the currently running match attempt.
result(): Promise<SHSession_Result>Swift declarationfinal func result() async -> SHSession.ResultPerforms an asynchronous match with a single signature. - Returns: A ``SHSession/Result`` enumeration that indicates the result.
static initCatalog(catalog: SHCatalog): SHManagedSessionSwift declarationinit(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.
prepare(): Promise<void>Swift declarationfinal func prepare() asyncPreallocates the resources needed for a match, which increases the responsiveness of matches.
get results(): SHSession_ResultsSwift declarationfinal 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()``.
static init(): SHManagedSessionSwift declarationinit()Creates a new managed session object for matching songs in the Shazam Music catalog.
No declarations were skipped in this snapshot.