AppleWatch – how to call the parent application using openParentApplication (Swift)

With Beta  2 of the AppleWatch SDK, released last year, Apple introduced a new way for the WatchKit Extension to call the parent application (e.g. to send and request data). There are other ways for app and extension to exchange data – but this new way is the easiest so far (I think).

I’ve played around with the new method, googled some examples for help and put together a simple example of my own that shows how the whole thing works. In my example, I send a value from the WatchKit extension to the parent app and depending on what it receives, the app will send back a different string.

The example was implemented in XCode 6.2 Beta 5.

In the WatchKit Extension:

Screen Shot 2015-02-05 at 17.34.03

In the parent application (AppDelegate.swift)

Screen Shot 2015-02-05 at 17.34.22

That’s it. I hope this helps someone to quickly integrate the functionality.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s