<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DeclaredAgeRange",
  "identifier" : "/documentation/DeclaredAgeRange/DeclaredAgeRangeAction/callAsFunction(ageGates:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Declared Age Range"
    ],
    "preciseIdentifier" : "s:16DeclaredAgeRange0abC6ActionV14callAsFunction8ageGates__AA0bC7ServiceV8ResponseOSi_SiSgAJtYaKF"
  },
  "title" : "callAsFunction(ageGates:_:_:)"
}
-->

# callAsFunction(ageGates:_:_:)

Returns a response indicating whether the person shared their age range.

```
func callAsFunction(ageGates threshold1: Int, _ threshold2: Int? = nil, _ threshold3: Int? = nil) async throws -> AgeRangeService.Response
```

## Parameters

`threshold1`

The primary age threshold for your app.

`threshold2`

An optional second age threshold that creates an additional age range.

`threshold3`

An optional third age threshold that creates a final age range.

## Return Value

A response indicating whether the person declared their age range. If the person shared their
age range, the system also returns the age range.

## Discussion

Regional requirements may override your age gates based on the person’s location.

Use <doc://com.apple.documentation/documentation/SwiftUI/EnvironmentValues/requestAgeRange> with SwiftUI environment values to request age ranges in response to user interactions:

```swift
struct ContentView: View {
    @Environment(\.requestAgeRange) var requestAgeRange

    var body: some View {
        Button("Check Age Range") {
            Task {
                do {
                    let response = try await requestAgeRange(ageGates: 13, 16, 18)
                    switch response {
                    case let .sharing(ageRange):
                        // Person shared their age range.
                        break
.                    case .declinedSharing:
                        // In regulated regions, the system automatically provides the person's age range — the person can't decline sharing.
                        break
                    }
                } catch {
                    // Handle error.
                }
            }
        }
    }
}
```

> Throws: An error if the request fails.

---

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)