Post

Replies

Boosts

Views

Activity

Reply to BGTaskScheduler crashes on iOS 18.4
That seems to be the replacement for .backgroundTask(.appRefresh(...)) func registerAppRefresh( _ taskID: String, handler: @escaping () async -> () ) { BGTaskScheduler.shared.register( forTaskWithIdentifier: taskID, using: nil ) { bgTask in let task = Task { await handler() bgTask.setTaskCompleted(success: true) } bgTask.expirationHandler = { task.cancel() } } } // use taskID and action from .backgroundTask(.appRefresh(taskID), action: action) registerAppRefresh(<taskID>, action)
Mar ’25
Reply to BGTaskScheduler crashes on iOS 18.4
That seems to be the replacement for .backgroundTask(.appRefresh(...)) func registerAppRefresh( _ taskID: String, handler: @escaping () async -> () ) { BGTaskScheduler.shared.register( forTaskWithIdentifier: taskID, using: nil ) { bgTask in let task = Task { await handler() bgTask.setTaskCompleted(success: true) } bgTask.expirationHandler = { task.cancel() } } } // use taskID and action from .backgroundTask(.appRefresh(taskID), action: action) registerAppRefresh(<taskID>, action)
Replies
Boosts
Views
Activity
Mar ’25
Reply to BGTaskScheduler crashes on iOS 18.4
I have a similar issue. In my case, it crashes when submitting the request ( BGTaskScheduler.shared.submit(request) ) And it's still valid with the last iOS update: 18.4 (22E5216h) Our task identifiers are long and in the reverse-domain style. It seems, that the new bata has some multithreading issue with the task registration.
Replies
Boosts
Views
Activity
Mar ’25