<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DeviceActivity",
  "identifier" : "/documentation/DeviceActivity/DeviceActivityCenter/startMonitoring(_:during:events:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Device Activity"
    ],
    "preciseIdentifier" : "s:14DeviceActivity0aB6CenterV15startMonitoring_6during6eventsyAA0aB4NameV_AA0aB8ScheduleVSDyAA0aB5EventV0H0VALGtKF"
  },
  "title" : "startMonitoring(_:during:events:)"
}
-->

# startMonitoring(_:during:events:)

Starts monitoring the specified device activity.

```
func startMonitoring(_ activity: DeviceActivityName, during schedule: DeviceActivitySchedule, events: [DeviceActivityEvent.Name : DeviceActivityEvent] = [:]) throws
```

## Parameters

`activity`

The name of the activity.

`schedule`

The schedule on which your app extension’s [`DeviceActivityMonitor`](/documentation/DeviceActivity/DeviceActivityMonitor) receives callbacks.

`events`

An optional mapping of events keyed by their names. If this parameter is empty, the application extension only
receives callbacks for the start and end times of the schedule’s interval. If the device’s time zone changes
in the middle of a schedule’s interval, any ongoing events include device activity that may have accumulated
outside of the new time zone. In other words, the system uses the time zone of the device at `nextInterval.start`
to calculate device activity for the entirety of the interval.

## Discussion

If the app already monitored the activity, this method overwrites the previous schedule and events.
Attempting to monitor too many activities or activities that are too tightly scheduled can cause this method to throw an error.

The system throws an error if the attempt to monitor the device activity failed.
To avoid errors, reduce the number of unique, tightly-scheduled activities. For example, consider
using the `warningTime` property of an activity’s schedule.

> Important: The application extension’s ``doc://com.apple.DeviceActivity/documentation/DeviceActivity/DeviceActivityMonitor`` may begin receiving callbacks as soon as
> the system calls this method if the activity’s scheduled interval is ongoing.

---

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)