<!--
{
  "documentType" : "article",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/xpc-activities",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "XPC activities"
}
-->

# XPC activities

Schedule background activities for the system to execute.

## Topics

### Registration

[`xpc_activity_register`](/documentation/XPC/xpc_activity_register(_:_:_:))

Registers an activity with the system.

[`xpc_activity_unregister`](/documentation/XPC/xpc_activity_unregister(_:))

Unregisters an activity with the specified identifier.

[`XPC_ACTIVITY_CHECK_IN`](/documentation/XPC/XPC_ACTIVITY_CHECK_IN)

A constant to check in with the system for a previously registered activity using the same identifier.

[`xpc_activity_t`](/documentation/XPC/xpc_activity_t)

An XPC activity object.

[`xpc_activity_handler_t`](/documentation/XPC/xpc_activity_handler_t)

A block to call when an XPC activity becomes eligible to run.

### State

[`xpc_activity_get_state`](/documentation/XPC/xpc_activity_get_state(_:))

Returns the current state of an activity.

[`xpc_activity_set_state`](/documentation/XPC/xpc_activity_set_state(_:_:))

Updates the current state of an activity.

[`xpc_activity_should_defer`](/documentation/XPC/xpc_activity_should_defer(_:))

Tests whether to defer an activity.

[xpc_activity_state_t](/documentation/XPC/xpc-activity-state-t-swift-consts)

A type that represents the state of an activity.

[`xpc_activity_state_t`](/documentation/XPC/xpc_activity_state_t)

A type that represents the state of an activity.

[`XPC_ACTIVITY_STATE_CHECK_IN`](/documentation/XPC/XPC_ACTIVITY_STATE_CHECK_IN)

The activity has completed a check-in with the system.

[`XPC_ACTIVITY_STATE_WAIT`](/documentation/XPC/XPC_ACTIVITY_STATE_WAIT)

The activity is waiting for an opportunity to run.

[`XPC_ACTIVITY_STATE_RUN`](/documentation/XPC/XPC_ACTIVITY_STATE_RUN)

The activity is eligible to run according to its criteria.

[`XPC_ACTIVITY_STATE_DEFER`](/documentation/XPC/XPC_ACTIVITY_STATE_DEFER)

The activity needs to wait until it satisfies its criteria again.

[`XPC_ACTIVITY_STATE_CONTINUE`](/documentation/XPC/XPC_ACTIVITY_STATE_CONTINUE)

The activity continues its operation beyond the return of its handler block.

[`XPC_ACTIVITY_STATE_DONE`](/documentation/XPC/XPC_ACTIVITY_STATE_DONE)

The activity is complete.

### Execution criteria

[`xpc_activity_copy_criteria`](/documentation/XPC/xpc_activity_copy_criteria(_:))

Returns an XPC dictionary that describes the execution criteria of an activity.

[`xpc_activity_set_criteria`](/documentation/XPC/xpc_activity_set_criteria(_:_:))

Modifies the execution criteria of an activity.

### Scheduling

[`XPC_ACTIVITY_REPEATING`](/documentation/XPC/XPC_ACTIVITY_REPEATING)

A Boolean property that indicates whether this is a repeating activity.

[`XPC_ACTIVITY_DELAY`](/documentation/XPC/XPC_ACTIVITY_DELAY)

An integer property that indicates the number of seconds to delay before beginning the activity.

[`XPC_ACTIVITY_GRACE_PERIOD`](/documentation/XPC/XPC_ACTIVITY_GRACE_PERIOD)

An integer property that indicates the number of seconds to allow as a grace period before the scheduling of the activity becomes more aggressive.

### Time Intervals

[`XPC_ACTIVITY_INTERVAL`](/documentation/XPC/XPC_ACTIVITY_INTERVAL)

An integer property that indicates the desired time interval of the activity in seconds.

[`XPC_ACTIVITY_INTERVAL_1_MIN`](/documentation/XPC/XPC_ACTIVITY_INTERVAL_1_MIN)

A constant that represents a 1-minute time interval.

[`XPC_ACTIVITY_INTERVAL_5_MIN`](/documentation/XPC/XPC_ACTIVITY_INTERVAL_5_MIN)

A constant that represents a 5-minute time interval.

[`XPC_ACTIVITY_INTERVAL_15_MIN`](/documentation/XPC/XPC_ACTIVITY_INTERVAL_15_MIN)

A constant that represents a 15-minute time interval.

[`XPC_ACTIVITY_INTERVAL_30_MIN`](/documentation/XPC/XPC_ACTIVITY_INTERVAL_30_MIN)

A constant that represents a 30-minute time interval.

[`XPC_ACTIVITY_INTERVAL_1_HOUR`](/documentation/XPC/XPC_ACTIVITY_INTERVAL_1_HOUR)

A constant that represents a 1-hour time interval.

[`XPC_ACTIVITY_INTERVAL_4_HOURS`](/documentation/XPC/XPC_ACTIVITY_INTERVAL_4_HOURS)

A constant that represents a 4-hour time interval.

[`XPC_ACTIVITY_INTERVAL_8_HOURS`](/documentation/XPC/XPC_ACTIVITY_INTERVAL_8_HOURS)

A constant that represents an 8-hour time interval.

[`XPC_ACTIVITY_INTERVAL_1_DAY`](/documentation/XPC/XPC_ACTIVITY_INTERVAL_1_DAY)

A constant that represents a one-day time interval.

[`XPC_ACTIVITY_INTERVAL_7_DAYS`](/documentation/XPC/XPC_ACTIVITY_INTERVAL_7_DAYS)

A constant that represents a seven-day time interval.

### Priority

[`XPC_ACTIVITY_PRIORITY`](/documentation/XPC/XPC_ACTIVITY_PRIORITY)

A string property that indicates the priority of the activity.

[`XPC_ACTIVITY_PRIORITY_MAINTENANCE`](/documentation/XPC/XPC_ACTIVITY_PRIORITY_MAINTENANCE)

A string that indicates an activity is maintenance priority.

[`XPC_ACTIVITY_PRIORITY_UTILITY`](/documentation/XPC/XPC_ACTIVITY_PRIORITY_UTILITY)

A string that indicates an activity is utility priority.

### Power consumption

[`XPC_ACTIVITY_ALLOW_BATTERY`](/documentation/XPC/XPC_ACTIVITY_ALLOW_BATTERY)

A Boolean value that indicates whether to allow the activity to run while the computer is on battery power.

[`XPC_ACTIVITY_REQUIRE_SCREEN_SLEEP`](/documentation/XPC/XPC_ACTIVITY_REQUIRE_SCREEN_SLEEP)

A Boolean value that indicates whether the activity performs only while the primary screen is in sleep mode.

[`XPC_ACTIVITY_PREVENT_DEVICE_SLEEP`](/documentation/XPC/XPC_ACTIVITY_PREVENT_DEVICE_SLEEP)

A Boolean that indicates whether the activity prevents the system from sleeping while on battery power.

### Deprecated

[`XPC_ACTIVITY_REQUIRE_BATTERY_LEVEL`](/documentation/XPC/XPC_ACTIVITY_REQUIRE_BATTERY_LEVEL)

An integer percentage of minimum battery charge required to allow the activity to run.

[`XPC_ACTIVITY_REQUIRE_HDD_SPINNING`](/documentation/XPC/XPC_ACTIVITY_REQUIRE_HDD_SPINNING)

A Boolean value indicating whether the activity should only be performed while the hard disk drive (HDD) is spinning.



---

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)