diff --git a/WatchApp Extension/Controllers/NotificationController.swift b/WatchApp Extension/Controllers/NotificationController.swift index 0cc9b0011e..9b2aaa71da 100644 --- a/WatchApp Extension/Controllers/NotificationController.swift +++ b/WatchApp Extension/Controllers/NotificationController.swift @@ -14,19 +14,14 @@ import UserNotifications final class NotificationController: WKUserNotificationInterfaceController { override init() { - // Initialize variables here. super.init() - - // Configure interface objects here. } override func willActivate() { - // This method is called when watch view controller is about to be visible to user super.willActivate() } override func didDeactivate() { - // This method is called when watch view controller is no longer visible super.didDeactivate() } diff --git a/WatchApp Extension/ExtensionDelegate.swift b/WatchApp Extension/ExtensionDelegate.swift index 6d3ccada38..05ba0a86f1 100644 --- a/WatchApp Extension/ExtensionDelegate.swift +++ b/WatchApp Extension/ExtensionDelegate.swift @@ -41,55 +41,29 @@ final class ExtensionDelegate: NSObject, WKExtensionDelegate { } func applicationDidFinishLaunching() { - // Perform any final initialization of your application. UNUserNotificationCenter.current().delegate = self } func applicationDidBecomeActive() { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - if WCSession.default.activationState != .activated { WCSession.default.activate() } } - func applicationWillResignActive() { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, etc. - } - - func handleUserActivity(_ userInfo: [AnyHashable : Any]?) { - // Use it to respond to Handoff–related activity. WatchKit calls this method when your app is launched as a result of a Handoff action. Use the information in the provided userInfo dictionary to determine how you want to respond to the action. For example, you might decide to display a specific interface controller. - } - func handle(_ backgroundTasks: Set) { for task in backgroundTasks { switch task { case is WKApplicationRefreshBackgroundTask: os_log("Processing WKApplicationRefreshBackgroundTask") - // Use the WKApplicationRefreshBackgroundTask class to update your app’s state in the background. - // You often use a background app refresh task to drive other tasks. For example, you could use a background app refresh task to start an URLSession background transfer, or to schedule a background snapshot refresh task. - // Your app must schedule background app refresh tasks by calling your extension’s scheduleBackgroundRefresh(withPreferredDate:userInfo:scheduledCompletion:) method. The system never schedules these tasks. - // WKExtension.shared().scheduleBackgroundRefresh(withPreferredDate:userInfo: scheduledCompletion:) - // For more information, see [WKApplicationRefreshBackgroundTask] https://developer.apple.com/reference/watchkit/wkapplicationrefreshbackgroundtask - // Background app refresh tasks are budgeted. In general, the system performs approximately one task per hour for each app in the dock (including the most recently used app). This budget is shared among all apps on the dock. The system performs multiple tasks an hour for each app with a complication on the active watch face. This budget is shared among all complications on the watch face. After you exhaust the budget, the system delays your requests until more time becomes available. break case let task as WKSnapshotRefreshBackgroundTask: os_log("Processing WKSnapshotRefreshBackgroundTask") - // Use the WKSnapshotRefreshBackgroundTask class to update your app’s user interface. You can push, pop, or present other interface controllers, and then update the content of the desired interface controller. The system automatically takes a snapshot of your user interface as soon as this task completes. - // Your app can invalidate its current snapshot and schedule a background snapshot refresh tasks by calling your extension’s scheduleSnapshotRefresh(withPreferredDate:userInfo:scheduledCompletion:) method. The system will also schedule background snapshot refresh tasks to periodically update your snapshot. - // For more information, see WKSnapshotRefreshBackgroundTask. - // For more information about snapshots, see Snapshots. - task.setTaskCompleted(restoredDefaultState: false, estimatedSnapshotExpiration: Date(timeIntervalSinceNow: TimeInterval(minutes: 5)), userInfo: nil) return // Don't call the standard setTaskCompleted handler case is WKURLSessionRefreshBackgroundTask: - // Use the WKURLSessionRefreshBackgroundTask class to respond to URLSession background transfers. break case let task as WKWatchConnectivityRefreshBackgroundTask: os_log("Processing WKWatchConnectivityRefreshBackgroundTask") - // Use the WKWatchConnectivityRefreshBackgroundTask class to receive background updates from the WatchConnectivity framework. - // For more information, see WKWatchConnectivityRefreshBackgroundTask. pendingConnectivityTasks.append(task)