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

Ruby is watching

Ruby is watching

An introduction on developing WatchKit and Android Wear apps using RubyMotion. We'll learn about the differences between both platforms, what kind of possibilities the smartwatches bring to extending your application and how to share some code for your watch app between both iOS and Android versions.

Boris Bügling

July 02, 2015
Tweet

More Decks by Boris Bügling

Other Decks in Programming

Transcript

  1. RUBY IS ⌚ING
    #INSPECT 2015 !
    BORIS BÜGLING - @NEONACHO

    View Slide

  2. View Slide

  3. COCOAPODS

    View Slide

  4. CONTENTFUL

    View Slide

  5. View Slide

  6. !!!!

    View Slide

  7. AGENDA
    ▸ ᴡᴀᴛᴄʜ
    ▸ Android Wear
    ▸ Developing for both with RubyMotion
    ▸ Building a simple app

    View Slide

  8. ᴡᴀᴛᴄʜ

    View Slide

  9. WATCHOS 1.X
    ▸ Notifications
    ▸ Glances
    ▸ WatchKit apps

    View Slide

  10. NOTIFICATIONS

    View Slide

  11. GLANCES

    View Slide

  12. WATCHKIT

    View Slide

  13. WATCHOS 2.X
    ▸ Apps run natively on the watch
    ▸ Custom complications

    View Slide

  14. !!!

    View Slide

  15. View Slide

  16. COMPLICATIONS

    View Slide

  17. ANDROID WEAR

    View Slide

  18. ANDROID WEAR
    ▸ Enhanced Notifications
    ▸ Wearable Apps

    View Slide

  19. ENHANCED NOTIFICATIONS

    View Slide

  20. View Slide

  21. WEARABLE APPS

    View Slide

  22. => PRETTY MUCH THE SAME

    View Slide

  23. => RUBYMOTION

    View Slide

  24. View Slide

  25. RAKEFILE
    Motion::Project::App.setup do |app|
    [...]
    app.target 'WatchApp', :watchapp
    end

    View Slide

  26. RESOURCES
    ▸ Interface.storyboard
    ▸ Asset catalogs

    View Slide

  27. WATCHAPP/RAKEFILE
    [...]
    require 'ib/tasks'
    IB::RakeTask.new do |project|
    project.resource_directories = ['watch_app']
    end

    View Slide

  28. EXTENSION DELEGATE
    class ExtensionDelegate
    def applicationDidFinishLaunching
    [...]
    end
    def applicationDidBecomeActive
    [...]
    end
    def applicationWillResignActive
    [...]
    end
    end

    View Slide

  29. INTERFACE CONTROLLER
    class InterfaceController < WKInterfaceController
    extend IB
    def initWithContext(context)
    if super
    [...]
    self
    end
    end
    def willActivate
    [...]
    end
    def didDeactivate
    [...]
    end
    end

    View Slide

  30. WKINTERFACECONTROLLER
    ▸ Navigation
    ▸ Presentation
    ▸ Handoff
    ▸ Handle notification actions
    ▸ Communicate with parent app

    View Slide

  31. RUNNING THE APP IN THE SIM
    rake watch

    View Slide

  32. ANDROID WEAR ISN'T REALLY
    SUPPORTED, YET

    View Slide

  33. BUILDING A
    SIMPLE APP

    View Slide

  34. View Slide

  35. 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

    View Slide

  36. MULTIPEER CONNECTIVITY!

    View Slide

  37. AVAILABLE
    FRAMEWORKS

    View Slide

  38. CFNetwork.framework
    ClockKit.framework
    Contacts.framework
    CoreData.framework
    CoreFoundation.framework
    CoreGraphics.framework
    CoreLocation.framework
    CoreMotion.framework
    EventKit.framework
    Foundation.framework

    View Slide

  39. HealthKit.framework
    HomeKit.framework
    ImageIO.framework
    MapKit.framework
    MobileCoreServices.framework
    PassKit.framework
    Security.framework
    UIKit.framework
    WatchConnectivity.framework
    WatchKit.framework

    View Slide

  40. BT APIS ARE
    PRIVATE :(

    View Slide

  41. OTHER OPTIONS
    ▸ NSURLSession via Wi-Fi
    ▸ WatchConnectivity.framework to talk via the phone

    View Slide

  42. HEALTHKIT.FRAMEWORK
    ▸ not usable in the Watch simulator

    View Slide

  43. 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(WKHapticTypeStart)

    View Slide

  44. BUT ALSO NOT USABLE IN THE SIM

    View Slide

  45. DEMO

    View Slide

  46. TIPS

    View Slide

  47. printf
    DEBUGGING IS
    GREAT!

    View Slide

  48. MMWORMHOLE
    ▸ watchOS 1.0: CFNotificationCenter
    ▸ watchOS 2.0: WatchConnectivity.framework

    View Slide

  49. FORCE QUIT APPS
    ▸ Long press until "reboot" menu
    ▸ Long press again

    View Slide

  50. IF IN DOUBT, REBOOT THE
    WATCH :)

    View Slide

  51. WHAT HAVE WE LEARNED?

    View Slide

  52. THANK YOU!

    View Slide

  53. ▸ https://developer.apple.com/watch/human-interface-guidelines/
    ▸ https://developer.apple.com/library/prerelease/watchos/
    documentation/General/Conceptual/AppleWatch2TransitionGuide/
    ▸ https://developer.android.com/wear/index.html
    ▸ https://github.com/shu223/watchOS-2-Sampler
    ▸ http://www.kristinathai.com/category/watchkit/
    ▸ http://www.slideshare.net/peterfriese/introduction-to-android-
    wear

    View Slide

  54. View Slide

  55. @NeoNacho
    [email protected]
    http://buegling.com/talks

    View Slide