Introduction Features of WatchOS2.
Outline
- Architecture of WatchOS 2
- A bunch of new interface elements.
- Complications. (ClockKit)
- Taptic Engine.
- Accessibility
- Open System URL
- Hints of building Watch app
2. Outline
• Architecture of WatchOS 2
• A bunch of new interface elements.
• Complications. (ClockKit)
• Taptic Engine.
• Accessibility
• Open System URL
• Hints of building Watch app
6. WatchOS 2 provides ways for communicating with
iOS app or network
• Communicate with network:NSURLSession
• Communicate with iOS app:Watch Connectivity
7. Watch App communicates with iOS App
and vice versa
(Watch Connectivity)
• Precondition:WCSession.isSupported()
• Communication categories
• Background transfers
• Interactive messaging
8. Background transfers
• Best when information isn’t needed immediately
• Operating system determines the most suitable
time to send the data
• Content is queued up for transfer
9. Three ways of communicating
for background transfers
• Application Context:Information waiting in a
transfer queue will get overridden by the latest
data.
• User Info Transfer:Information waiting in a
transfer queue will deliver one by one in FIFO
order.(Like openParentApplication)
• File Transfer:Transfer files
10. Interactive messaging
• Precondition:iOS and watch App must be in
reachable state.(They must be connected via
Bluetooth) and watch app must be running in
the foreground.
12. API for background transfers
• Application Context:
• Sender:updateApplicationContext(_:)
• Receiver:session(_:didReceiveApplicationContext:)
• User Info Transfer:
• Sender:transferUserInfo(_:)
• Receiver:session(_:didReceiveUserInfo:)
• File Transfer:
• Sender:transferFile(_:metadata:)
• Receiver:session(_:didReceiveFile:)
Sender has an instance of WCSession
Receiver is instance which implements
WCSessionDelegate
13. API for interactive
messaging
• Sender
• sendMessage(_:replyHandler: errorHandler:)
• sendMessageData(_:replyHandler: errorHandler:)
• Receiver
• session(_:didReceiveMessage:replyHandler:)
• session(_:didReceiveMessageData:replyHandler:)
15. A bunch of new interface
elements
• WKInterfacePicker (Digital crown)
• Alerts and Action Sheets
• WKInterfaceMovie
• WKInterfaceController
• Playing Short Audio and Video Clips(Behavior like WKInterfaceMovie)
• Recording Short Audio Clips
• Animation
• WKAudioFilePlayer
• Playing Extended Audio Content (It needed to connect a blue tooth headset
now)
17. WKInterfacePicker
• A WKInterfacePicker object displays a
sequence of items that the user can navigate
through using the Digital Crown.
• Three types:list、stack、sequence
• Advance:Coordinated images
18. Alerts and Action Sheets
• Alerts and action sheets offer a standard interface for
displaying messages to the user.When tapped, the buttons
call blocks of code that you provide.
• WKInterfaceController:
presentAlertControllerWithTitle:message:preferredStyle:acti
ons:
• WKAlertControllerStyle:Alert, ActionSheet,
SideBySideButtonAlert
• WKAlertAction:Default, Cancel, Destructive
19. WKInterfaceMovie
• A WKInterfaceMovie object lets you embed short
audio or video clips directly into your interface.
• setMovieURL(URL: NSURL)
• setVideoGravity(videoGravity: WKVideoGravity)
• setLoops(loops: Bool)
• setPosterImage(posterImage: WKImage?)
20. Playing Short Audio and
Video Clips
• presentMediaPlayerControllerWithURL(URL:
NSURL, options: [NSObject : AnyObject]?,
completion: (Bool, NSTimeInterval, NSError?) ->
Void)
• dismissMediaPlayerController
23. Playing Extended Audio Content
(WKAudioFilePlayer)
• Precondition: It needed to connect a Bluetooth
Headset with watch.
• WKAudioFilePlayer play WKAudioFilePlayerItem
which contains WKAudioFileAsset(URL, title,
albumTitle, artist, duration)
32. CLKTextProvider
(It is an abstract class)
• e.g. shows “Thursday, October 22” on
complication by CLKDateTextProvider (truncate
automatically)
• Thur, October 22
• Thur, Oct 22
• Oct 22
• 22
41. Hints of building Watch app
• UI is stored in Watch app
• One controller per screen of content
• Layout of WatchKit is flow-based layout
• Code updates UI from the extension
• Manages UI elements through outlets
• Uses target-action design pattern
• Profile with Instruments