Publicité
Publicité

Contenu connexe

Publicité
Publicité

Driving User Engagement with watchOS 3

  1. WITH WATCHOS 3 DRIVING USER ENGAGEMENT KRISTINA THAI IOS SOFTWARE ENGINEER ⌚ @KRISTINATHAI
  2. @KRISTINATHAI USER ENGAGEMENT 🙋 📲🙋 🌧 🍝 🌇
  3. @KRISTINATHAI 💇 ??? 💃 🏄 USER ENGAGEMENT
  4. @KRISTINATHAI ⌚ Background Tasks Complications Local Notifications USER ENGAGEMENT
  5. COMPLICATIONS
  6. @KRISTINATHAI
  7. @KRISTINATHAI
  8. @KRISTINATHAI
  9. @KRISTINATHAI
  10. @KRISTINATHAI import ClockKit class ComplicationController: NSObject, CLKComplicationDataSource { // MARK: - Timeline Configuration func getSupportedTimeTravelDirections(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimeTravelDirections) -> Void) { handler([.forward, .backward]) } func getTimelineStartDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) { handler(nil) } func getTimelineEndDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) { handler(nil) } func getPrivacyBehavior(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationPrivacyBehavior) -> Void) { handler(.showOnLockScreen) } // MARK: - Timeline Population func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) { // Call the handler with the current timeline entry handler(nil) } func getTimelineEntries(for complication: CLKComplication, before date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) { // Call the handler with the timeline entries prior to the given date handler(nil) } func getTimelineEntries(for complication: CLKComplication, after date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) { // Call the handler with the timeline entries after to the given date handler(nil) } // MARK: - Placeholder Templates func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) { // This method will be called once per supported complication, and the results will be cached handler(nil) } }
  11. @KRISTINATHAI Optional @KRISTINATHAI
  12. @KRISTINATHAI import ClockKit class ComplicationController: NSObject, CLKComplicationDataSource { // MARK: - Timeline Population func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) { // Call the handler with the current timeline entry handler(nil) } func getTimelineEntries(for complication: CLKComplication, before date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) { // Call the handler with the timeline entries prior to the given date handler(nil) } func getTimelineEntries(for complication: CLKComplication, after date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) { // Call the handler with the timeline entries after to the given date handler(nil) } }
  13. @KRISTINATHAI func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) { // Call the handler with the current timeline entry handler(nil) }
  14. https://theswiftdev.com/2016/04/28/clockkit-complications-cheat-sheet/ CLKComplicationTemplate @KRISTINATHAI
  15. @KRISTINATHAI
  16. @KRISTINATHAI
  17. @KRISTINATHAI func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) { // Call the handler with the current timeline entry let template = CLKComplicationTemplateModularLargeStandardBody() template.headerTextProvider = CLKSimpleTextProvider(text: “12:00-2:00PM”) template.body1TextProvider = CLKSimpleTextProvider(text: "Lunch with Lucas") template.body2TextProvider = CLKSimpleTextProvider(text: "Saru Sushi") let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template) handler(timelineEntry) }
  18. @KRISTINATHAI
  19. BACKGROUND TASKS
  20. @KRISTINATHAI
  21. @KRISTINATHAI BACKGROUND TASKS WKApplicationRefreshBackgroundTask⌚ WKSnapshotRefreshBackgroundTask📷 WKWatchConnectivityRefreshBackgroundTask📲 WKURLSessionRefreshBackgroundTask🌐
  22. @KRISTINATHAI WKApplicationRefreshBackgroundTask⌚ ⌚ 🌐⌚ NSURLSession 📷⌚ Snapshots Update app from background
  23. @KRISTINATHAI WKSnapshotRefreshBackgroundTask📷 Make updates to your app’s UI Supporting up-to-date snapshots keeps your users informed
  24. @KRISTINATHAI WKURLSessionRefreshBackgroundTask🌐 🌐⌚ Trigger NSURLSession to update app from background
  25. @KRISTINATHAI WKWatchConnectivityRefreshBackgroundTask📲 📱⌚ Get latest data from iPhone via Watch Connectivity 📱⌚ Be a good battery/data citizen by pulling data from server only once 🌐
  26. LOCAL NOTIFICATIONS
  27. @KRISTINATHAI LOCAL NOTIFICATIONS Like push notifications, but scheduled locally Handled by UNUserNotificationCenter (allows management of duplicates sent to both devices)
  28. @KRISTINATHAI // Create the content
 let content = UNMutableNotificationContent() content.title = NSString.localizedUserNotificationString(forKey: "Hello!", arguments: nil) content.body = NSString.localizedUserNotificationString(forKey: "Hello_message_body", arguments: nil) content.sound = UNNotificationSound.default() // Deliver the notification in five seconds. let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5, repeats: false) let request = UNNotificationRequest.init(identifier: "FiveSecond", content: content, trigger:trigger) // Schedule the notification. let center = UNUserNotificationCenter.current() center.add(request) Create scheduled local notification
  29. @KRISTINATHAI LOCAL NOTIFICATIONS UNUserNotificationCenter Create custom responses for your notifications
  30. @KRISTINATHAI Respond to custom notification action func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { if response.actionIdentifier == "Complete" { //Handle response here } }
  31. @KRISTINATHAI BOTTOM LINE Use these to engage your user without any direct interaction ⌚ Background Tasks Complications Local Notifications
  32. @KRISTINATHAI RESOURCES kristina.io/watchos-3-key-takeaways-from-wwdc16
 kristina.io/watchos-3-key-takeaways-from-wwdc16-part-2
  33. kristina.io
 me@kristina.io @kristinathai THANK YOU -
Publicité