cocoa coders 141113-watch

30
WATCH What might it be good for, and how might we use it? Carl Brown, CocoaCoder.org November 13, 2014 @CarlBrwn @CocoaCoder

Upload: carl-brown

Post on 06-Jul-2015

152 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Cocoa coders 141113-watch

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

GET READY TO FIT INThe race is about to Start!

Page 3: Cocoa coders 141113-watch

SDK SHOULD DROP THIS MONTHBut what’s in it?

Page 4: Cocoa coders 141113-watch

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

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

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

ACTIONABLE NOTIFICATIONSNotifications present the user with options

Page 8: Cocoa coders 141113-watch

LOOK FAMILIAR?That looks an awful lot like iOS8 interactive notifications…

Page 9: Cocoa coders 141113-watch

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

PRE-WATCH NOTIFICATIONSOLD AND BUSTED

https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Introduction/Introduction.html

Page 11: Cocoa coders 141113-watch

ACTIONABLE NOTIFICATIONSThe new Hotness

Page 12: Cocoa coders 141113-watch

GLANCESSwipe from Bottom to Open

Side to Side to Switch Between

Page 13: Cocoa coders 141113-watch

DÉJÀ VU?Glances act like Today Screen Widgets, don’t you think?

Page 14: Cocoa coders 141113-watch

POSTULATED:WATCH Actionable Notifications and Glances will be implemented in

WatchKit similarly to iOS8 Notifications and Widgets

Page 15: Cocoa coders 141113-watch

ACTIONABLE NOTIFICATIONSHow might you create one?

Page 16: Cocoa coders 141113-watch

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

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

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

GLANCESHow might you create one?

Page 20: Cocoa coders 141113-watch

CREATING GLANCES/WIDGETS

Page 21: Cocoa coders 141113-watch

CONFIGURING GLANCES/WIDGETS

Page 22: Cocoa coders 141113-watch

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

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

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

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

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

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

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

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

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