Yes, I am also using the SwiftUI life cycle and have an identical extension declaration to yours in both the App and Info.plist. I am quite certain that this is how you declare the extension delegate since the debugger will print an error if you try scheduling a background task without declaring it in this way. Perhaps we are missing a step.
On that note, I can't seem to schedule background tasks. My handle( ) method never receives a WKApplicationRefreshBackgroundTask after the following code block is called:
func scheduleBackgroundUpdate() {
let fireDate = Date(timeIntervalSinceNow: 10)
print("\nActivityManager: Scheduled background process will run at: \(fireDate.description)\n")
WKExtension.shared().scheduleBackgroundRefresh(withPreferredDate: fireDate, userInfo: nil)
{ (error) in
if error == nil {
print("\nWKExtension: Scheduled background process successfully.")
}
else {
print("WKExtension: Could not schedule background process.")
}
}
}
error always results in nil, indicating that it should work, but I never receive an event update. I do get event updates for applicationDidFinishLaunching and WKSnapshotRefreshBackgroundTask, however.
Do you have any idea why this might be?
Thank you.