An object that manages behaviors shared by an app’s interface controllers.


class WKExtension : NSObject


Every WatchKit extension has a single extension object that the system creates and manages. You use the extension object to perform app-level tasks such as opening URLs and getting the root interface controller of your app.

As relevant events occur within your WatchKit app, the extension object notifies its delegate of those events. Your delegate object can implement the methods it needs to provide an appropriate response to life cycle events, handle notifications, or handle Handoff–related behaviors. For more information about the methods of the delegate, see WKExtensionDelegate.


Getting the Extension Object

class func shared() -> WKExtension

Returns the shared WatchKit extension object.

Accessing the Extension Delegate

var delegate: WKExtensionDelegate?

The delegate of the WatchKit extension object.

protocol WKExtensionDelegate

A collection of methods that manage the app-level behavior of a WatchKit extension.

Opening a URL Resource

func openSystemURL(URL)

Opens the specified system URL.

Getting the Interface Controllers

var rootInterfaceController: WKInterfaceController?

The app’s root interface controller.

var visibleInterfaceController: WKInterfaceController?

Returns the last visible interface controller.

Managing the Execution State

var applicationState: WKApplicationState

The runtime state of the Watch app.

enum WKApplicationState

The running states of your Watch app.

var isApplicationRunningInDock: Bool

A Boolean value that indicates whether the app is running in the dock.

var isFrontmostTimeoutExtended: Bool

A Boolean value that determines whether the app extends its time as the frontmost app.

Managing the User Interface

var isAutorotating: Bool

A Boolean value that determines whether the interface automatically rotates when the user flips their wrist.

var isAutorotated: Bool

A Boolean value that indicates whether the user interface is currently rotated so that it is properly oriented for another viewer.

func enableWaterLock()

Disables the Apple Watch touch screen to prevent accidental taps while the watch is submerged.

Registering for Remote Notifications

func registerForRemoteNotifications()

Register to receive remote notifications from the Apple Push Notification service (APNs).

func unregisterForRemoteNotifications()

Unregister for all remote notifications received from Apple Push Notification service (APNs).

var isRegisteredForRemoteNotifications: Bool

A Boolean value that indicates if the app has successfully registered for remote notifications.



Inherits From

Conforms To

See Also

App Infrastructure

Working with the watchOS App Life Cycle

Learn how the watchOS app life cycle operates and respond to life cycle notification methods.

Keeping Your watchOS Content Up to Date

Ensure that your watchOS content is relevant and up to date.

Authenticating Users on Apple Watch

Create an account sign-up and sign-in strategy for Apple Watch.

protocol WKExtensionDelegate

A collection of methods that manage the app-level behavior of a WatchKit extension.

class WKInterfaceDevice

An object that provides information about the user’s Apple Watch.

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