requestAgeRange(ageGates:_:_:in:)
Requests an age range for the person signed in to iCloud on the device.
Declaration
func requestAgeRange(ageGates threshold1: Int, _ threshold2: Int? = nil, _ threshold3: Int? = nil, in viewController: UIViewController) async throws -> AgeRangeService.ResponseParameters
- 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.
- viewController:
The view controller that anchors the system UI presentation. The system UI appears modally over this view controller.
Return Value
An AgeRangeService.Response value containing either the person’s age range or an indication that the person declined to share their age range.
Discussion
Use requestAgeRange(ageGates:_:_:in:) to implement age-appropriate experiences in your app. People who meet the minimum age requirements that you specify can access age-appropriate features and content.
This method presents a system-provided interface that explains what information a person shares with your app and allows people to make an informed decision about providing their age range information to your app.
The system may return age ranges that override the age gates you specify based on the person’s location and applicable regulations. When local regulations require specific age gates, the returned age range reflects regulatory requirements rather than the bounds of your age gates.