---
title: "requestPerObjectReadAuthorization(for:predicate:completion:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkhealthstore/requestperobjectreadauthorization(for:predicate:completion:)"
---

# requestPerObjectReadAuthorization(for:predicate:completion:)

Asynchronously requests permission to read a data type that requires per-object authorization (such as vision prescriptions).

## Declaration

```swift
func requestPerObjectReadAuthorization(for objectType: HKObjectType, predicate: NSPredicate?, completion: @escaping @Sendable (Bool, (any Error)?) -> Void)
```

```swift
func requestPerObjectReadAuthorization(for objectType: HKObjectType, predicate: NSPredicate?) async throws
```

## Parameters

- `objectType`: The data type you want to read.
- `predicate`: A predicate that further restricts the data type.
- `completion`: A completion handler that the system calls after the user responds to the request. The completion handler has the following parameters:

## Discussion

Discussion Some samples require per-object authorization. For these samples, people can select which ones your app can read on a sample-by-sample basis. By default, your app can read any of the per-object authorization samples that it has saved to the HealthKit store; however, you may not always have access to those samples. People can update the authorization status for any of these samples at any time. Your app can begin by querying for any samples that it already has permission to read. // Read the newest prescription from the HealthKit store. let queryDescriptor = HKSampleQueryDescriptor(predicates: [.visionPrescription()],   sortDescriptors: [SortDescriptor(\.startDate, order: .reverse)],   limit: 1)

let prescription: HKVisionPrescription

do { guard let result = try await queryDescriptor.result(for: store).first else { print("*** No prescription found. ***") return }

prescription = result } catch { // Handle the error here. fatalError("*** An error occurred while reading the most recent vision prescriptions: \(error.localizedDescription) ***") } Based on the results, you can then decide whether you need to request authorization for additional samples. Call requestPerObjectReadAuthorization(for:predicate:completion:) to prompt someone to modify the samples your app has access to read. // Request authorization to read vision prescriptions. do { try await store.requestPerObjectReadAuthorization(for: .visionPrescriptionType(),   predicate: nil) } catch HKError.errorUserCanceled { // Handle the user canceling the authorization request. print("*** The user canceled the authorization request. ***") return } catch { // Handle the error here. fatalError("*** An error occurred while requesting permission to read vision prescriptions: \(error.localizedDescription) ***") } important: Using the requestAuthorization(toShare:read:) method to request read access to any data types that require per-object authorization fails with an HKError.Code.errorInvalidArgument error. When your app calls this method, HealthKit displays an authorization sheet that asks for permission to read the samples that match the predicate and object type. The person using your app can then select individual samples to share with your app. The system always asks for permission, regardless of whether they previously granted it.

After the person responds, the system calls the callback handler on an arbitrary background queue.

## See Also

### Accessing HealthKit

- [authorizationStatus(for:)](healthkit/hkhealthstore/authorizationstatus(for:).md)
- [HKAuthorizationStatus](healthkit/hkauthorizationstatus.md)
- [getRequestStatusForAuthorization(toShare:read:completion:)](healthkit/hkhealthstore/getrequeststatusforauthorization(toshare:read:completion:).md)
- [HKAuthorizationRequestStatus](healthkit/hkauthorizationrequeststatus.md)
- [isHealthDataAvailable()](healthkit/hkhealthstore/ishealthdataavailable().md)
- [supportsHealthRecords()](healthkit/hkhealthstore/supportshealthrecords().md)
- [requestAuthorization(toShare:read:completion:)](healthkit/hkhealthstore/requestauthorization(toshare:read:completion:).md)
- [requestAuthorization(toShare:read:)](healthkit/hkhealthstore/requestauthorization(toshare:read:).md)
- [handleAuthorizationForExtension(completion:)](healthkit/hkhealthstore/handleauthorizationforextension(completion:).md)
- [authorizationViewControllerPresenter](healthkit/hkhealthstore/authorizationviewcontrollerpresenter.md)
