cocoa coders 141113-watch
TRANSCRIPT
![Page 1: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/1.jpg)
WATCHWhat might it be good for, and how might we use it?
Carl Brown, CocoaCoder.org
November 13, 2014@CarlBrwn @CocoaCoder
![Page 2: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/2.jpg)
GET READY TO FIT INThe race is about to Start!
![Page 3: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/3.jpg)
SDK SHOULD DROP THIS MONTHBut what’s in it?
![Page 4: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/4.jpg)
KREMLINOLOGY“… to examine the smallest minutiae to learn what was happening inside
the walls of [a closed system]”c.f. http://www.imore.com/nsfw-september-apple-event-kremlinology-and-blind-luck
![Page 5: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/5.jpg)
NOTABLE KREMLINOLOGIST @_DAVIDSMITHhttp://david-smith.org/blog/2014/11/06/expectations-for-watchkit/
http://developingperspective.com/2014/10/31/201/
![Page 6: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/6.jpg)
WATCH — DEVELOPER VIEW
• With Apple Watch, developers can create WatchKit apps with actionable notifications and Glances that provide timely information.
• Starting later next year, developers will be able to create fully native apps for Apple Watch.
http://www.apple.com/pr/library/2014/09/09Apple-Unveils-Apple-Watch-Apples-Most-Personal-Device-Ever.html
![Page 7: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/7.jpg)
ACTIONABLE NOTIFICATIONSNotifications present the user with options
![Page 8: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/8.jpg)
LOOK FAMILIAR?That looks an awful lot like iOS8 interactive notifications…
![Page 9: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/9.jpg)
PRE-WATCH NOTIFICATIONS
•BTLE Profile based
•One-way
•Pebble Watch, et. al.
https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Introduction/Introduction.html
![Page 10: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/10.jpg)
PRE-WATCH NOTIFICATIONSOLD AND BUSTED
https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Introduction/Introduction.html
![Page 11: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/11.jpg)
ACTIONABLE NOTIFICATIONSThe new Hotness
![Page 12: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/12.jpg)
GLANCESSwipe from Bottom to Open
Side to Side to Switch Between
![Page 13: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/13.jpg)
DÉJÀ VU?Glances act like Today Screen Widgets, don’t you think?
![Page 14: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/14.jpg)
POSTULATED:WATCH Actionable Notifications and Glances will be implemented in
WatchKit similarly to iOS8 Notifications and Widgets
![Page 15: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/15.jpg)
ACTIONABLE NOTIFICATIONSHow might you create one?
![Page 16: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/16.jpg)
CREATING NEW NOTIFICATIONS let firstAction = UIMutableUserNotificationAction() firstAction.identifier = Actions.first.rawValue firstAction.title = "FIRST" firstAction.activationMode = UIUserNotificationActivationMode.Background firstAction.authenticationRequired = true firstAction.destructive = false
let notificationCategory = UIMutableUserNotificationCategory() notificationCategory.identifier = categoryID !notificationCategory.setActions([firstAction, secondAction, resetAction], forContext: UIUserNotificationActionContext.Default)
let types = UIUserNotificationType.Alert | UIUserNotificationType.Sound let settings = UIUserNotificationSettings(forTypes: types, categories: NSSet(object: notificationCategory)) !UIApplication.sharedApplication().registerUserNotificationSettings(settings)
![Page 17: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/17.jpg)
SENDING NEW NOTIFICATIONS
let notification = UILocalNotification() notification.alertBody = “Text Here" notification.soundName = UILocalNotificationDefaultSoundName notification.fireDate = NSDate() notification.category = categoryID UIApplication.sharedApplication().scheduleLocalNotification(notification)
![Page 18: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/18.jpg)
HANDLING NEW NOTIFICATIONS func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forLocalNotification notification: UILocalNotification, completionHandler: () -> Void) { if notification.category == categoryID { let action:Actions = Actions(rawValue: identifier!)! switch action{ case Actions.first: doStuff() case Actions.cancel: cancelStuff() } } completionHandler() }
![Page 19: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/19.jpg)
GLANCESHow might you create one?
![Page 20: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/20.jpg)
CREATING GLANCES/WIDGETS
![Page 21: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/21.jpg)
CONFIGURING GLANCES/WIDGETS
![Page 22: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/22.jpg)
IMPLEMENTING GLANCES/WIDGETS
• Must use Auto layout
• Use setPreferredContentSize:
class TodayViewController: UIViewController, NCWidgetProviding { override func viewDidLoad() {} override func viewDidAppear(animated: Bool) {} override func viewDidLayoutSubviews() {} }
![Page 23: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/23.jpg)
UPDATING GLANCES/WIDGETS func widgetPerformUpdateWithCompletionHandler( completionHandler: ((NCUpdateResult) -> Void)!) { doStuff { error in if error == nil { self.update() completionHandler(.NewData) } else { completionHandler(.NoData) } } }
![Page 24: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/24.jpg)
RESIZING WIDGETS
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { coordinator.animateAlongsideTransition({ (context: UIViewControllerTransitionCoordinatorContext!) -> Void in self.preferredContentSize = size; }, completion: { (context: UIViewControllerTransitionCoordinatorContext!) -> Void in self.view.alpha = 1.0 }) }
![Page 25: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/25.jpg)
UNANSWERED QUESTIONS
• Will we be able to access to sensor info (accelerometer, etc) in this month’s SDK?
• How does your app know if there’s a connected watch?
• Will the same code get called for NotificationCenter and WATCH by default?
• Will Apple allow “WATCH Required” apps in January or will your app have to function without one?
• How long before WatchKit apps can be submitted for review?
![Page 26: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/26.jpg)
SO WHAT’S A GOOD USE FOR A
GLANCE?Good Question.
!
Guessing there will be some risk. !
Thoughts?
http://techcrunch.com/2014/10/30/apple-no-longer-rejecting-calculator-widgets-from-the-app-store/
![Page 27: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/27.jpg)
SO WHAT’S A GOOD USE FOR A
GLANCE?Good Question.
!
Guessing there will be some risk. !
Thoughts?
http://www.tuaw.com/2014/11/12/overglide-is-a-game-for-your-ios-notification-screen/
![Page 28: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/28.jpg)
N.F.W. — JUST DON’TA Plea on behalf of your users
http://www.campaignlive.com/article/apple-watch-its-time-new-ad-designs/1321477
![Page 29: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/29.jpg)
CONSIDER THISA Plea on behalf of your potential users
http://www.wired.com/2014/11/where-fitness-trackers-fail/
![Page 30: Cocoa coders 141113-watch](https://reader037.vdocuments.us/reader037/viewer/2022103002/559969fd1a28ab0e6a8b473a/html5/thumbnails/30.jpg)
FURTHER RESOURCES• http://david-smith.org/blog/2014/11/06/expectations-for-watchkit/
• http://www.thinkandbuild.it/interactive-notifications-with-notification-actions/
• WWDC 2014 Session 205: Creating Extensions for iOS and OS X, Part 1
• http://www.raywenderlich.com/83809/ios-8-today-extension-tutorial
• http://www.mutualmobile.com/posts/apple-watch-apps-want-to-write
• http://www.wired.com/2014/11/where-fitness-trackers-fail/
• http://keynotopia.com/apple-watch-ui-kit/
• https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Introduction/Introduction.html