Code Examples for New Features of watchOS 2

In this topic, we dive into the exciting new features introduced in watchOS 2 and provide you with comprehensive code examples to help you leverage these enhancements in your Apple Watch apps.

Code Examples for New Features of watchOS 2

With the release of watchOS 2, Apple introduced several powerful capabilities and APIs that allow developers to create even more immersive and interactive experiences for the Apple Watch.

This collection of code examples serves as a practical guide, walking you through the implementation of various watchOS 2 features step by step.

From native app development to accessing sensors, utilizing complications, and leveraging new UI elements, you’ll find a wealth of code snippets and demonstrations to help you understand and incorporate these features into your own watchOS apps.

Discover how to harness the full potential of watchOS 2 by exploring code examples that showcase the benefits of improved performance, expanded access to hardware, and enhanced functionality.

Dive into the world of interactive notifications, leveraging the Digital Crown, utilizing background updates, and much more.

By studying these code examples, you’ll gain a deeper understanding of the watchOS 2 framework and its capabilities, enabling you to create richer and more engaging experiences for Apple Watch users.

Whether you’re an experienced watchOS developer looking to upgrade your skills or a newcomer interested in exploring the latest features, this resource provides valuable insights and hands-on guidance for incorporating watchOS 2 enhancements into your apps.

Get ready to unlock the potential of watchOS 2 with our comprehensive code examples, empowering you to create compelling and innovative Apple Watch apps that take full advantage of the platform’s latest capabilities.


  • Xcode 7
  • iOS 9 and watchOS 2

How to build

  • Change the “Team” setting on [General] for each target.
  • Enable HealthKit for the parent app and WatchKit extension target.
  • Enable App Groups for the Watch app and WatchKit extension target.
    • Edit “AudioRecAndPlayInterfaceController” with your group identifier.
  • Build & Run with Xcode 7


Animated Properties

Animate width/height, alpha and alignments.

Animate width/height, alpha and alignments in WatchKit

Table Animations

Insert and remove animations for WKInterfaceTable.

table animation in WatchKit

Picker Styles

WKInterfacePicker styles catalog.

picker style in WatchKit

Taptic Engine

Access to the Taptic engine using playHaptic method.

taptic engine in WatchKit

Audio Rec & Play

Record and play audio.

audio recorder in WatchKit

Animation with Digital Crown

Coordinated Animations with WKInterfacePicker and Digital Crown.

digital animation in WatchKit

Draw Paths

Draw paths with Core Graphics.

drawpath in WatchKit


Draw gradations with Core Graphics.

gradient color in WatchKit

Heart Rate

Access to Heart Rate data using HealthKit.

heart rate in WatchKit


Access to Accelerometer data using CoreMotion.

accelerometer in WatchKit

Gyroscope (Not Available)

Access to Gyroscope data using CoreMotion.

These APIs are available, however CMMotionManager always returns false for gyroAvailable. So actually it’s not available for now.

gyroscope in WatchKit

Device Motion (Not Available)

Access to DeviceMotion data using CoreMotion.

These APIs are available, however CMMotionManager always returns false for deviceMotionAvailable. So actually it’s not available for now.

device motion in WatchKit


Counting steps demo using CMPedometer.

pedometer in WatchKit


Present an alert or action sheet.

alert in WatchKit

Interactive Messaging

Sending message to phone and receiving from phone demo with WatchConnectivity.

messaging in WatchKit

Audio File Player

Play an audio file with WKAudioFilePlayer.

audio file in WatchKit

Need to pair a Bluetooth headset on your Apple Watch.

Open System URL

Open Tel or SMS app using openSystemURL: method.

open system in WatchKit

Network Access

Get an image data from network using NSURLSession.

network access in WatchKit

Known Issues

  • Open System URL
    • Phone doesn’t launch…
    • It’s based on the Apple’s document.
    • sms: works with same way. I have no idea why it doesn’t work!


You can check the examples for iOS 9 new features on iOS-9-Sampler!!

ios-9 sampler in WatchKit



Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *