Intro to watchOS 2

The Apple Watch operating system now has a proper name and struts some brand new tricks. If you learned how to use WatchKit over the past year, you might find it fun that apps now can run on the Watch hardware and take advantage of the sensors. Ben steps through real-world use cases of apps written for watchOS 2 and answer questions about what is possible.


Introduction (0:00)

My name is Ben Morrow, and I run the Apple Watch meetup group here in the Bay Area, and I’m working on a workout app for the Apple Watch. watchOS 2 is now in beta and soon to release, and I’d like to review the parts of it that can help you make a spectacular app.

New Apple Watch Capabilities (0:19)

When the original iPhone came out, it had minimal functionality, Apple-only apps and little storage. We’ve come a long way since then, all the way up to iOS 9, and that kind of trajectory is gonna happen for the watch as well. The watch started off with a bang, and now watchOS 2 extends that. There are many a whole lot of system frameworks that we get access to in watchOS 2, including ClockKit, HealthKit, and Watch Connectivity.

Native Apps and Sensor Access (0:57)

Watch Connectivity is what you use to talk back and forth between the phone and the watch. The reason you would want to talk back and forth between the phone and the watch is because watch apps are now native. That means that the code is actually running on the watch instead of what it was doing before where it was running on the phone and just updating the view on the watch. This in turn yields faster and less buggy apps that can run even without a phone. They can even do networking over known Wi-Fi networks on their own.

We now get access to hardware and sensors, so that includes the Taptic Engine, the Digital Crown, the accelerometer, the heart rate sensor, the speaker, and the microphone. Some good examples of apps using these include the PING app, which uses the accelerometer to measure the speed of your golf swing; Strava uses the heart rate sensor to gather data during workouts; Insteon uses the Digital Crown to control your house lights.

ClockKit and Siri (1:49)

ClockKit can provide extra bits of information that you see on the watch face, called complications. Some good examples of that are flight times or how much charge your electric car has left. Related to that is time travel. It allows you to turn the Digital Crown on the side of the watch to see what happened yesterday, what’s happening today, and what’s scheduled to happen tomorrow. Some cool examples of this is that you could check what the weather will be like for your lunch date tomorrow, or you could check back over the headlines that you missed earlier in the day.

The Apple Watch also uses Siri well. Even though there is no Siri API yet, Siri for watchOS 2 is really beefed up. Siri allows dictated replies to emails and texts, provides contextual suggestions, and even start a workout by saying the time length you want to workout. Using Siri, you can open up a glance, you can get transit information, and you can even control HomeKit devices. This way of interaction with your voice will be important in the future, and so if you want to you can start thinking about how your app can take advantage of voice. Let’s think about putting all of that into practice.

Apple Watch Hackathon (2:56)

On June 13th, which is the Saturday after WWDC, we had an Apple Watch hackathon. It was actually the second one that the group put on. Thirty teams came and built great apps. You can find everyone’s presentations here. I just wanted to go over them to show you what makes a good watch app.

  • WatchOut is an Atari Breakout style game where you control the paddle with the Digital Crown, and that was really fun.
  • Pow is a gestures trigger sound effects, so when you do a fist pump it makes a cha-ching for you.
  • PreziRemote lets you control the next slide and get a tap on your wrist when you’re low on time in a real Prezi presentation online.
  • FamilyBurrowClock provided a notification when a family member enters or leave the geofences.
  • The watchOS Sampler was a hodgepodge of all the different new features. It has the accelerometer, gyroscope, hand drawing with core graphics, audio recording, playback, picker styles, Taptic Engine, showing alerts and animations with the Digital Crown.
  • Air Drum let’s you play drums using the motion data.
  • Rollin lets you find people around you who want to have fun doing the same activity.
  • Lastly, Propeller Pet was a lot of fun — a virtual pet where you actually have to go outside and walk so that your pet stays happy.

WatchKit Improvements (4:58)

The features that I wanted to discuss in WatchKit include Digital Crown, layout and animation, Taptic Engine, and audio and video. With the Digital Crown there’s a lot of new picker styles that you can choose from. The list style, which has an optional focus outline and a caption. The stack style displays list of images with a transition where one slides up and the other one fades back. The image sequence style has no transitions, but has an optional scroll indicator so you know how far you are down the list. Lastly, the coordinated image with the picker control provides visual feedback for what’s happening inside of the picker.

