Post

Replies

Boosts

Views

Activity

Apple Watch background task
I wish to wake a standalone watch app from the background once daily. The user will add the app's complication to the watch Home Screen. My code to schedule the task is below. My question is as follows. Is it kosher to call this code in func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) so as to schedule the next background task for the same time next day? Thank you! private func scheduleBackgroundTask() {         let today = Calendar.current.date(bySettingHour: 21, minute: 0, second: 0, of: .now)!         let tomorrow = Calendar.current.date(byAdding: .day, value: 1, to: today)!         WKExtension.shared().scheduleBackgroundRefresh(withPreferredDate: tomorrow, userInfo: nil) { error in             if let error = error {                 print(error.localizedDescription)             } else {                 print(#function)             }         }     }
0
0
569
Dec ’22