<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iOSAppExtension: -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NowPlaying",
  "identifier" : "/documentation/NowPlaying/RemoteMediaSession",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Now Playing"
    ],
    "preciseIdentifier" : "s:10NowPlaying18RemoteMediaSessionC"
  },
  "title" : "RemoteMediaSession"
}
-->

# RemoteMediaSession

A session that manages remote media playback across devices.

```
@MainActor class RemoteMediaSession<Attributes> where Attributes : RemoteMediaSessionAttributes
```

## Overview

Use a remote session to represent media playback sessions happening outside
of this device, but that your app wants to donate to the system so they may appear
in the system’s Now Playing interface.

Use this API when your app has information about the remote session and
wants to signal to the system that playback has started (using [`start(attributes:)`](/documentation/NowPlaying/RemoteMediaSession/start(attributes:)))
or something about the session has changed (using [`update(_:)`](/documentation/NowPlaying/RemoteMediaSession/update(_:))).

You can also donate remote sessions to the system through push notifications, for example
when playback starts while your app isn’t running.

In that case, use APNs to send a push notification to the user’s device that informs
the system of a `start`, `update`, or `end` event.

For more information, see [Publishing remote media sessions](/documentation/NowPlaying/publishing-remote-media-sessions)

The following example shows how to start a session:

```swift
struct MySessionAttributes: RemoteMediaSessionAttributes {
    let id: String
    let trackID: String
}

let attributes = MySessionAttributes(id: "session-123", trackID: "track-123")
let session = try await RemoteMediaSession.start(attributes: attributes)
```

After starting a session, update its attributes or end it:

```swift
// Update the session attributes
try await session.update(newAttributes)

// End the session when playback completes
try await session.end()
```

## Topics

### Instance Properties

[`let id: String`](/documentation/NowPlaying/RemoteMediaSession/id)

The unique identifier for this session.

[`var isSystemPrimary: Bool`](/documentation/NowPlaying/RemoteMediaSession/isSystemPrimary)

A Boolean value that indicates whether this is currently the primary system session.

### Instance Methods

[`func end() async throws`](/documentation/NowPlaying/RemoteMediaSession/end())

Ends the session and removes it from the Now Playing interface.

[`func requestToBecomeSystemPrimary() async throws`](/documentation/NowPlaying/RemoteMediaSession/requestToBecomeSystemPrimary())

Requests to make this session the system primary media session.

[`func update(Attributes) async throws`](/documentation/NowPlaying/RemoteMediaSession/update(_:))

Updates the session with new attributes.

### Type Properties

[`static var pushToStartToken: Data?`](/documentation/NowPlaying/RemoteMediaSession/pushToStartToken)

The token you use to start a [`RemoteMediaSession`](/documentation/NowPlaying/RemoteMediaSession) through a push notification.

[`static var pushToStartTokenUpdates: AsyncStream<Data>`](/documentation/NowPlaying/RemoteMediaSession/pushToStartTokenUpdates)

An asynchronous sequence that delivers updated tokens for starting a [`RemoteMediaSession`](/documentation/NowPlaying/RemoteMediaSession)
through a push notification.

### Type Methods

[`static func sessions() async throws -> [RemoteMediaSession<Attributes>]`](/documentation/NowPlaying/RemoteMediaSession/sessions())

Returns all registered remote sessions.

[`static func start(attributes: Attributes) async throws -> RemoteMediaSession<Attributes>`](/documentation/NowPlaying/RemoteMediaSession/start(attributes:))

Starts a new remote session with the specified attributes.

## Relationships

### Conforms To

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

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

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

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

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

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

---

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)