callAsFunction
TypeScriptcallAsFunction(threshold1: number, threshold2?: (number) | null, threshold3?: (number) | null): Promise<AgeRangeService_Response>Swift declarationfunc callAsFunction(ageGates threshold1: Int, _ threshold2: Int? = nil, _ threshold3: Int? = nil) async throws -> AgeRangeService.ResponseReturns a response indicating whether the person shared their age range. 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. } } } } } ``` - 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. - Returns: A response indicating whether the person declared their age range. If the person shared their age range, the system also returns the age range. - Throws: An error if the request fails.