If background time is about to expire, switch to a minimal “save critical data and stop” path.
TaskServicesStartTaskAndAllowInBackground
TaskServicesCancelTask
When app is suspending:
Start background allowance (TaskServicesStartTaskAndAllowInBackground) and do your normal save/upload work.
If quotaWillExpireEvent fires:
quotaWillExpireEvent
State: EmergencySaveMinimal
EmergencySaveMinimal
Stop optional work.
Save only critical state (fastest possible).
Call TaskServicesCancelTask to end the task and exit quickly.
Assign quotaWillExpireEvent on TaskServicesStartTaskAndAllowInBackground and add it as a Global Transition to your emergency state.
Last updated 1 month ago