How to check for cancellation of background task

When using the old withTaskCancellationHandler(operation:onCancel:isolation:) to run background tasks, you were notified that the background task gets cancelled via the handler being called. SwiftUI provides the backgroundTask(_:action:) modifier which looks quite handy. However how can I check if the background task will be cancelled to avoid being terminated by the system?

I have tried to check that via Task.isCancelled but this always returns false no matter what.

Is this not possible when using the modifier in which case I should file a bug report?

Thanks for your help

How to check for cancellation of background task
 
 
Q