Type Method

openParentApplication(_:reply:)

Sends data from your WatchKit extension running in watchOS 1 to your iOS app.

Declaration

class func openParentApplication(_ userInfo: [AnyHashable : Any], reply: (([AnyHashable : Any], Error?) -> Void)? = nil) -> Bool

Parameters

userInfo

A dictionary containing data to pass to the iOS app. Use this dictionary to pass information to the iOS app so that it can perform any needed tasks. The contents of the dictionary must be serializable to a property list file. This parameter must not be nil.

reply

A block for receiving a reply from the containing iOS app. You may specify nil for this parameter. This block has no return value and takes the following parameters:

replyInfo

The reply dictionary provided by the iOS app.

error

An error object indicating if a problem occurred or nil if there was no error.

Return Value

true if the request was sent successfully or false if the request was not sent.

Discussion

In watchOS 1, use this method to send a message from your WatchKit extension to your iOS app running on the same device. Calling the method causes iOS to launch the app in the background (as needed) and call the application(_:handleWatchKitExtensionRequest:reply:) method of its app delegate. That method has the following signature:

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply

The app delegate receives the dictionary you pass into the userInfo parameter and uses it to process whatever request you made. If it provides a reply, WatchKit executes the block you provided in the reply parameter on your Watch app’s main queue. If you call this method multiple times in quick succession, your calls are serialized so that each subsequent call is delayed until the response from the previous call is received.

See Also

watchOS 1 Methods

func handleAction(withIdentifier: String?, for: UNNotification)

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