Instance Method

didReceiveRemoteNotification(_:withCompletion:)

Delivers a remote notification payload to your interface controller for processing.

Declaration

func didReceiveRemoteNotification(_ remoteNotification: [AnyHashable : Any], withCompletion completionHandler: @escaping (WKUserNotificationInterfaceType) -> Void)

Parameters

remoteNotification

The remote notification dictionary. The contents of the dictionary correspond to the contents of the notification payload and are organized in the same way. For information about the contents of the remote notification payload, see Local and Remote Notification Programming Guide.

completionHandler

The completion handler for telling the system what interface to display. Execute this completion handler at the end of your method implementation. If you do not execute this block in a timely manner, the system displays your app’s static notification interface. This block has no return value and takes the following parameter:

interface

The notification interface to be displayed. Specify the value WKUserNotificationInterfaceType.custom to display your dynamic interface. Specify the value WKUserNotificationInterfaceType.default to display the static interface. You might choose to display the static interface if the payload does not contain the data you were expecting.

Discussion

Before displaying your notification interface, WatchKit calls this method to deliver the incoming notification object. Implement this method and use it to store the notification object, configure your custom notification interface, and execute the completionHandler block as quickly as possible. Failure to execute the completion handler in a timely manner causes the system to display the corresponding static notification interface.

WatchKit may call this method multiple times while your interface controller is active. If a new local notification with the same category arrives while your notification interface is active, WatchKit calls the method again with the new local notification object.

See Also

Processing the Notification

func didReceive(UNNotification)

Delivers a notification object to your interface controller for processing.

func didReceive(UNNotification, withCompletion: (WKUserNotificationInterfaceType) -> Void)

Delivers a notification object to your interface controller for processing.

func didReceive(UILocalNotification, withCompletion: (WKUserNotificationInterfaceType) -> Void)

Delivers a local notification object to your interface controller for processing.

Deprecated