Cocoa coders 141113-watch
-
Upload
carl-brown -
Category
Software
-
view
146 -
download
0
Transcript of 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
GET READY TO FIT INThe race is about to Start!
SDK SHOULD DROP THIS MONTHBut what’s in it?
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
NOTABLE KREMLINOLOGIST @_DAVIDSMITHhttp://david-smith.org/blog/2014/11/06/expectations-for-watchkit/
http://developingperspective.com/2014/10/31/201/
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
ACTIONABLE NOTIFICATIONSNotifications present the user with options
LOOK FAMILIAR?That looks an awful lot like iOS8 interactive notifications…
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
PRE-WATCH NOTIFICATIONSOLD AND BUSTED
https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Introduction/Introduction.html
ACTIONABLE NOTIFICATIONSThe new Hotness
GLANCESSwipe from Bottom to Open
Side to Side to Switch Between
DÉJÀ VU?Glances act like Today Screen Widgets, don’t you think?
POSTULATED:WATCH Actionable Notifications and Glances will be implemented in
WatchKit similarly to iOS8 Notifications and Widgets
ACTIONABLE NOTIFICATIONSHow might you create one?
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)
SENDING NEW NOTIFICATIONS
let notification = UILocalNotification() notification.alertBody = “Text Here" notification.soundName = UILocalNotificationDefaultSoundName notification.fireDate = NSDate() notification.category = categoryID UIApplication.sharedApplication().scheduleLocalNotification(notification)
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() }
GLANCESHow might you create one?
CREATING GLANCES/WIDGETS
CONFIGURING GLANCES/WIDGETS
IMPLEMENTING GLANCES/WIDGETS
• Must use Auto layout
• Use setPreferredContentSize:
class TodayViewController: UIViewController, NCWidgetProviding { override func viewDidLoad() {} override func viewDidAppear(animated: Bool) {} override func viewDidLayoutSubviews() {} }
UPDATING GLANCES/WIDGETS func widgetPerformUpdateWithCompletionHandler( completionHandler: ((NCUpdateResult) -> Void)!) { doStuff { error in if error == nil { self.update() completionHandler(.NewData) } else { completionHandler(.NoData) } } }
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 }) }
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?
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/
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/
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
CONSIDER THISA Plea on behalf of your potential users
http://www.wired.com/2014/11/where-fitness-trackers-fail/
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