Class

NSExtensionContext

Represents the host app context from which an app extension is invoked.

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.

Symbols

Handling Requests

func cancelRequest(withError: Error)

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

func completeRequest(returningItems: [Any]?, completionHandler: (Bool) -> Void)? = nil)

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

Opening URLs

func open(URL, completionHandler: (Bool) -> Void)? = nil)

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

Managing the Display Mode for a Widget

var widgetLargestAvailableDisplayMode: NCWidgetDisplayMode

The largest display mode the widget supports.

var widgetActiveDisplayMode: NCWidgetDisplayMode

The active display mode of the widget.

func widgetMaximumSize(for: NCWidgetDisplayMode)

Returns the maximum size for the specified widget display mode.

Storing Extension Items

var inputItems: [Any]

The list of input NSExtensionItem objects associated with the context.

Controlling Media Playback in Notification Content Extensions

func mediaPlayingStarted()

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

func mediaPlayingPaused()

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

Getting the Siri Hosted View Metrics

var hostedViewMinimumAllowedSize: CGSize

The minimum size for a Siri hosted view.

var hostedViewMaximumAllowedSize: CGSize

The maximum size for a Siri hosted view.

Constants

Extension Items and Errors Key

This key is used in the userInfo dictionary of the NSError object returned by cancelRequest(withError:).

Notifications

static let NSExtensionHostDidBecomeActive: NSNotification.Name

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

static let NSExtensionHostWillResignActive: NSNotification.Name

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

static let NSExtensionHostDidEnterBackground: NSNotification.Name

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

static let NSExtensionHostWillEnterForeground: NSNotification.Name

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

Relationships

Inherits From

Conforms To