Introducing Watch Connectivity - Apple Developer...News App Social Networking App iOS Game Image...
Transcript of Introducing Watch Connectivity - Apple Developer...News App Social Networking App iOS Game Image...
© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
Introducing Watch Connectivity Communication between devices
Chris Jensen watchOS EngineerAlex Ledwith watchOS Engineer
System Frameworks
Session 713
#WWDC15
WatchKit App
iOS App
WatchKit Extension
watchOS 1
Data Store
iOS AppWatchKit
App
WatchKit Extension
watchOS 2
Data Store
Data Store
iOS AppWatchKit
App
WatchKit Extension
watchOS 2
Data Store
Data Store
?How do you get the data to the Apple Watch
WatchConnectivity
WatchConnectivity NSURLSession
Example Apps with watchOS 2 Support
News App
Social Networking
App
iOS Game
Image Editing App
Run Tracker App
Weather App
Surfing App
Sports App
WatchConnectivity
NSURLSession
Complications
WatchConnectivity
Setup
Setup
Always set your apps up to receive incoming WatchConnectivity content
Setup
Always set your apps up to receive incoming WatchConnectivity contentif (WCSession.isSupported()) {
Setup
Always set your apps up to receive incoming WatchConnectivity contentif (WCSession.isSupported()) { let session = WCSession.defaultSession()
Setup
Always set your apps up to receive incoming WatchConnectivity contentif (WCSession.isSupported()) { let session = WCSession.defaultSession() session.delegate = self // conforms to WCSessionDelegate
Setup
Always set your apps up to receive incoming WatchConnectivity contentif (WCSession.isSupported()) { let session = WCSession.defaultSession() session.delegate = self // conforms to WCSessionDelegate session.activateSession() }
Session State
Session State
News App
Session State
News App
Session State
let session = WCSession.defaultSession() session.delegate = self session.activateSession()
News App
Session State
session.paired == false
News App
Session State
session.paired == false
Session State
session.paired == false
Session State
N
session.paired == false
Session State
session.paired == false
Session State
session.paired == false
Session State
session.paired == false
Session State
session.paired == false
News App
Session State
session.paired == false
News App
Session State
session.paired == false
func sessionWatchStateDidChange(_)
News App
Session State
session.paired == true
func sessionWatchStateDidChange(_)
Session State
session.watchAppInstalled == falseNews App
Session State
session.watchAppInstalled == false
Session State
session.watchAppInstalled == false
Session State
session.watchAppInstalled == false
Session State
session.watchAppInstalled == false
Session State
session.watchAppInstalled == false
Session State
session.watchAppInstalled == false
Session State
session.watchAppInstalled == falseNews App
Session State
session.watchAppInstalled == trueNews App
Session State
session.watchAppInstalled == true
session.watchDirectoryURL != nilNews App
Session StateWatch directory
Session StateWatch directory
Directory and its contents’ lifetime is tied to the watchAppInstalled property
Session StateWatch directory
Directory and its contents’ lifetime is tied to the watchAppInstalled propertyUse only for data relevant to the specific instance of your Watch app
Session StateWatch directory
Directory and its contents’ lifetime is tied to the watchAppInstalled propertyUse only for data relevant to the specific instance of your Watch app• ‘Last queued item’ marker
Session StateWatch directory
Directory and its contents’ lifetime is tied to the watchAppInstalled propertyUse only for data relevant to the specific instance of your Watch app• ‘Last queued item’ marker• Preferences
Session StateWatch directory
Directory and its contents’ lifetime is tied to the watchAppInstalled propertyUse only for data relevant to the specific instance of your Watch app• ‘Last queued item’ marker• Preferences• Files queued for transfer
Session State
session.complicationEnabled == falseNews App
Session State
session.complicationEnabled == falseNews App
Session State
News Appsession.complicationEnabled == true
Communication
Alex Ledwith
CommunicationCategories
CommunicationCategories
Background transfers
CommunicationCategories
Background transfers• Content not needed immediately
CommunicationCategories
Background transfers• Content not needed immediately• OS intelligently transfers content
CommunicationCategories
Background transfers• Content not needed immediately• OS intelligently transfers content
Interactive messaging
CommunicationCategories
Background transfers• Content not needed immediately• OS intelligently transfers content
Interactive messaging• Live communication
Background Transfers
Background TransfersContent and user interaction
News App
Background Transfers
CBA
Content and user interaction
News App
Background Transfers
CBAD
Content and user interaction
News App
DC
DC
Background Transfers
BA
Content and user interaction
News App
D C
DC
Background Transfers
BA
Content and user interaction
News App
D C
DC
Background Transfers
BA
Content and user interaction
WatchKit App
News App
DCDC
Background Transfers
BA
Content and user interaction
Background TransfersIntroduction
Background TransfersIntroduction
Queue up content
Background TransfersIntroduction
Queue up contentOS transfers content
Background TransfersIntroduction
Queue up contentOS transfers content• Sending side can exit
Background TransfersIntroduction
Queue up contentOS transfers content• Sending side can exit• Pick opportune time
Background TransfersIntroduction
Queue up contentOS transfers content• Sending side can exit• Pick opportune time• Delivers on receiver next launch
Background TransfersIntroduction
Queue up contentOS transfers content• Sending side can exit• Pick opportune time• Delivers on receiver next launch
Recommended
Background TransfersIntroduction
Queue up contentOS transfers content• Sending side can exit• Pick opportune time• Delivers on receiver next launch
Recommended• Most information not needed immediately
Background TransfersTypes
Background TransfersTypes
Application context
Background TransfersTypes
Application contextUser info transfer
Background TransfersTypes
Application contextUser info transferFile transfer
Background TransfersApplication context
Social Networking
App
Background Transfers
receivedApplicationContext
Application context
applicationContext
Social Networking
App
Background Transfers
receivedApplicationContext
Application context
applicationContext
updateApplicationContext(_:)
Social Networking
App
A
Background Transfers
receivedApplicationContext
Application context
applicationContext
updateApplicationContext(_:)
Social Networking
App
A
Background Transfers
receivedApplicationContext
Application context
applicationContext
updateApplicationContext(_:)
Social Networking
App
A
B
Background Transfers
receivedApplicationContext
Application context
applicationContext
updateApplicationContext(_:)
Social Networking
App
B
Background Transfers
receivedApplicationContext
Application context
applicationContext
updateApplicationContext(_:)
Social Networking
App
B
Background Transfers
receivedApplicationContext
Application context
applicationContext
updateApplicationContext(_:)
Social Networking
App
Background Transfers
receivedApplicationContext
Application context
applicationContext
updateApplicationContext(_:)
Social Networking
App
WatchKit Extension
Background TransfersApplication context: Code
do {let context = // Create context dictionary with latest state
Background TransfersApplication context: Code
do {let context = // Create context dictionary with latest statetry WCSession.defaultSession().updateApplicationContext(context)
Background TransfersApplication context: Code
do {let context = // Create context dictionary with latest statetry WCSession.defaultSession().updateApplicationContext(context)
} catch {// Handle any errors
}
Background TransfersApplication context: Code
// Receiver Callback func session(session: WCSession, didReceiveApplicationContext: applicationContext: [String : AnyObject]) {
// Handle application context dictionary }
Background TransfersApplication context: Code
Background TransfersApplication context
Background TransfersApplication context
Most interesting/relevant content
Background TransfersApplication context
Most interesting/relevant contentOverriding behavior
Background TransfersApplication context
Most interesting/relevant contentOverriding behaviorDictionary
Background TransfersApplication context
Most interesting/relevant contentOverriding behaviorDictionary• Property list types
Background TransfersApplication context
Most interesting/relevant contentOverriding behaviorDictionary• Property list types
Recommended use cases
Background TransfersApplication context
Most interesting/relevant contentOverriding behaviorDictionary• Property list types
Recommended use cases• Many Apple Watch apps
Background TransfersApplication context
Most interesting/relevant contentOverriding behaviorDictionary• Property list types
Recommended use cases• Many Apple Watch apps• Glances
Background TransfersUser info transfer
Game
Background TransfersUser info transfer
Outstanding User Info Transfers
Game
Background TransfersUser info transfer
Outstanding User Info Transfers
L2L1
Game
Background TransfersUser info transfer
Outstanding User Info Transfers
L2L1
transferUserInfo(_:)
Game
Background TransfersUser info transfer
Outstanding User Info Transfers
L2L1
transferUserInfo(_:)
L3
Game
Background TransfersUser info transfer
Outstanding User Info Transfers
L2L1
transferUserInfo(_:)
L3
Game
Background TransfersUser info transfer
Outstanding User Info Transfers
L2L1
transferUserInfo(_:)
L3
Game
Background TransfersUser info transfer
Outstanding User Info Transfers
L2L1
transferUserInfo(_:)
L3iOS Game Game
Background TransfersUser info transfer: Code
let userInfo = // Create dictionary of userInfo
Background TransfersUser info transfer: Code
let userInfo = // Create dictionary of userInfolet userInfoTransfer = WCSession.defaultSession().transferUserInfo(userInfo)
Background TransfersUser info transfer: Code
let userInfo = // Create dictionary of userInfolet userInfoTransfer = WCSession.defaultSession().transferUserInfo(userInfo)
Background TransfersUser info transfer: Code
let transfers = WCSession.defaultSession().outstandingUserInfoTransfers()
// Receiver Callback func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) {
// Handle incoming user info dictionary }
Background TransfersUser info transfer: Code
Background TransfersUser info transfer
Background TransfersUser info transfer
Queue user infos (dictionaries)
Background TransfersUser info transfer
Queue user infos (dictionaries)• Property list types
Background TransfersUser info transfer
Queue user infos (dictionaries)• Property list types
In memory content
Background TransfersUser info transfer
Queue user infos (dictionaries)• Property list types
In memory contentAccess to outstanding content in queue
Background TransfersFile transfer
Image Editing App
Background TransfersFile transfer
Outstanding File Transfers ~/Documents/Inbox/
Image Editing App
Background TransfersFile transfer
Outstanding File Transfers
P1P2
~/Documents/Inbox/
Image Editing App
Background TransfersFile transfer
Outstanding File Transfers
P1P2
transferFile(_: metadata:)
~/Documents/Inbox/
Image Editing App
Background TransfersFile transfer
Outstanding File Transfers
P1P2
P3
transferFile(_: metadata:)
~/Documents/Inbox/
Image Editing App
Background TransfersFile transfer
Outstanding File Transfers
P1P2P3
transferFile(_: metadata:)
~/Documents/Inbox/
Image Editing App
Background TransfersFile transfer
Outstanding File Transfers
P1P2P3
transferFile(_: metadata:)
~/Documents/Inbox/
Image Editing App
Background TransfersFile transfer
Outstanding File Transfers
P1P2P3
transferFile(_: metadata:)
~/Documents/Inbox/
WatchKit ExtensionImage
Editing App
Background TransfersFile transfer: Code
let url = // Retrieve URL of file
Background TransfersFile transfer: Code
let url = // Retrieve URL of filelet metadata = // Create dictionary of metadata
Background TransfersFile transfer: Code
let url = // Retrieve URL of filelet metadata = // Create dictionary of metadatalet fileTransfer = WCSession.defaultSession().transferFile(url, metadata:metadata)
Background TransfersFile transfer: Code
let url = // Retrieve URL of filelet metadata = // Create dictionary of metadatalet fileTransfer = WCSession.defaultSession().transferFile(url, metadata:metadata)
Background TransfersFile transfer: Code
let transfers = WCSession.defaultSession().outstandingFileTransfers()
Background TransfersFile transfer: Delegate callback
// Receiver Callback func session(session: WCSession, didReceiveFile file: WCSessionFile) {
// Handle file URL and metadata in WCSessionFile object }
Background TransfersFile transfer: Delegate callback
// Receiver Callback func session(session: WCSession, didReceiveFile file: WCSessionFile) {
// Handle file URL and metadata in WCSessionFile object }
Background TransfersFile transfer: Delegate callback
WCSessionFile
// Receiver Callback func session(session: WCSession, didReceiveFile file: WCSessionFile) {
// Handle file URL and metadata in WCSessionFile object }
Background TransfersFile transfer: Delegate callback
WCSessionFile• File URL
// Receiver Callback func session(session: WCSession, didReceiveFile file: WCSessionFile) {
// Handle file URL and metadata in WCSessionFile object }
Background TransfersFile transfer: Delegate callback
WCSessionFile• File URL• Metadata
// Receiver Callback func session(session: WCSession, didReceiveFile file: WCSessionFile) {
// Handle file URL and metadata in WCSessionFile object }
Background TransfersFile transfer: Delegate callback
WCSessionFile• File URL• Metadata
Move file to take control
// Receiver Callback func session(session: WCSession, didReceiveFile file: WCSessionFile) {
// Handle file URL and metadata in WCSessionFile object }
Background TransfersFile transfer: Delegate callback
WCSessionFile• File URL• Metadata
Move file to take control• File deleted from inbox
Background TransfersFile transfer
Background TransfersFile transfer
Very similar to user info transfer
Background TransfersFile transfer
Very similar to user info transferQueue files
Background TransfersFile transfer
Very similar to user info transferQueue filesAccess to outstanding content in queue
Background TransfersFile transfer
Very similar to user info transferQueue filesAccess to outstanding content in queueAdditional metadata
Background TransfersFile transfer
Very similar to user info transferQueue filesAccess to outstanding content in queueAdditional metadata• Small
Background TransfersFile transfer
Very similar to user info transferQueue filesAccess to outstanding content in queueAdditional metadata• Small• Property list types
Interactive Messaging
Interactive MessagingIntroduction
iOS App Watch App
Interactive MessagingReachability
Interactive MessagingReachability
Other app available
Interactive MessagingReachability
Other app availableRequired for messaging
Interactive MessagingReachability
Other app availableRequired for messagingProperty on WCSession
WCSession.defaultSession().reachable
Interactive MessagingReachability: iPhone
iOS App
Interactive MessagingReachability: iPhone
Devices connected
iOS App
Interactive MessagingReachability: iPhone
Devices connectedWatch app foreground
iOS App Watch App
Interactive MessagingReachability: iPhone
Devices connectedWatch app foreground
iOS App Watch App
session.reachable == true
Interactive MessagingReachability: Apple Watch
Interactive Messaging
Devices connected
Reachability: Apple Watch
Interactive Messaging
Devices connectedWatchKit extension foreground
Watch App
WatchKit Extension
Reachability: Apple Watch
Interactive Messaging
Devices connectedWatchKit extension foreground
Watch App
WatchKit Extension
session.reachable == true
Reachability: Apple Watch
Interactive MessagingBackground launching: iOS app only
Run Tracker App
WatchKit Extension
Interactive MessagingBackground launching: iOS app only
Run Tracker App
WatchKit Extension
Interactive MessagingBackground launching: iOS app only
Run Tracker App
WatchKit Extension
iOS App Background
Interactive MessagingBackground launching: iOS app only
Run Tracker App
WatchKit Extension
iOS App Background
Interactive MessagingTypes
Interactive MessagingTypes
Dictionary
Interactive MessagingTypes
Dictionary
func sendMessage(message:, replyHandler:, errorHandler:)
Interactive MessagingTypes
Dictionary• Property list types
func sendMessage(message:, replyHandler:, errorHandler:)
Interactive MessagingTypes
Dictionary• Property list types
Data
func sendMessage(message:, replyHandler:, errorHandler:)
Interactive MessagingTypes
Dictionary• Property list types
Data
func sendMessage(message:, replyHandler:, errorHandler:)
func sendMessageData(data:, replyHandler:, errorHandler:)
Interactive MessagingTypes
Dictionary• Property list types
Data• Custom data
func sendMessage(message:, replyHandler:, errorHandler:)
func sendMessageData(data:, replyHandler:, errorHandler:)
Interactive MessagingTypes
Dictionary• Property list types
Data• Custom data• Own serialization
func sendMessage(message:, replyHandler:, errorHandler:)
func sendMessageData(data:, replyHandler:, errorHandler:)
Interactive MessagingReplying
Interactive MessagingReplying
func sendMessage(message:, replyHandler:, errorHandler:)
func sendMessageData(data:, replyHandler:, errorHandler:)
Interactive MessagingReplying
Optional handler
func sendMessage(message:, replyHandler:, errorHandler:)
func sendMessageData(data:, replyHandler:, errorHandler:)
Interactive MessagingReplying
Optional handlerRecommended
func sendMessage(message:, replyHandler:, errorHandler:)
func sendMessageData(data:, replyHandler:, errorHandler:)
Interactive MessagingReplying
Optional handlerRecommended• Confirmation by receiver
func sendMessage(message:, replyHandler:, errorHandler:)
func sendMessageData(data:, replyHandler:, errorHandler:)
Interactive MessagingReplying
Optional handlerRecommended• Confirmation by receiver
Separate delegate callbacks
func sendMessage(message:, replyHandler:, errorHandler:)
func sendMessageData(data:, replyHandler:, errorHandler:)
Interactive MessagingDelegate callbacks
func session(session: WCSession, didReceiveMessage message: [String : AnyObject], replyHandler: ([String : AnyObject]) -> Void) { // Handle message, return reply }
Interactive MessagingDelegate callbacks
func session(session: WCSession, didReceiveMessage message: [String : AnyObject], replyHandler: ([String : AnyObject]) -> Void) { // Handle message, return reply }
Interactive MessagingDelegate callbacks
func session(session: WCSession, didReceiveMessage message: [String : AnyObject]) {
// Handle message }
Interactive MessagingCode
if (WCSession.defaultSession().reachable) {
Interactive MessagingCode
if (WCSession.defaultSession().reachable) {let message = // Create dictionary of content
Interactive MessagingCode
if (WCSession.defaultSession().reachable) {let message = // Create dictionary of contentWCSession.defaultSession().sendMessage(message,
Interactive MessagingCode
if (WCSession.defaultSession().reachable) {let message = // Create dictionary of contentWCSession.defaultSession().sendMessage(message, replyHandler: { ([String : AnyObject]) -> Void in
// Handle reply })
Interactive MessagingCode
if (WCSession.defaultSession().reachable) {let message = // Create dictionary of contentWCSession.defaultSession().sendMessage(message, replyHandler: { ([String : AnyObject]) -> Void in
// Handle reply })
errorHandler: { (NSError) -> Void in // Handle error
});}
Interactive MessagingCode
WatchConnectivity
Setup
WatchConnectivity
Setup • Delegate and activate
WatchConnectivity
Setup • Delegate and activate
Session state
WatchConnectivity
Setup • Delegate and activate
Session state Background transfers
WatchConnectivity
Setup • Delegate and activate
Session state Background transfers• Application context
WatchConnectivity
Setup • Delegate and activate
Session state Background transfers• Application context• User info transfer
WatchConnectivity
Setup • Delegate and activate
Session state Background transfers• Application context• User info transfer• File transfer
WatchConnectivity
Setup • Delegate and activate
Session state Background transfers• Application context• User info transfer• File transfer
Interactive messaging
WatchConnectivity
Setup • Delegate and activate
Session state Background transfers• Application context• User info transfer• File transfer
Interactive messaging• Live communication
WatchConnectivity
NSURLSession
NSURLSessionIntroduction
NSURLSessionIntroduction
Existing foundation class
NSURLSessionIntroduction
Existing foundation classHTTP requests
NSURLSessionIntroduction
Existing foundation classHTTP requestsAvailable in watchOS 2
NSURLSessionIntroduction
Existing foundation classHTTP requestsAvailable in watchOS 2Tetherless Wi-Fi
NSURLSessionWhen to use
NSURLSessionWhen to use
Server has new content
NSURLSessionWhen to use
Server has new contentSimilar to iOS apps
NSURLSessionWhen to use
Server has new contentSimilar to iOS apps• Content tailored for Apple Watch
News App
NSURLSession and WatchConnectivity
WatchKit Extension
News App
NSURLSession and WatchConnectivity
Application Context WatchKit Extension
News App
NSURLSession and WatchConnectivity
Application Context WatchKit Extension
NSURLSession and WatchConnectivity
HTTP Request
Application Context WatchKit ExtensionNews App
NSURLSession and WatchConnectivity
HTTP Request
Application Context WatchKit ExtensionNews App
Complications
Complications
Complications
ComplicationsIntroduction
ComplicationsIntroduction
Two primary tasks
ComplicationsIntroduction
Two primary tasks• Updating clock face
ComplicationsIntroduction
Two primary tasks• Updating clock face• Get content to Apple Watch
ComplicationsUpdating clock face
ComplicationsUpdating clock face
Weather App
WatchKit Extension
ComplicationsUpdating clock face
ClockKit
ComplicationsUpdating clock face
ClockKit
WatchKit Extension
Background
ComplicationsUpdating clock face
ClockKit
WatchKit Extension
Background
ComplicationsUpdating clock face
ClockKit
let server = CLKComplicationServer.sharedInstance()
WatchKit Extension
Background
ComplicationsUpdating clock face
ClockKit
let server = CLKComplicationServer.sharedInstance()server.extendTimelineForComplication(aComplication)
WatchKit Extension
Background
ComplicationsUpdating clock face
ClockKit
WatchKit Extension
Background
ComplicationsUpdating clock face
ClockKit
getCurrentTimelineEntryForComplication(_:withHandler:)
WatchKit Extension
Background
ComplicationsUpdating clock face
ClockKit
getCurrentTimelineEntryForComplication(_:withHandler:)getTimelineEntriesForComplication(_:beforeDate:limit:withHandler:)
WatchKit Extension
Background
ComplicationsUpdating clock face
ClockKit
getCurrentTimelineEntryForComplication(_:withHandler:)getTimelineEntriesForComplication(_:beforeDate:limit:withHandler:)getTimelineEntriesForComplication(_:afterDate:limit:withHandler:)
WatchKit Extension
Background
ComplicationsUpdating clock face
ClockKit
getCurrentTimelineEntryForComplication(_:withHandler:)getTimelineEntriesForComplication(_:beforeDate:limit:withHandler:)getTimelineEntriesForComplication(_:afterDate:limit:withHandler:)getNextRequestedUpdateDateWithHandler(_)
ComplicationsUpdating clock face
ComplicationsUpdating clock face
ClockKit
ComplicationsUpdating clock face
ClockKit Content for past, present, and future
ComplicationsUpdating clock face
ClockKit Content for past, present, and futureBackground launched for updating
ComplicationsUpdating clock face
ClockKit Content for past, present, and futureBackground launched for updatingSpecify when content provided will be stale
ComplicationsUpdating clock face
ClockKit Content for past, present, and futureBackground launched for updatingSpecify when content provided will be stale BUDGETED
ComplicationsUpdating clock face
ClockKit Content for past, present, and futureBackground launched for updatingSpecify when content provided will be stale BUDGETED
Creating Complications with ClockKit Pacific Heights Wednesday 11:00AM
Initial ActivationComplications
ComplicationsInitial activation
ComplicationsInitial activation
ComplicationsInitial activation
ComplicationsInitial activation
ComplicationsInitial activation
WatchKit Extension
Background
WatchKit Extension
Background
ComplicationsInitial activation
NSURLSession
ComplicationsInitial activation
WatchKit Extension
Background
ComplicationsInitial activation
WatchKit Extension
Background
ComplicationsInitial activation
WatchKit Extension
Backgroundsession.reachable == true
ComplicationsInitial activation
WatchKit Extension
Backgroundsession.reachable == true
sendMessage(_:replyHandler:errorHandler:)
ComplicationsInitial activation
WatchKit Extension
Backgroundsession.reachable == true
sendMessage(_:replyHandler:errorHandler:)
ComplicationsInitial activation
WatchKit Extension
BackgroundWeather App Background
session.reachable == true
sendMessage(_:replyHandler:errorHandler:)
ComplicationsInitial activation
WatchKit Extension
BackgroundWeather App Background
session.reachable == true
sendMessage(_:replyHandler:errorHandler:)
ComplicationsInitial activation: Summary
ComplicationsInitial activation: Summary
WatchKit extension will get launched in the background
ComplicationsInitial activation: Summary
WatchKit extension will get launched in the backgroundNSURLSession
ComplicationsInitial activation: Summary
WatchKit extension will get launched in the backgroundNSURLSessionSpecial complication update where iOS app is reachable
ComplicationsInitial activation: Summary
WatchKit extension will get launched in the backgroundNSURLSessionSpecial complication update where iOS app is reachablePopulate as much as possible of the ClockKit timeline
Staying CurrentComplications
ComplicationsStaying current
Cloud
iPhone Apple Watch
ComplicationsPushed
Cloud
iPhone Apple Watch
ComplicationsPushed
Cloud
iPhone Apple Watch Sports App
ComplicationsRequested interval fetch
iPhone Apple Watch
Cloud
ComplicationsRequested interval fetch
iPhone Apple Watch
Cloud
Surfing App
ComplicationsRequested interval fetch
NSURLSession
ComplicationsRequested interval fetch
NSURLSession ClockKit
ComplicationsRequested interval fetch
WatchKit Extension
Background
ComplicationsRequested interval fetch
WatchKit Extension
BackgroundRequest
ComplicationsRequested interval fetch
WatchKit Extension
BackgroundRequest
ComplicationsRequested interval fetch
Response
WatchKit Extension
BackgroundRequest Extend
Timeline
ComplicationsRequested interval fetch
Response
WatchKit Extension
BackgroundRequest Timeline
UpdatesExtend
Timeline
ComplicationsRequested interval fetch
Response
WatchKit Extension
BackgroundRequest Timeline
UpdatesRequest
Next UpdateExtend
Timeline
ComplicationsRequested interval fetch
Response
Request Timeline UpdatesRequest
Next UpdateExtend
Timeline
ComplicationsRequested interval fetch
Response
ComplicationsRequested interval fetch
ComplicationsRequested interval fetch
ComplicationsRequested interval fetch
Request Update ClockKit
ComplicationsRequested interval fetch
Response
ComplicationsRequested interval fetch: Summary
ComplicationsRequested interval fetch: Summary
Use a NSURLSession background session if possible
ComplicationsRequested interval fetch: Summary
Use a NSURLSession background session if possibleNSURLSession requests might not complete until next time the extension runs
ComplicationsRequested interval fetch: Summary
Use a NSURLSession background session if possibleNSURLSession requests might not complete until next time the extension runsRequested update time is a suggestion
ComplicationsRequested interval fetch: Summary
Use a NSURLSession background session if possibleNSURLSession requests might not complete until next time the extension runsRequested update time is a suggestionKeep runtime as short as possible
ComplicationsRequested interval fetch: Summary
Use a NSURLSession background session if possibleNSURLSession requests might not complete until next time the extension runsRequested update time is a suggestionKeep runtime as short as possibleClockKit
ComplicationsRequested interval fetch: Summary
Use a NSURLSession background session if possibleNSURLSession requests might not complete until next time the extension runsRequested update time is a suggestionKeep runtime as short as possibleClockKit
BUDGETED
BUDGETED
ComplicationsPushed
Cloud
iPhone Apple Watch
ComplicationsPushed
Cloud
iPhone Apple Watch Sports App
ComplicationsPushed
ComplicationsPushed: Part 1
ComplicationsPushed: Part 1
PushKit
ComplicationsPushed: Part 2
WatchConnectivity
Pushed: Part 1Complications
ComplicationsPushed: Part 1
PushKit
ComplicationsPushed: Part 1
ComplicationsPushed: Part 1
Updated PushKit framework
ComplicationsPushed: Part 1
Updated PushKit frameworkpushRegistry = PKPushRegistry(queue: dispatch_get_main_queue())
ComplicationsPushed: Part 1
Updated PushKit frameworkpushRegistry = PKPushRegistry(queue: dispatch_get_main_queue())pushRegistry.delegate = self // conforms to PKPushRegistryDelegate
ComplicationsPushed: Part 1
Updated PushKit frameworkpushRegistry = PKPushRegistry(queue: dispatch_get_main_queue())pushRegistry.delegate = self // conforms to PKPushRegistryDelegatepushRegistry.desiredPushTypes = [PKPushTypeComplication]
ComplicationsPushed: Part 1
Updated PushKit frameworkpushRegistry = PKPushRegistry(queue: dispatch_get_main_queue())pushRegistry.delegate = self // conforms to PKPushRegistryDelegatepushRegistry.desiredPushTypes = [PKPushTypeComplication]
func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!)
// Upload push token to server to enable it to send pushes
ComplicationsPushed: Part 1
Updated PushKit frameworkpushRegistry = PKPushRegistry(queue: dispatch_get_main_queue())pushRegistry.delegate = self // conforms to PKPushRegistryDelegatepushRegistry.desiredPushTypes = [PKPushTypeComplication]
func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!)
// Upload push token to server to enable it to send pushesfunc pushRegistry(registry: PKPushRegistry!, didReceiveIncomingPushWithPayload payload: PKPushPayload!, forType type: String!)
// Massage content and prepare to send it to the complication
Pushed: Part 2Complications
ComplicationsPushed: Part 2
WatchConnectivity
ComplicationsPushed: Part 2
ComplicationsPushed: Part 2
session.transferUserInfo(timeLineEntry1)session.transferUserInfo(timeLineEntry2)...
ComplicationsPushed: Part 2
session.transferUserInfo(timeLineEntry1)session.transferUserInfo(timeLineEntry2)...session.transferCurrentComplicationUserInfo(presentTimeLineEntry)
ComplicationsPushed: Part 2
session.transferUserInfo(timeLineEntry1)session.transferUserInfo(timeLineEntry2)...session.transferCurrentComplicationUserInfo(presentTimeLineEntry)
func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) {
// Call ClockKit APIs to update complication}
Pushed: SummaryComplications
Sports App
ComplicationsPushed: Summary
Sports App
ComplicationsPushed: Summary
Push Registration
Sports App
ComplicationsPushed: Summary
Push Registration
Sports App
ComplicationsPushed: Summary
Push RegistrationPush Token
Sports App
ComplicationsPushed: Summary
Push Registration
Push Token
Sports App
ComplicationsPushed: Summary
Push Registration
Push TokenPush Token
Sports App
ComplicationsPushed: Summary
Push Registration
Push Token
Push Token
ComplicationsPushed: Summary
Push Registration
Push Token
Push Token
ComplicationsPushed: Summary
Push
ComplicationsPushed: Summary
Push
ComplicationsPushed: Summary
ComplicationsPushed: Summary
Sports App Background
U1U2
U3
Outstanding User Info Transfers
transferUserInfo(_:)
ComplicationsPushed: Summary
Sports App Background
U1U2U3
Outstanding User Info Transfers
ComplicationsPushed: Summary
Sports App Background
U1U2U3
U4
transferCurrent ComplicationUserInfo(_:)
Outstanding User Info Transfers
ComplicationsPushed: Summary
Sports App Background
U1U2U3 U4
Outstanding User Info Transfers
ComplicationsPushed: Summary
U1U2U3 U4
Outstanding User Info Transfers
ComplicationsPushed: Summary
U1U2U3
U4
Outstanding User Info Transfers
ComplicationsPushed: Summary
WatchKit Extension
Background
Outstanding User Info Transfers
ComplicationsPushed: Summary
WatchKit Extension
Background
WatchKit Extension
Background
ComplicationsPushed: Summary
WatchKit Extension
Background
ComplicationsPushed: Summary
Update ClockKit
ComplicationsPushed: Summary
Update ClockKit
ComplicationsPushed: Summary
ComplicationsPushed: Summary
PushKit
ComplicationsPushed: Summary
PushKitPKPushTypeComplication
ComplicationsPushed: Summary
PushKitPKPushTypeComplicationComplication active on clock face
ComplicationsPushed: Summary
PushKitPKPushTypeComplicationComplication active on clock faceLimited number of pushes per day
ComplicationsPushed: Summary
PushKitPKPushTypeComplicationComplication active on clock faceLimited number of pushes per daytransferUserInfo()
ComplicationsPushed: Summary
PushKitPKPushTypeComplicationComplication active on clock faceLimited number of pushes per daytransferUserInfo()transferCurrentComplicationUserInfo()
ComplicationsPushed: Summary
PushKitPKPushTypeComplicationComplication active on clock faceLimited number of pushes per daytransferUserInfo()transferCurrentComplicationUserInfo()ClockKit
ComplicationsPushed: Summary
PushKitPKPushTypeComplicationComplication active on clock faceLimited number of pushes per daytransferUserInfo()transferCurrentComplicationUserInfo()ClockKit
BUDGETED
BUDGETED
BUDGETED
Wrap Up
Summary
WatchConnectivityNSURLSessionComplications
More Information
DocumentationwatchOS 2 Transition GuideWatchKit Programming Guide
Sample CodeListerWatchKit Catalog
http://developer.apple.com/watchOS
Technical SupportApple Developer ForumsDeveloper Technical Support
General InquiriesJake Behrens, watchOS Frameworks [email protected]
Related Sessions
Introducing WatchKit for watchOS 2 Presidio Tuesday 10:00AM
Privacy and Your App Pacific Heights Tuesday 2:30PM
Building Watch Apps Pacific Heights Tuesday 4:30PM
Security and Your Apps Mission Tuesday 4:30PM
Creating Complications with ClockKit Pacific Heights Wednesday 11:00AM
Networking with NSURLSession Pacific Heights Thursday 9:00AM
WatchKit Tips and Tricks Presidio Friday 10:00AM
Labs
Watch Connectivity Lab Frameworks Lab B Thursday 1:30PM
WatchKit and ClockKit Complications Lab Frameworks Lab A Friday 1:30PM