<!--
{
  "availability" : [
    "iOS: 13.0.0 - 27.0.0",
    "iPadOS: 13.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SensorKit",
  "identifier" : "/documentation/SensorKit/SRSensorReader",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "SensorKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SRSensorReader"
  },
  "title" : "SRSensorReader"
}
-->

# SRSensorReader

An object that establishes user authorization and records data for a particular sensor.

```
class SRSensorReader
```

## Overview

To acquire data from a particular sensor using a reader, an app creates an instance of this class using [`init(sensor:)`](/documentation/SensorKit/SRSensorReader/init(sensor:)) and passes in one sensor from the available options in `Sensors`.

A reader is a data stream for a particular sensor that the user must authorize before use. When an app calls [`requestAuthorization(sensors:completion:)`](/documentation/SensorKit/SRSensorReader/requestAuthorization(sensors:completion:)), the OS prompts the user for approval to use the particular sensor and determines the app’s authorization according to the user’s answer. The framework notifies the delegate with the  [`sensorReader(_:didChange:)`](/documentation/SensorKit/SRSensorReaderDelegate/sensorReader(_:didChange:)) callback if the authorization status changes as a result of the [`requestAuthorization(sensors:completion:)`](/documentation/SensorKit/SRSensorReader/requestAuthorization(sensors:completion:)) call. When a reader’s [`authorizationStatus`](/documentation/SensorKit/SRSensorReader/authorizationStatus) is [`SRAuthorizationStatus.authorized`](/documentation/SensorKit/SRAuthorizationStatus/authorized), an app starts collecting sensor data by beginning recording.

When an app calls [`startRecording()`](/documentation/SensorKit/SRSensorReader/startRecording()), the framework starts the reader’s sensor if it isn’t already running because of a request from another app or a system process. An app has access to 7 days of prior recorded data for an active sensor. When an app calls [`stopRecording()`](/documentation/SensorKit/SRSensorReader/stopRecording()), the app relinquishes stakeholdership in the sensor. When a sensor has no app or system stakeholders, the framework deactivates the sensor and, thereby, stops recording data.

To fetch a sensor’s data, pass a request object to the [`fetch(_:)`](/documentation/SensorKit/SRSensorReader/fetch(_:)) function. [`SRFetchRequest`](/documentation/SensorKit/SRFetchRequest) specifies a time range that defines the age of the data, and a device, such as a phone or a watch, from which to collect the data. Use [`fetchDevices()`](/documentation/SensorKit/SRSensorReader/fetchDevices()) to list the available devices, and use the time convenience-functions in Defining the Time Range to specify the time range.

If the fetch query succeeds, the framework notifies the delegate with [`sensorReader(_:didCompleteFetch:)`](/documentation/SensorKit/SRSensorReaderDelegate/sensorReader(_:didCompleteFetch:)). The delegate receives sensor data in the form of *samples* from [`sensorReader(_:fetching:didFetchResult:)`](/documentation/SensorKit/SRSensorReaderDelegate/sensorReader(_:fetching:didFetchResult:)). A fetch result’s [`sample`](/documentation/SensorKit/SRFetchResult/sample) type is different depending on the particular sensor for the reader. For a mapping of sensors to their samples, see [`Sample types`](/documentation/SensorKit/SRFetchResult/sample#Sample-types).

## Topics

### Checking user authorization

[`var authorizationStatus: SRAuthorizationStatus`](/documentation/SensorKit/SRSensorReader/authorizationStatus)

The status of the user’s agreement to let the app access this reader’s sensor.

[`class func requestAuthorization(sensors: Set<SRSensor>, completion: ((any Error)?) -> Void)`](/documentation/SensorKit/SRSensorReader/requestAuthorization(sensors:completion:))

Requests user permission to read one or more sensors.

[`enum SRAuthorizationStatus`](/documentation/SensorKit/SRAuthorizationStatus)

The states that model whether the user approves the app to read a particular sensor.

### Creating a sensor reader

[`init(sensor: SRSensor)`](/documentation/SensorKit/SRSensorReader/init(sensor:))

Initializes a new sensor reader object.

[`struct SRSensor`](/documentation/SensorKit/SRSensor)

The sensors an app can read.

[`var sensor: SRSensor`](/documentation/SensorKit/SRSensorReader/sensor)

The particular sensor that this object reads.

### Recording sensor data

[`func startRecording()`](/documentation/SensorKit/SRSensorReader/startRecording())

Starts recording sensor data.

[`func stopRecording()`](/documentation/SensorKit/SRSensorReader/stopRecording())

Stops recording sensor data.

### Reading recorded data

[`func fetch(SRFetchRequest)`](/documentation/SensorKit/SRSensorReader/fetch(_:))

Fetches the samples that a fetch request specifies.

[`func fetchDevices()`](/documentation/SensorKit/SRSensorReader/fetchDevices())

Acquires device information for all devices that store data for this reader’s sensor.

[`class SRDevice`](/documentation/SensorKit/SRDevice)

A representation of a device that provides sample data.

### Responding to sensor events

[`var delegate: (any SRSensorReaderDelegate)?`](/documentation/SensorKit/SRSensorReader/delegate)

An object that responds to sensor-related events.

[`protocol SRSensorReaderDelegate`](/documentation/SensorKit/SRSensorReaderDelegate)

A set of callbacks the framework invokes to notify the app of sensor-related events.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)