Protocol

WKExtensionDelegate

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

Declaration

@protocol WKExtensionDelegate

Overview

Implement the delegate’s methods to respond to your app’s life-cycle events, such as the activation and deactivation of your app. You can also implement delegate methods to respond to background tasks, Siri intents, workout sessions, or Handoff activity from another devices.

WatchKit creates your delegate object automatically by instantiating the class assigned to the WKExtensionDelegateClassName key in your WatchKit extension’s Info.plist file. By default, this class is named ExtensionDelegate. The system then assigns the delegate object to the delegate property of the shared WKExtension object.

Topics

Monitoring State Changes

Working with the watchOS App Life Cycle

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

- applicationDidFinishLaunching

Tells the delegate that the launch process is almost done and the extension is almost ready to run.

- applicationDidBecomeActive

Tells the delegate that the Watch app is now visible and processing events.

- applicationWillResignActive

Tells the delegate that the Watch app is about to be deactivated.

- applicationWillEnterForeground

Tells the delegate that the app is about to transition from the background to the foreground.

- applicationDidEnterBackground

Tells the delegate that the app has transitioned from the foreground to the background.

- deviceOrientationDidChange

Tells the delegate that the device's orientation has changed.

- handleBackgroundTasks:

Tells the delegate that the app has received one or more background tasks.

Responding to Intents

- handleIntent:completionHandler:

Responds to a SiriKit intent.

Setup Now Playing Interface

- handleRemoteNowPlayingActivity

Tells the delegate when the user plays audio in the corresponding iOS app.

Handling a Workout Session

- handleWorkoutConfiguration:

Tells the delegate that the user started a workout session on the paired iPhone.

- handleActiveWorkoutRecovery

Tells the delegate when the app relaunches after crashing during an active workout session.

Handling Extended Runtime Sessions

- handleExtendedRuntimeSession:

Tells the delegate that the system launched your app to resume an extended runtime session.

Managing Remote Notifications

- didRegisterForRemoteNotificationsWithDeviceToken:

Tells the delegate that the app successfully registered with Apple Push Notification service (APNs).

- didFailToRegisterForRemoteNotificationsWithError:

Tells the delegate that Apple Push Notification service (APNs) cannot successfully complete the registration process.

- didReceiveRemoteNotification:fetchCompletionHandler:

Tells the delegate that a background notification has arrived.

WKBackgroundFetchResult

The result of an attempt to download the content associated with a remote notification.

Coordinating Handoff Activity

- handleUserActivity:

Responds to Handoff–related activity from complications and notifications.

- handleActivity:

Responds to Handoff–related activity from Siri.

Deprecated Methods

- didReceiveRemoteNotification:

Tells the delegate that a remote notification arrived.

Deprecated
- didReceiveLocalNotification:

Tells the delegate that a local notification was triggered.

Deprecated
- handleActionWithIdentifier:forRemoteNotification:

Delivers a remote notification payload and a user-selected action to the app.

Deprecated
- handleActionWithIdentifier:forRemoteNotification:withResponseInfo:

Delivers a remote notification payload and user response information to the app.

Deprecated
- handleActionWithIdentifier:forLocalNotification:

Delivers a local notification payload and a user-selected action to the app.

Deprecated
- handleActionWithIdentifier:forLocalNotification:withResponseInfo:

Delivers a local notification payload and user response information to the app.

Deprecated

Relationships

Inherits From

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.

WKExtension

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

WKInterfaceDevice

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