Homekit on tvOS

Homekit on tvOS

HomeKit frameworkを使ったtvOSアプリ開発を通して学んだ事を簡単にまとめました。

Db5cf21a75ebe2484b95ea9dec5f573b?s=128

Shingo Tamaki

June 05, 2017
Tweet

Transcript

  1. HomeKit on tvOS

  2. ࣗݾ঺հ

  3. ࣗݾ঺հ ۄ৓৴ޛ iOS Engineer! tvOSΞϓϦͷ։ൃ͸ࠓ೔͜ͷ೔ͷͨΊʹษڧ͠·ͨ͠ɻ झຯ" ిࢠ޻࡞⚡ ےτϨ$ ΨδΣοτ%

  4. tvOSΞϓϦͷ։ൃํ๏ʹ͍ͭͯ • ΫϥΠΞϯτ/αʔόܕͷΞϓϦέʔγϣϯ (TVML Kit)

  5. tvOSΞϓϦͷ։ൃํ๏ʹ͍ͭͯ • ωΠςΟϒ։ൃ

  6. OrigamiͷtvOSΞϓϦ ΫϥΠΞϯτ/αʔόܕͰߏங͓ͯ͠ΓɺOrigamiͷECͷ঎඼Ӿ ཡػೳΛఏڙ͍ͯ͠·͢ɻ

  7. OrigamiͷtvOSΞϓϦ • TVMLͷTemplate͕ECͷίϯςϯπͱϚονͨ͠ • ϥΠϒΞοϓσʔτՄೳͰϦϦʔεͷख͕ؒগͳ͍ • ৽͍͠ϓϥοτϑΥʔϜ΁ͷνϟϨϯδ

  8. Ͱ΋ࠓ೔͸ωΠςΟϒ࣮ ૷ʹؔ࿈ͨ͠࿩Λ͠·͢ ! ޷͖ͳࣄ࿩͍͍ͯͬͯ͠ݴΘΕͨ͠

  9. ૣ଎tvOSͷ࿩Λ ͢Δલʹ...

  10. ࠷ۙͷεϚʔτϗʔϜؔ࿈ͷ࿩୊ Alexa

  11. ࠷ۙͷεϚʔτϗʔϜؔ࿈ͷ࿩୊ Google Home

  12. ࠷ۙͷεϚʔτϗʔϜؔ࿈ͷ࿩୊ SiriεϐʔΧʔʁ

  13. ͳͥ͜ͷ࿩୊Λ͔ͨ͠ͱ ͍͏ͱʁ

  14. HomeKit

  15. HomeKitͱ͸ʁ Apple͕ఏڙ͢ΔεϚʔτϗʔϜͷͨΊͷϑϨʔϜϫʔΫɺ HomeKitରԠ୺຤Λൢച͢Δʹ͸MFiೝূ͕ඞཁ

  16. AppleTVͷHomeKitʹ͓͚Δ໾ׂ • Remote Gateway ϦϞʔτίϯτϩʔϧɺΦʔτϝʔγϣϯ͕ՄೳՄೳ

  17. iOS10 HomeΞϓϦ͕ొ৔

  18. tvOS͸ʁ

  19. tvOS10 HomeKitରԠ

  20. tvOS10ͷHomeKitରԠͰԿ͕ग़དྷΔ ͷ͔ʁ • HomeKit frameworkͷҰ෦ػೳ͕Մೳʹͳͬͨ • HomeΞϓϦ͸tvOSʹ͸ଘࡏ͠ͳ͍

  21. ͳͷͰHomeΞϓϦ΋Ͳ ͖Λࢼ࡞ग़དྷͳ͍͔΍ͬ ͯΈͨ

  22. DEMO

  23. tvOSΞϓϦ։ൃͷಛ௃ • ը໘αΠζ • ੍ݶ͞ΕͨετϨʔδ • ύϥϥοΫεΞΠίϯ • ϑΥʔΧε

  24. tvOSΞϓϦ։ൃͷಛ௃ • ը໘αΠζ • ੍ݶ͞ΕͨετϨʔδ • ύϥϥοΫεΞΠίϯ • ϑΥʔΧε ←

    !
  25. ϑΥʔΧεΤϯδϯ

  26. tvOSΞϓϦͷ։ൃʹ͍ͭͯ ϑΥʔΧεͱ͍͏֓೦͸tvOSʹ͔͠ͳ͍΋ͷͰɺ tvOSΞϓϦ։ൃͷ࠷େͷצॴͰ͸ͳ͍͔ͱࢥ͍ͬͯ·͢ɻ αϯϓϧίʔυΛ࡞੒ͨ࣌͠ʹࢥ͍௨Γʹಈ͔ͳ͔ͬͨέʔε ͱɺͦͷରԠʹ͍ͭͯઆ໌͠·͢ɻ ※ ϫʔΫΞϥ΢ϯυͳײ͡΋͢ΔͷͰ΋ͬͱςΫχΧϧͳํ๏ ͕͋Ε͹୭͔͋ͱͰڭ͍͑ͯͩ͘͞ɻ

  27. ͦͷ1

  28. ࢥ͍௨ΓʹϑΥʔΧεग़དྷͳ͍ ͦͷ1

  29. ࢥ͍௨ΓʹϑΥʔΧεग़དྷͳ͍ ͦͷ1

  30. ࢥ͍௨ΓʹϑΥʔΧεग़དྷͳ͍ ͦͷ1 λϒόʔ͔Βӈଆͷηϧ΁ͷϑΥʔΧεΛېࢭ͢Δ override func shouldUpdateFocus(in context: UIFocusUpdateContext) -> Bool

    { if let prev = context.previouslyFocusedView, String(describing:type(of: prev)) == "UITabBarButton" { return false } return true }
  31. ͦͷ2

  32. ࢥ͍௨ΓʹϑΥʔΧεग़དྷͳ͍ ͦͷ2

  33. ࢥ͍௨ΓʹϑΥʔΧεग़དྷͳ͍ ͦͷ2

  34. UIFocusEnvironment Protocol UIFocusEnvironment ProtocolͷσϦήʔτϝιουͰϑΥʔΧ εΛ͏·͘ίϯτϩʔϧग़དྷΔΑ͏ʹ ࣮૷͢Δඞཁ͕͋Δɻ var preferredFocusEnvironments: [UIFocusEnvironment] func

    shouldUpdateFocus(in context: UIFocusUpdateContext) -> Bool { return ൑ఆॲཧ݁Ռ } override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) { //ϑΥʔΧε࣌ʹߦ͍͍ͨॲཧ } https://developer.apple.com/reference/uikit/ uifocusenvironment
  35. Debug Quick Look

  36. Debug _whyIsThisViewNotFocusable σόοά࣌ʹ_whyIsThisViewNotFocusableϝιουΛݺͿ͜ ͱͰݪҼͱߟ͑ΒΕΔࣄ߲Λग़ྗͯ͘͠Ε·͢ɻ

  37. Θ͔ͬͨࣄ શͯͷϝιου͕࢖͑ΔΘ͚Ͱ͸ͳ͍ addHome(withName homeName: String, completionHandler completion: @escaping (HMHome?, Error?)

    -> Void) removeHome(_ home: HMHome, completionHandler completion: @escaping (Error?) -> Void) updatePrimaryHome(HMHome, completionHandler: (Error?) -> Void) Homeͷ࡞੒ʹݶΒͣɺRoom΍ΞΫηαϦʹ͍ͭͯ΋ಉ༷
  38. Θ͔ͬͨࣄ શͯͷϝιου͕࢖͑ΔΘ͚Ͱ͸ͳ͍ • ߟ࡯ • TV͸جຊతʹݟΔ͚ͩͰɺૢ࡞͸͠ͳ͍ࣄ͕ଟ͍(ϦϞί ϯͷૢ࡞͸ͩΔ͍...)ͨΊɺͦͷػೳ͕আ֎͞Ε͍ͯΔͷͰ ͸!

  39. ͓·͚

  40. ͋ͳ͕ͨtvOSΞϓϦ ͷ։ൃΛ͢ΔͷͳΒ ग़ઌͰͷ࣮ػσόοάͭΒ͍

  41. ͋ͳ͕ͨtvOSΞϓϦͷ։ൃΛ͢Δͷͳ Β

  42. ͋ͳ͕ͨtvOSΞϓϦͷ։ൃΛ͢Δͷͳ Β • ࣮ػ(AppleTV)͸ܞଳੑʹ๡͍͠ͷͰɺHomeKitͷૢ࡞෦෼ ͷ։ൃ͸iPhoneͰ΋ߦ͑ΔΑ͏ʹͯͨ͠ํ͕ग़ઌͰ։ൃ͠΍ ͍͢ɻ

  43. γϛϡϨʔλͰྑ͍ͷͰ ͸ʁ!

  44. HomeKitͷDBڞ༗ʹ͍ͭͯ HomeKitͷiCloudʹΑΔDBڞ༗͸ γϛϡϨʔλͰ͸ग़དྷͳ͍

  45. ͓Θ͔Γ͍͚ͨͩͨͩΖ ͏͔!?

  46. ࣮ػ։ൃΛڧ͍ΒΕΔཧ༝ • HomeKit DBڞ༗͸࣮ػ͚ͩ • HomeKit FrameworkͰ͸Home/Room/AccesoryͳͲͷ৽ن ొ࿥ɾ࡟আɾฤू͕ग़དྷͳ͍ • ඞવతʹσʔλ͸iCloudܦ༝ͷHomeKit

    DBڞ༗པΈͱͳ Δ
  47. Enjoy tvOS App Development

  48. ࢀߟจݙ tvOSΞϓϦέʔγϣϯϓϩάϥϛϯάΨΠυ https://developer.apple.com/jp/documentation/General/ Conceptual/AppleTV_PG/ 2017೥ͦ͜tvOSΞϓϦ։ൃΛ࢝Ί͍ͨΤϯδχΞ޲͚ɺUI࣮૷ ϊ΢ϋ΢ू https://techblog.yahoo.co.jp/advent-calendar-2016/tvosapp- tips/

  49. ࢀߟจݙ Apple TV – tvOSೖ໳ – https://developers.cyberagent.co.jp/blog/archives/3642/ UIKitCatalogͷαϯϓϧίʔυ͔ΒtvOSͷϑΥʔΧεΛֶͿ http://qiita.com/hanawat/items/a2542df65e0534979cb0 ϚωʔϑΥϫʔυͷtvOSΞϓϦέʔγϣϯΛ։ൃͨ͠࿩

    https://moneyforward.com/engineers_blog/2016/02/26/ moneyforward-tvos/
  50. Ҏ্