Class

NSExtensionContext

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

Declaration

@interface NSExtensionContext : NSObject

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 property.

Topics

Handling Requests

- cancelRequestWithError:

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

- completeRequestReturningItems:completionHandler:

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

Opening URLs

- openURL:completionHandler:

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

Managing the Display Mode for a Widget

widgetLargestAvailableDisplayMode

The largest display mode the widget supports.

widgetActiveDisplayMode

The active display mode of the widget.

- widgetMaximumSizeForDisplayMode:

Returns the maximum size for the specified widget display mode.

Storing Extension Items

inputItems

The list of input NSExtensionItem objects associated with the context.

Controlling Media Playback in Notification Content Extensions

- mediaPlayingStarted

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

- mediaPlayingPaused

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

Getting Siri-Related Information

hostedViewMinimumAllowedSize

The minimum size for a Siri hosted view.

hostedViewMaximumAllowedSize

The maximum size for a Siri hosted view.

- interfaceParametersDescription

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

Constants

Extension Items and Errors Key

This key is used in the userInfo dictionary of the NSError object returned by cancelRequestWithError:.

Notifications

NSExtensionHostDidBecomeActiveNotification

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

NSExtensionHostWillResignActiveNotification

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

NSExtensionHostDidEnterBackgroundNotification

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

NSExtensionHostWillEnterForegroundNotification

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

Instance Properties

Relationships

Inherits From

See Also

Extension Support

NSExtensionRequestHandling

The interface an app extension uses to respond to a request from a host app.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software