<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSExtensionContext",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSExtensionContext"
  },
  "title" : "NSExtensionContext"
}
-->

# NSExtensionContext

The host app context from which an app extension is invoked.

```
class NSExtensionContext
```

## Overview

When a host app sends a request to an app extension, it provides an extension context. For many app extensions, the most important part of the context is the data the user wants to work with, which is contained in the [`inputItems`](/documentation/Foundation/NSExtensionContext/inputItems) property.

## Topics

### Handling requests

[`-  completeRequestReturningItems:completionHandler:`](/documentation/Foundation/NSExtensionContext/completeRequest(returningItems:completionHandler:))

Tells the host app to complete the app extension request with an array of result items.

[`-  cancelRequestWithError:`](/documentation/Foundation/NSExtensionContext/cancelRequest(withError:))

Tells the host app to cancel the app extension request, with a supplied error.

[`NSExtensionItemsAndErrorsKey`](/documentation/Foundation/NSExtensionItemsAndErrorsKey)

The extension items and errors key.

### Opening URLs

[`-  openURL:completionHandler:`](/documentation/Foundation/NSExtensionContext/open(_:completionHandler:))

Asks the system to open a URL on behalf of the currently running app extension.

### Storing extension items

[`inputItems`](/documentation/Foundation/NSExtensionContext/inputItems)

The list of input [`NSExtensionItem`](/documentation/Foundation/NSExtensionItem) objects associated with the context.

### Controlling media playback in notification content extensions

[`-  mediaPlayingStarted`](/documentation/Foundation/NSExtensionContext/mediaPlayingStarted())

Tells the system that the Notification Content app extension began playing a media file.

[`-  mediaPlayingPaused`](/documentation/Foundation/NSExtensionContext/mediaPlayingPaused())

Tells the system that the Notification Content app extension stopped playing a media file.

### Populating your share extension with metadata

[`intent`](/documentation/Foundation/NSExtensionContext/intent)

Metadata for populating your share extensions interface.

### Getting Siri-related information

[`hostedViewMinimumAllowedSize`](/documentation/Foundation/NSExtensionContext/hostedViewMinimumAllowedSize)

The minimum size for a Siri hosted view.

[`hostedViewMaximumAllowedSize`](/documentation/Foundation/NSExtensionContext/hostedViewMaximumAllowedSize)

The maximum size for a Siri hosted view.

[`-  interfaceParametersDescription`](/documentation/Foundation/NSExtensionContext/interfaceParametersDescription())

Returns a human-readable string describing the data that SiriKit displays to the user when you handle an intent.

### Supporting broadcasting

[`-  loadBroadcastingApplicationInfoWithCompletion:`](/documentation/Foundation/NSExtensionContext/loadBroadcastingApplicationInfo(completion:))

[`-  completeRequestWithBroadcastURL:setupInfo:`](/documentation/Foundation/NSExtensionContext/completeRequest(withBroadcast:setupInfo:))

### Handling notification actions

[`notificationActions`](/documentation/Foundation/NSExtensionContext/notificationActions)

[`-  performNotificationDefaultAction`](/documentation/Foundation/NSExtensionContext/performNotificationDefaultAction())

[`-  dismissNotificationContentExtension`](/documentation/Foundation/NSExtensionContext/dismissNotificationContentExtension())

### Working with notifications

[`NSExtensionHostDidBecomeActiveNotification`](/documentation/Foundation/NSNotification/Name-swift.struct/NSExtensionHostDidBecomeActive)

Posted when the extension’s host app moves from the inactive to the active state.

[`NSExtensionHostWillResignActiveNotification`](/documentation/Foundation/NSNotification/Name-swift.struct/NSExtensionHostWillResignActive)

Posted when the extension’s host app moves from the active to the inactive state.

[`NSExtensionHostDidEnterBackgroundNotification`](/documentation/Foundation/NSNotification/Name-swift.struct/NSExtensionHostDidEnterBackground)

Posted when the extension’s host app begins running in the background.

[`NSExtensionHostWillEnterForegroundNotification`](/documentation/Foundation/NSNotification/Name-swift.struct/NSExtensionHostWillEnterForeground)

Posted when the extension’s host app begins running in the foreground.

### Working with notification messages

[`DidBecomeActiveMessage`](/documentation/Foundation/NSExtensionContext/DidBecomeActiveMessage)

A message the system sends when the extension’s host app moves from the inactive to the active state.

[`WillResignActiveMessage`](/documentation/Foundation/NSExtensionContext/WillResignActiveMessage)

A message the system sends when the extension’s host app moves from the active to the inactive state.

[`DidEnterBackgroundMessage`](/documentation/Foundation/NSExtensionContext/DidEnterBackgroundMessage)

A message the system sends when the extension’s host app begins running in the background.

[`WillEnterForegroundMessage`](/documentation/Foundation/NSExtensionContext/WillEnterForegroundMessage)

A message the system sends when the extension’s host app begins running in the foreground.

### Deprecated

[`-  completeRequestWithBroadcastURL:broadcastConfiguration:setupInfo:`](/documentation/Foundation/NSExtensionContext/completeRequest(withBroadcast:broadcastConfiguration:setupInfo:))

Tells the host app to complete the app extension request with the specified broadcast information.

[`widgetActiveDisplayMode`](/documentation/Foundation/NSExtensionContext/widgetActiveDisplayMode)

The active display mode of the widget.

[`widgetLargestAvailableDisplayMode`](/documentation/Foundation/NSExtensionContext/widgetLargestAvailableDisplayMode)

The largest display mode the widget supports.

[`-  widgetMaximumSizeForDisplayMode:`](/documentation/Foundation/NSExtensionContext/widgetMaximumSize(for:))

Returns the maximum size for the specified widget display mode.

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

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

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

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

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

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

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

---

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)