Native watch apps and third-party complications

Native watch apps and third-party complications

Let's take a practical look at Apple's newest development platform watchOS, by implementing a GitHub streak custom complication and a native Spotify watch app.

9d2ea021919ff81e02d48530aae191bd?s=128

Boris Bügling

July 20, 2015
Tweet

Transcript

  1. 4.
  2. 5.
  3. 9.
  4. 10.
  5. 12.

    !!!

  6. 13.
  7. 16.
  8. 19.

    EXTENSION DELEGATE class ExtensionDelegate: NSObject, WKExtensionDelegate { func applicationDidFinishLaunching() {

    } func applicationDidBecomeActive() { } func applicationWillResignActive() { } }
  9. 20.

    INTERFACE CONTROLLER class InterfaceController: WKInterfaceController { override func awakeWithContext(context: AnyObject?)

    { super.awakeWithContext(context) } override func willActivate() { super.willActivate() } override func didDeactivate() { super.didDeactivate() } }
  10. 22.

    CLKCOMPLICATIONFAMILY enum CLKComplicationFamily : Int { case ModularSmall case ModularLarge

    case UtilitarianSmall case UtilitarianLarge case CircularSmall }
  11. 24.

    CLKCOMPLICATIONTEMPLATE The CLKComplicationTemplate class is a base class for specifying

    the arrangement of data in your custom watch complication.
  12. 27.

    ...

  13. 28.
  14. 29.

    If you measure interactions with your iOS app in minutes,

    you can expect interactions with your Watch app to be measured in seconds.
  15. 31.

    LAYOUT ▸ based on horizontal or vertical groups ▸ very

    similar to UIStackView ▸ two device sizes (38mm and 42mm) ▸ edge-to-edge, bezel provides margins
  16. 32.
  17. 34.
  18. 35.
  19. 36.
  20. 37.
  21. 39.
  22. 40.

    WATCHPRESENTER ▸ Remote controls Deckset instead ▸ Direct connection to

    the Mac ▸ Shows a preview of the slides ▸ Measures heartrate to display the "most exciting" slide ▸ Taps you if you're running out of time
  23. 47.

    HEALTHKIT.FRAMEWORK let anchorValue = Int(HKAnchoredObjectQueryNoAnchor) let sampleType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate) let

    heartRateQuery = HKAnchoredObjectQuery(type: sampleType!, predicate: nil, anchor: anchorValue, limit: 0) { (query, sampleObjects, deletedObjects, newAnchor, error) -> Void in guard let heartRateSamples = sampleObjects as?[HKQuantitySample] else {return} let sample = heartRateSamples.first let value = sample!.quantity.doubleValueForUnit(self.heartRateUnit) print(value) } heartRateQuery.updateHandler = // ...
  24. 48.
  25. 50.

    TAPTIC ENGINE typedef NS_ENUM(NSInteger, WKHapticType) { WKHapticTypeNotification, WKHapticTypeDirectionUp, WKHapticTypeDirectionDown, WKHapticTypeSuccess,

    WKHapticTypeFailure, WKHapticTypeRetry, WKHapticTypeStart, WKHapticTypeStop, WKHapticTypeClick } WK_AVAILABLE_WATCHOS_ONLY(2.0); WKInterfaceDevice.currentDevice().playHaptic(.Start)
  26. 53.
  27. 54.
  28. 55.
  29. 56.
  30. 57.
  31. 58.
  32. 63.

    WHAT HAVE WE LEARNED? ▸ Code isn't very different from

    iOS apps ▸ But design very much is ▸ Rethink your app for the watch, don't port it ▸ If you can't - maybe you don't need a watch app