All the attributes that you have in Interface Builder can now be set in code, and that’s pretty important because previously you had to set everything up in Interface Builder and you couldn’t mess with too much of it. But now, since we can edit them in code, we can also use animateWithDuration(). That allows us to create neat animations such as changing the width of groups.

Audio Recording, Haptic Feedback, Video, and Health (6:16)

Also new in WatchKit is a recording sheet. It pops this sheet up and the user can start recording their voice, and then when they’re done they can hit the button in the upper right hand corner, send, and your app can handle that audio file. You can also play haptic feedback. Any of these notification, direction up, direction down, success, failure, retry, start, stop and click, are all different kinds of taps that you can get on your wrist. If you’ve used the maps app on the Apple Watch then you’re familiar, it plays direction up and direction down for turn left and turn right. In your app you could play these at any time, so the Prezi app was a good example of that where it would give you a warning when you’re running out of time for your presentation. There’s also video on the watch now, so when you play a video it moves into a nice fullscreen mode, and you can watch the whole video and then when you’re done you can exit out of that sheet.

Apple also exposed HealthKit, which is my favorite because I’m building the workout app. If you import HealthKit and create a HealthKit health store and workout session, then you can start the workout session, which gives you access to all of the workout data, such as distance traveled, calories burned, and heart rate in BPM. Another advantage is that if you do this, then your app actually stays in the foreground while the workout is running. So when the user puts their wrist down and brings it back up to check, then your app comes right back up.

watchOS Resources (8:06)

Next are some handy resources to get started with watchOS 2. The first is the watchOS 2 Sampler, one of the hackathon projects, but he put it on GitHub, so you can get sample code for all the different features that were demonstrated today. Apple has made two different projects: the audio recorder and the movie player, that get you up and running with those.

There’s also HealthKit. There’s a really awesome presentation about how to make a workout app for watchOS 2 that’s there and then there’s a Stack Overflow discussion about keeping the app alive during a workout.

I’m a co-author on the WatchKit by Tutorials book, and so if you want to jump in and learn about all the different system frameworks and how to use them with the watch, that’s a good place to do it. I’m Ben Morrow and thanks for reading.

Q&A (9:25)

Q: Can we use the haptic engine with our own vibration pattern, like you can do with the Android Wear devices?

Ben: Not yet, but you could combine existing vibration patterns.

Q: Can the native watch app send notification to the device?

Ben: You can set up local notifications that could trigger at a set date in the future.

Q: Are you familiar with the video playback restrictions on the watch, such as max duration or size?

Ben: Unfortunately not, but the docs will help.

Audience member: It was mentioned during WWDC that only short videos are possible, ideally up to 45 seconds.

Q: Regarding vibration notifications, could you technically create an alarm app that would keep vibrating until paused?

Ben: I don’t think so; the app would have to be active to achieve that currently.

Q: How well do watchOS 2 betas work?

Ben: So far, up to beta 5 currently, using the OS on the watch itself is fairly stable, but we ran into a few development bugs.

Q: Do you have any tricks for running the watch apps on device or in the simulator?

Ben: Sometimes the app can’t run on the simulator and it requires a few retries until it magically fixes itself at this point. Occasionally the app doesn’t install correctly on device, so toggling the installation on device switch on and off sometimes to solve that issue.

Q: Is there a way to limit the watch apps to the gold version only, targeting only stinking rich owners?

Ben: I’m not sure if there’s a string you could check to find that out, but that would be funny…

By the way, you can now localize for the watch; you can make it work in any language. Furthermore, when you localize it for a right-to-left language then it actually flips your whole interface, which is pretty cool to watch happen. There are also many accessibility features on the watch. You could set up an image where you can touch different parts of the image and it will speak aloud what’s in there.

Q: Do you know if any audio frameworks other than just the recorder are available yet?

Ben: Well you can play audio back, too, but that’s the only two that I know of.

Q: For kicks, what’s your reaction to these word: Code Signing?

Ben: It’s been a challenge but it’s improving. With watchOS 2, I ran into some issues and signing out and back in with my developer account typically fixes them.

Q: Why do you think Apple developed a limited, preliminary SDK to release to the public, and shortly afterwards replacing it with the native app SDK?

Ben: Part of doing that is coming up with the minimum viable product. They may have known that it was easier to get proxy style interface working first, and needed more time to flesh out full app capacity.


Ben Morrow

Ben Morrow

Ben Morrow is a developer, author, and hackathon organizer. With the Apple Watch community, he's been working on apps made for the new device platform. Find more video and code at happy.watch­.