<!--
{
  "documentType" : "article",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/background-task-cancellation",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Background task cancellation"
}
-->

# Background task cancellation

Constants that indicate why a background task was canceled.

## Discussion

These values are used in conjunction with the [`NSURLErrorBackgroundTaskCancelledReasonKey`](/documentation/Foundation/NSURLErrorBackgroundTaskCancelledReasonKey) key in an [`NSError`](/documentation/Foundation/NSError) object’s `userInfo` dictionary.

## Topics

### Cancellation reasons

[`var NSURLErrorCancelledReasonBackgroundUpdatesDisabled: Int`](/documentation/Foundation/NSURLErrorCancelledReasonBackgroundUpdatesDisabled)

A reason that indicates the system canceled the background task because background tasks are disabled.

[`var NSURLErrorCancelledReasonInsufficientSystemResources: Int`](/documentation/Foundation/NSURLErrorCancelledReasonInsufficientSystemResources)

A reason that indicates the system canceled the background task because it lacks sufficient resources to perform the task.

[`var NSURLErrorCancelledReasonUserForceQuitApplication: Int`](/documentation/Foundation/NSURLErrorCancelledReasonUserForceQuitApplication)

A reason that indicates the system canceled the background task because the user force-quit the application.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)