<!--
{
  "availability" : [
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreHID",
  "identifier" : "/documentation/CoreHID/HIDDeviceClient/monitorNotifications(reportIDsToMonitor:elementsToMonitor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core HID"
    ],
    "preciseIdentifier" : "s:7CoreHID15HIDDeviceClientC20monitorNotifications18reportIDsToMonitor08elementsiJ0ScsyAC12NotificationOs5Error_pGSaySNyAA11HIDReportIDVGG_SayAA10HIDElementVGtF"
  },
  "title" : "monitorNotifications(reportIDsToMonitor:elementsToMonitor:)"
}
-->

# monitorNotifications(reportIDsToMonitor:elementsToMonitor:)

Creates an asynchronous that receives notifications about the associated device.

```
func monitorNotifications(reportIDsToMonitor: [ClosedRange<HIDReportID>], elementsToMonitor: [HIDElement]) -> AsyncThrowingStream<HIDDeviceClient.Notification, any Error>
```

## Parameters

`reportIDsToMonitor`

The report IDs that should trigger an [`HIDDeviceClient.Notification.inputReport(id:data:timestamp:)`](/documentation/CoreHID/HIDDeviceClient/Notification/inputReport(id:data:timestamp:)) notification.

`elementsToMonitor`

The elements that should trigger an [`HIDDeviceClient.Notification.elementUpdates(values:)`](/documentation/CoreHID/HIDDeviceClient/Notification/elementUpdates(values:)) notification. Elements of interest can be parsed from [`elements`](/documentation/CoreHID/HIDDeviceClient/elements).

## Return Value

An asynchronous stream that receive notifications.

## Discussion

Notifications come in asynchronously from the device at arbitrary times when relevant events occur.

Example usage:

```swift
for await notification in try await client.monitorNotifications(reportIDsToMonitor: [HIDReportID.allReports], elementsToMonitor: await client.elements) {
switch notification {
case .inputReport(let reportID, let report, let timestamp):
    break
case .elementUpdates(let values):
    break
case .deviceSeized:
    break
case .deviceUnseized:
    break
case .deviceRemoved:
    break
}
```

> Throws: ``doc://com.apple.CoreHID/documentation/CoreHID/HIDDeviceError`` if there is an issue with setup.

---

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)