A protocol used to implement event handling in a Safari app extension.


protocol SFSafariExtensionHandling


Receiving Messages in Your App Extension

func messageReceived(withName: String, from: SFSafariPage, userInfo: [String : Any]?)

Called when a message is received from an injected script.

func messageReceivedFromContainingApp(withName: String, userInfo: [String : Any]?)

Called when a message is received from the extension's containing app.

Responding to Context Menu Selections

Working with Toolbar Items

func toolbarItemClicked(in: SFSafariWindow)

Called when a toolbar item associated with the app extension is clicked.

func validateToolbarItem(in: SFSafariWindow, validationHandler: (Bool, String) -> Void)

Called in response to a requested update or a browser state change that may affect the toolbar item.

Working with Popovers

func popoverViewController() -> SFSafariExtensionViewController

Asks the handler to provide a popover view controller for display.

func popoverWillShow(in: SFSafariWindow)

Tells the handler that the app extension's popover is about to be opened.

func popoverDidClose(in: SFSafariWindow)

Tells the handler that the app extension's popover was closed.


Inherits From

Conforming Types

See Also

Injecting Scripts and Style Sheets

About Injected Style Sheets and Scripts

Learn how you can affect the appearance or behavior of a webpage by using injected style sheets and scripts.

Injecting a Script into a Webpage

Inject a script that you've written from a Safari App Extension into a webpage.

Injecting CSS Style Sheets into a Webpage

Add to or override styles by injecting CSS style sheets into webpages.

Passing Messages Between Safari App Extensions and Injected Scripts

Pass data back and forth between Safari App Extension and injected scripts.

class SFSafariExtensionHandler

A base class that you subclass to handle events in your Safari app extension.

class SFSafariExtensionManager

A class used by your app to find out the current state of a Safari app extension.

class SFSafariExtensionState

The state of a Safari app extension.

class SFSafariPageProperties

Information about a webpage.

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