<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SiriKit",
  "identifier" : "/documentation/Intents/INPlayMediaIntentHandling/handle(intent:completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Intents"
    ],
    "preciseIdentifier" : "c:objc(pl)INPlayMediaIntentHandling(im)handlePlayMedia:completion:"
  },
  "title" : "handle(intent:completion:)"
}
-->

# handle(intent:completion:)

Handles the media playback request.

```
func handle(intent: INPlayMediaIntent, completion: @escaping @Sendable (INPlayMediaIntentResponse) -> Void)
```

```
func handle(intent: INPlayMediaIntent) async -> INPlayMediaIntentResponse
```

## Parameters

`intent`

The [`INPlayMediaIntent`](/documentation/Intents/INPlayMediaIntent) object that contains details about the user’s request. The Intents app extension confirms the information in this intent before the system calls the [`handle(intent:completion:)`](/documentation/Intents/INPlayMediaIntentHandling/handle(intent:completion:)) method.

`completion`

The handler block to execute with your response. You must execute this handler while implementing this method. This handler has no return value and takes the following parameter:

- `response`: The [`INPlayMediaIntentResponse`](/documentation/Intents/INPlayMediaIntentResponse) object you create that reports the status of the request. This parameter must not be `nil`.

## Discussion

Because the lifespan for an Intents app extension is short, the [`INPlayMediaIntent`](/documentation/Intents/INPlayMediaIntent) handler tells the main app to start the media playback. For audio content, respond with the [`INPlayMediaIntentResponseCode.handleInApp`](/documentation/Intents/INPlayMediaIntentResponseCode/handleInApp) response code. This code tells the system to launch the main app in the background and call <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate/application(_:handle:completionHandler:)> on the <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate> object. Your app should begin the audio playback in this app delegate method.

The listing below tells the app to play the requested media in the background.

```swift
public func handle(intent: INPlayMediaIntent, completion: @escaping (INPlayMediaIntentResponse) -> Void) {
    let response = INPlayMediaIntentResponse(code: .handleInApp, userActivity: nil)
    completion(response)
}
```

For video content, respond with [`INPlayMediaIntentResponseCode.continueInApp`](/documentation/Intents/INPlayMediaIntentResponseCode/continueInApp). This code instructs the system to launch your app in the foreground and call <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate/application(_:continue:restorationHandler:)> on the <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate> object. Your app should start the video playback in this app delegate method.

The listing below tells the app to play the requested media in the foreground.

```swift
public func handle(intent: INPlayMediaIntent, completion: @escaping (INPlayMediaIntentResponse) -> Void) {
    let response = INPlayMediaIntentResponse(code: .continueInApp, userActivity: nil)
    completion(response)
}
```

---

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)