Instance Method

handleAction(withIdentifier:forRemoteNotification:)

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

Declaration

func handleAction(withIdentifier identifier: String?, forRemoteNotification remoteNotification: [AnyHashable : Any])

Parameters

identifier

The action selected by the user. This string is the identifier assigned to the action at registration time. This parameter is set to the empty string when the user launches the app without tapping one of the action buttons.

remoteNotification

The push notification payload dictionary. This parameter contains the data sent with the push notification. For information about the contents of this dictionary, see Local and Remote Notification Programming Guide.

Discussion

If your extension delegate does not implement the handleAction(withIdentifier:forRemoteNotification:) method, WatchKit calls this method on your app’s root interface controller to respond to button taps in your notification interfaces. If your containing iOS app supports actionable notifications, the identifier parameter contains the action identifier for the button that was tapped. Use that value to perform the requested action. If the identifier parameter contains an empty string, that means the user launched your Watch app from the notification interface without choosing a specific action.

The system calls this method on your WatchKit extension’s main thread. The super implementation of this method does nothing.

For information about how to support interactive notifications in your iOS app, see Local and Remote Notification Programming Guide. For information about how to display a custom interface for notifications, see App Programming Guide for watchOS.

See Also

Deprecated Symbols

func presentController([(name: String, context: AnyObject)])

Presents a page-based interface modally.

Deprecated
func handleAction(withIdentifier: String?, for: UILocalNotification)

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

Deprecated
func handleUserActivity([AnyHashable : Any]?)

Responds to Handoff–related activity.

class func reloadRootControllers(withNames: [String], contexts: [Any]?)

Loads the specified interface controllers and rebuilds the app’s page-based interface.

Text Response Key

Keys for retrieving text response information.