driving user engagement with watchos 3
TRANSCRIPT
WITH WATCHOS 3DRIVING USER ENGAGEMENT
KRISTINA THAI IOS SOFTWARE ENGINEER
⌚
@KRISTINATHAI
@KRISTINATHAI
USER ENGAGEMENT🙋
📲🙋
🌧🍝🌇
@KRISTINATHAI
💇???💃🏄
USER ENGAGEMENT
@KRISTINATHAI
⌚Background
TasksComplications
Local Notifications
USER ENGAGEMENT
COMPLICATIONS
@KRISTINATHAI
@KRISTINATHAI
@KRISTINATHAI
@KRISTINATHAI
@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) } }
@KRISTINATHAI
Optional
@KRISTINATHAI
@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) } }
@KRISTINATHAI
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
// Call the handler with the current timeline entry
handler(nil) }
https://theswiftdev.com/2016/04/28/clockkit-complications-cheat-sheet/
CLKComplicationTemplate@KRISTINATHAI
@KRISTINATHAI
@KRISTINATHAI
@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) }
@KRISTINATHAI
BACKGROUND TASKS
@KRISTINATHAI
@KRISTINATHAI
BACKGROUND TASKSWKApplicationRefreshBackgroundTask⌚
WKSnapshotRefreshBackgroundTask📷
WKWatchConnectivityRefreshBackgroundTask📲
WKURLSessionRefreshBackgroundTask🌐
@KRISTINATHAI
WKApplicationRefreshBackgroundTask⌚
⌚ 🌐⌚NSURLSession
📷⌚Snapshots
Update app from background
@KRISTINATHAI
WKSnapshotRefreshBackgroundTask📷
Make updates to your app’s UISupporting up-to-date snapshots keeps your users informed
@KRISTINATHAI
WKURLSessionRefreshBackgroundTask🌐
🌐⌚Trigger NSURLSession to update app from background
@KRISTINATHAI
WKWatchConnectivityRefreshBackgroundTask📲
📱⌚Get latest data from iPhone via Watch Connectivity
📱⌚Be a good battery/data citizen by pulling data from server only once
🌐
LOCAL NOTIFICATIONS
@KRISTINATHAI
LOCAL NOTIFICATIONSLike push notifications, but scheduled locally
Handled by UNUserNotificationCenter(allows management of duplicates sent to both devices)
@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
@KRISTINATHAI
LOCAL NOTIFICATIONSUNUserNotificationCenter
Create custom responses for your notifications
@KRISTINATHAI
Respond to custom notification action
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { if response.actionIdentifier == "Complete" { //Handle response here } }
@KRISTINATHAI
BOTTOM LINE
Use these to engage your user without any direct interaction
⌚Background
TasksComplications
Local Notifications
@KRISTINATHAI
RESOURCES
kristina.io/watchos-3-key-takeaways-from-wwdc16
kristina.io/watchos-3-key-takeaways-from-wwdc16-part-2
kristina.io [email protected] @kristinathai
THANK YOU-