Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WatchKit workshop at Tuenti

Tuenti
February 28, 2015

WatchKit workshop at Tuenti

We held another theEvnt workshop at Tuenti where Víctor Corugedo, César Estébanez and Eduardo González (Tuenti iOS Team members) gave a complete workshop about WatchKit SDK and how to develop Apple Watch Apps.

Tuenti

February 28, 2015
Tweet

More Decks by Tuenti

Other Decks in Technology

Transcript

  1. • Apple S1 integrate computer (SiP) • Sensors: • Accelerometer

    • Gyroscope • Heart rate monitor • Processor Broadcom handling WIFI and Bluetooth
  2. Preliminar SDK versions Xcode 6.2 beta 5 & iOS 8.2

    Apple Watch requires iPhone 5 or later https://developer.apple.com/watchkit/
  3. • WatchKit Apps • User interacts launching it from home

    screen • Full user interface with multiple screens of content
  4. • Glances • Timely read-only information. Lightweight view on watch

    app. • Glances do not scroll • Glance interface must fit on a single screen. • Optionals and watch could turn them on/off when they want :) • Tapping launches watch app (deep linking)
  5. • Notifications • Short supported by default (Local/Remote) • Displays

    alert message from notification • Long Look interface • Static version • Dinamic Version
  6. • Two separate bundles: • Watch app runs on Apple

    Watch • WatchKit Extension runs on user’s iPhone • UI Resources stored on the Watch App • Code runs on WatchKit extension manages Watch App user interfaces and respond to user interactions
  7. • WatchKit App & WatchKit Extension are packaged inside iOS

    App bundle • During installation of your iOS app, the system prompts the user to install the WatchKit app when a paired Apple Watch is present.
  8. iOS App WatchKit Extension WatchKitApp Resources WatchKitCode WatchKitApp iOS Code

    WatchKit Extension WatchKitApp Target WatchKit Extension Target iOS AppTarget
  9. • Each scene is managed by a single interface controller

    object, which is an instance of the WKInterfaceController class. • Interface controller presents and manages content on the screen and responds to user interactions with that content. • Only one controller at a time is displayed onscreen.
  10. Shared app group lets the two processes share files or

    user defaults information between them.
  11. At runtime, you share files between processes by reading and

    writing those files in the shared container directory
  12. Make sure that you don't accidentally corrupt the data. Sharing

    data files means there might be more than one process trying to use a file at the same time.
  13. WKInterfaceController • Manages elements in the scene • Entry point

    of the Apple Watch app • Lifecycle: willActivate and didDeactivate
  14. WKInterfaceObject • Base class of interface objects • Proxy objects,

    NOT the actual views • Communicate wirelessly with views in UI on Apple Watch
  15. Labels (WKInterfaceLabel) • Display static formatted text • Supports standard

    and custom fonts • Can be internationalized • For text input: Dictation or standard set of phrases or emoji
  16. Images (WKInterfaceImage) • Display single image or a sequence of

    images • Control animations programmatically • Images or image names are transferred wirelessly • Use images names from app bundle • Cache when possible
  17. Groups and Separators (WKInterfaceGroup & WKInterfaceSeparator) • Groups • Container

    for other interface objects or other groups • Layout horizontal or vertically • Separators • Separating content in a view
  18. Tables (WKInterfaceTable) • Support for single column tables and multiple

    row types • No data source nor delegate • Define row layout in storyboard and connect with row controllers • WKInterfaceController adds rows and handles interactions
  19. Buttons, Switches and Slider (WKInterfaceButton & WKInterfaceSwitch & WKInterfaceSlider) •

    Buttons • Can contain a single label or group • Sliders • Discrete or continuous • One image at each end
  20. Maps (WKInterfaceMap) • Static snapshots of a location • Not

    interactive: tap will open the Maps app • Support for annotations
  21. Dates and Timers (WKInterfaceDate & WKInterfaceTimer) • Specialized labels •

    Don’t require to be updated by a WatchKit extension • Configure display through different formats and calendars
  22. Menus (WKInterfaceSlider) • Display 1 to 4 secondary actions •

    Defined per screen • IBAction to handle action
  23. GitHubStars • Keep track of your repos • See how

    many stars, forks, and issues you have • GitHub API - OctoKit • ReactiveCocoa! • MVVM
  24. iOS App Architecture VM VM I I M V V

    Network Storage API DB M Business Presentation Data
  25. That’s why VM VM I I M V V Network

    Storage API DB M Business Presentation Data
  26. Reuse Code! • User Embedded Frameworks to share code between

    iOS App and WatchKit Extension • Limitations: • Extensions and iOS app run in separated processes • Some APIs are not available to App Extensions • Access sharedApplication • Camera, micro • Long-running background tasks (networking!) • HealthKit, EventKit UI, AirDrop, etc.
  27. WatchKit Extension iOS App Embedded API DB Data ? Storage

    App Groups! WatchKit App Architecture [[NSUserDefaults alloc] initWithSuiteName:GitHubStarsCoreKitAppGroupName];
  28. WatchKit Extension iOS App Embedded API DB Data ? Storage

    Background NSURLSessionTask + App Groups WatchKit App Architecture application:handleEventsForBackgroundURLSession:completionHandler:
  29. WatchKit Extension iOS App Embedded API DB Data Communicating with

    containing App Storage Network iOS WatchKit App Architecture WKInterfaceController openParentApplication:reply:
  30. WatchKit Extension iOS App Embedded M M Business API DB

    Data Storage Network iOS WatchKit App Architecture
  31. WatchKit Extension iOS App Embedded WKInterfaceController M M Business Presentation

    WKInterfaceController API DB Data Storage Network iOS WatchKit App Architecture
  32. WatchKit Extension iOS App Embedded WKInterfaceController I M M Business

    Presentation WKInterfaceController API DB Data Storage Network iOS I WatchKit App Architecture
  33. Pro Tips • Inter-process Communication & Debugging • Write tests.

    No, seriously. • Serialisation for inter-process communication • NSCoding?
  34. Pro Tips • Inter-process Communication & Debugging • Write tests.

    No, seriously. • Serialisation for inter-process communication • NSCoding • NSSecureCoding!
  35. Hands on • What are you learning? • WatchKit App

    • Static & Dynamic Notifications • Glance
  36. Hands on • Two flavours: • checkout kickoff and write

    code with us • checkout master and follow the explanations
  37. Hands on • What are we providing? I I M

    M Business Presentation API DB Data Storage Network iOS
  38. Hands on • What are we providing? I I M

    M Business Presentation API DB Data Storage Network iOS