Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developing for Apple Watch (Apple Guide) #17

Open
sohilpandya opened this issue Dec 1, 2016 · 5 comments
Open

Developing for Apple Watch (Apple Guide) #17

sohilpandya opened this issue Dec 1, 2016 · 5 comments
Assignees

Comments

@sohilpandya
Copy link
Member

sohilpandya commented Dec 1, 2016

#Apple has built a guide: Developing for Apple Watch

My plan is to go through the documentation and make notes as I read along so that we can all gain a better understanding of how to go about developing for Apple Watch, which will eventually help with getting v0.1 off the ground #15

@sohilpandya
Copy link
Member Author

sohilpandya commented Dec 1, 2016

Introduction to developing for Apple Watch

There are three distinct UI's that need to be looked at:

  • Watch App
    • Main Interface for the app
  • Complications
    • Found on all watch faces, Apple recommends all watch apps have a complication, even if their complication does not present information and just redirects the user to the app
  • Notifications
    • Interface to interact with new information (e.g. new message/timer runs out)

Watch app can live inside the corresponding iOS app.

  • Add to an existing iOS project
    • Choose File > New > Target > watchOS (tab) > WatchKit App
  • Create a new iOS project that includes a watch app.
    • New > Project > WatchOS Section > iOS App with WatchKit App

App Target Structure

As shown in the structure above:
screen shot 2016-12-01 at 16 25 42

  • iOS app contains the Watch app
    • Which contains the WatchKit extension
  • So when a user installs the iPhone app, it will automatically install the Watch app, if an Apple Watch is present.

Watch App Architecture

screen shot 2016-12-01 at 16 34 59
Watch App bundle

  • contains the app's storyboard
    WatchKit extension
  • contains your app's code and additional resources (what are these additional resources 🤔 )

Communication between your WatchKit Extension and iOS app is possible through the Watch Connectivity Framework

The WatchKit extension has an extension object - WKExtension and a corresponding delegate object to manage behavior that is central to your app.

Managing the Watch App Life Cycle

screen shot 2016-12-01 at 16 50 18

When the Watch app is launched, the methods of WKExtensionDelegate protocol are called for each transition phase:

  • applicationDidFinishLaunching
  • applicationDidBecomeActive or applicationWillResignActive
  • applicationWillEnterForeground or applicationDidEnterBackground
Note
  • The app will remain in the active phase as long as it is on screen
  • It transitions back to an inactive state when the user exits the app
  • If the app is in the dock or a complication, it remains in the suspended state

@sohilpandya
Copy link
Member Author

sohilpandya commented Dec 2, 2016

Reading through the WatchConnectivity Introduction by Natasha the Robot

I found a link to a tutorial which would guide a user through how to use watchConnectivity, here but unfortunately, it's not compatible with WatchOS3 😢

This has lead me into doing some more research and trying to find out how exactly one would go about implementing this in the latest OS.
Issue is with implementing a new mandatory method called session:activationDidCompleteWithState

😢 😢 😢 😢

@sohilpandya
Copy link
Member Author

sohilpandya commented Dec 2, 2016

An update for the day, I've been trying to get this supposedly simple feature where selecting a button on the watch would change the label on the phone. I have been following this tutorial http://kristina.io/watchos-2-tutorial-using-sendmessage-for-instantaneous-data-transfer-watch-connectivity-1/ which would allow us to transfer some data from the watch to the phone.

Simulator problem
I've taken a step closer to achieving that goal, but now I am unable to get the watch simulator to recognise the watch app. :(
solution
Change the active scheme from just app to apple watch app + phone app as seen below
screen shot 2016-12-02 at 17 58 19

I've still not managed to get the message between the two devices, I'll leave this as is now and look at it with fresh eyes next week. (or perhaps the weekend. 😄 )

sohilpandya added a commit that referenced this issue Dec 2, 2016
@sohilpandya sohilpandya self-assigned this Dec 5, 2016
@sohilpandya
Copy link
Member Author

sohilpandya commented Dec 5, 2016

Update from Monday morning session 🔍

I hit a wall on Friday, where I was unable to get the connection to work. After some futher research and looking into some code from the tutorial listed above, I've managed to get v0.1 up and running 🎉

If a user selects the button on the watch, they are able to see the text label change on the iPhone.

ezgif com-video-to-gif

My next steps are to create a short tutorial on how to do the following.

@nelsonic
Copy link
Member

nelsonic commented Dec 5, 2016

@sohilpandya amaze! 😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants