Watch os 2.0
-
Upload
grady-zhuo -
Category
Technology
-
view
79 -
download
4
Transcript of Watch os 2.0
How it Work? (watchOS 1)
WatchKit ExtensionWatchKit UI
iOS App
WatchKit WatchKit
How it Work? (watchOS 1)
WatchKit ExtensionWatchKit UI
iOS App
WatchKit WatchKit
Modified on Architecture
WatchKit ExtensionWatchKit UI
iOS App
Available Hardwares
WatchKit Extension
WatchKit UIDigital Crown
Taptic Engine
Networking
Microphone
Heart Rate Sensor
Accelerometer
Gyroscope
Available System Technologies
WatchKit Extension
WatchKit UI
ClockKitContacts Core Data Core Foundation Core Graphics Core Location Core Motion EventKit Foundation HealthKit
HomeKit ImageIO MapKit Mobile Core Services PassKit Security System Configuration Watch Connectivity WatchKit
Available System Technologies
❖ WatchConnectivity
❖ Complication - ClockKit
❖ Digital Crown - WKInterfacePicker
❖ Haptic - WKInterfaceDevice
❖ MediaPlayer - WKInterfaceController
❖ AudioRecording - WKInterfaceController
How do you get data to the watch App?
WatchConnectivity NSURLSession
WatchConnectivity
The Watch Connectivity framework (WatchConnectivity.framework) provides a two-way communications conduit between an iOS app and a WatchKit app on a paired Apple Watch.
WatchConnectivity
The Watch Connectivity framework (WatchConnectivity.framework) provides a two-way communications conduit between an iOS app and a WatchKit app on a paired Apple Watch.
Setup
if (WCSession.isSupported()) {
let session = WCSession.defaultSession()
session.delegate = self // conforms to WCSessionDelegate
session.activateSession() }
Session State
Session State
paired
Session State
watchAppInstalled
paired
Session State
watchAppInstalled
paired
complicationEnabled
Session State
watchAppInstalled
reachable
paired
complicationEnabled
Session State
watchAppInstalled
reachable
paired
complicationEnabledreachable
3 + 1 Transfer Types❖ Background transfers
• Application context
• User info transfer
• File transfer
❖ Interactive messaging
• Live communication
Background transfers
Background transfers ❖ Content not needed immediately
❖ OS intelligently transfers content
❖ Queue up content
❖ OS transfers content
❖ Sending side can exit
• Pick opportune time
• Delivers on receiver next launch
Background transfers ❖ Content not needed immediately
❖ OS intelligently transfers content
❖ Queue up content
❖ OS transfers content
❖ Sending side can exit
• Pick opportune time
• Delivers on receiver next launch
Recommended
3 + 1 Transfer Types❖
• Application context
• User info transfer
• File transfer
❖ Interactive messaging
• Live communication
Background transfers
Application context ❖ Most interesting/relevant content
❖ Overriding behavior
❖ Dictionary
❖ Property list types
❖ Recommended use cases
• Many Apple Watch apps
• Glances
applicationContext receivedApplicationContext
applicationContext receivedApplicationContext
iOS App
iOS App
applicationContext receivedApplicationContext
A
update
iOS App
applicationContext receivedApplicationContext
A
B
update
A
applicationContext
B
iOS App
receivedApplicationContext
B A
applicationContext
B
iOS App
receivedApplicationContext
BB
Watch Extension
applicationContext
B
iOS App
receivedApplicationContext
B
Current B
B
User info transfer
❖ Queue user infos (dictionaries)
❖ Property list types(String, Number, Array, Dictionary…)
❖ In memory content
❖ Access to outstanding content in queue
Background Queue Outstanding User Info Transfers
Background Queue Outstanding User Info Transfers
Watch Game
Background Queue Outstanding User Info Transfers
L1
Background Queue Outstanding User Info Transfers
L1
L2
Background Queue Outstanding User Info Transfers
L1 L2
L3
Background Queue Outstanding User Info Transfers
L1 L2 L3
iOS Game
Background Queue Outstanding User Info Transfers
L1 L2 L3
L1
didReceiveUserInfo
iOS Game
didReceiveUserInfo
Background Queue Outstanding User Info Transfers
L2 L3
L1L2
Background Queue Outstanding User Info Transfers
L3
iOS Game
L1L2
L3
didReceiveUserInfo
File transfer
❖ Very similar to user info transfer
❖ Queue files
❖ Access to outstanding content in queue
❖ Additional metadata
❖ Small
• Property list types
Outstanding File Transfers ~/Documents/Inbox/
Outstanding File Transfers ~/Documents/Inbox/
iOS App
A
Outstanding File Transfers ~/Documents/Inbox/
iOS App
B
A
Outstanding File Transfers ~/Documents/Inbox/
iOS App
A B
C
Outstanding File Transfers ~/Documents/Inbox/
iOS App
A B C
Outstanding File Transfers ~/Documents/Inbox/
iOS App
A B C
Watch Extension
Outstanding File Transfers ~/Documents/Inbox/
iOS App
A B C
didReceiveFile
A
Outstanding File Transfers ~/Documents/Inbox/
iOS App
B C
didReceiveFile
A
B
Outstanding File Transfers ~/Documents/Inbox/
iOS App
C
didReceiveFile
A
B
C
Live communication
❖ Devices connected Watch
❖ Check reachable == true
❖ Small
• Property list types
iOS App
session.reachable == trueWatch
Extension
iOS App
session.reachable == true
sendMessage:
Watch Extension
A
iOS App
session.reachable == trueWatch
ExtensionR
iOS App
session.reachable == trueWatch
Extension
replyHandler()
R
Live communication func sendMessage( message: [String : AnyObject], replyHandler: (([String : AnyObject]) -> Void)?, errorHandler: ((NSError) -> Void)?)
optional func session( session: WCSession, didReceiveMessageData messageData: NSData, replyHandler: (NSData) -> Void)
On Receiver side (by delegate)
On Sender Side
Clock Face
Clock Face
Complication
Complication Families
CLKComplicationTemplate
CLKComplicationTemplate ModularLargeStandardBody
class CLKComplicationTemplateModularLargeStandardBody : CLKComplicationTemplate { var headerTextProvider : CLKTextProvider var body1TextProvider : CLKTextProvider var body2TextProvider : CLKTextProvider? var headerImageProvider : CLKImageProvider?}
CLKComplicationDataSource
CLKComplicationServer
Reload
Timeline
WatchKit Extension
Time Travel
Timeline9:00
Lunch!12:00 PM
12:00
Coffee!1:30 PM
1:30
Dinner!6:30 PM
Timeline Entry9:00
Lunch!12:00 PM
Timeline Entry12:00
Coffee!1:30 PM
Timeline Entry1:30
Dinner!6:30 PM
9:00 12:00 1:00 2:00
Time Travel
Configure
Configure
Summary❖ Extension has been moved to on Watch.
❖ All the most hardware API on the Watch can be used.
❖ Connect with iOS App by WatchConnectivity.
❖ Complications can be provided by Watch App.
❖ Almost all CocoaTouch frameworks are supported.
❖ Now you can play Taptic Engine.
❖ Digital Crown can be used on Simulator.
Thanks for your attention