---
title: "monitorNotifications(reportIDsToMonitor:elementsToMonitor:)"
framework: corehid
role: symbol
role_heading: Instance Method
path: "corehid/hiddeviceclient/monitornotifications(reportidstomonitor:elementstomonitor:)"
---

# monitorNotifications(reportIDsToMonitor:elementsToMonitor:)

Creates an asynchronous that receives notifications about the associated device.

## Declaration

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

## Parameters

- `reportIDsToMonitor`: The report IDs that should trigger an doc://com.apple.CoreHID/documentation/CoreHID/HIDDeviceClient/Notification/inputReport(id:data:timestamp:) notification.
- `elementsToMonitor`: The elements that should trigger an doc://com.apple.CoreHID/documentation/CoreHID/HIDDeviceClient/Notification/elementUpdates(values:) notification. Elements of interest can be parsed from doc://com.apple.CoreHID/documentation/CoreHID/HIDDeviceClient/elements.

## Mentioned in

Communicating with human interface devices

## Return Value

Return Value An asynchronous stream that receive notifications.

## Discussion

Discussion Notifications come in asynchronously from the device at arbitrary times when relevant events occur. Example usage: 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 } note: HIDDeviceError if there is an issue with setup.

## See Also

### Monitor device notifications

- [HIDDeviceClient.Notification](corehid/hiddeviceclient/notification.md)
