Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2025 System ServicesPrivacy & Security

WWDC25 · 14 min · System Services / Privacy & Security

Deliver age-appropriate experiences in your app

Learn how to deliver age-appropriate experiences in your app with the new Declared Age Range API. We’ll cover how parents can allow their child to share an age range with an app to ensure a safe experience in a privacy-preserving way. We’ll also explore how this framework can help you tailor your app’s content and features based on a user’s age, and show you how to implement age gates, understand caching, and respect user privacy while creating safer and more engaging experiences.

Watch at developer.apple.com ↗

Transcript all transcripts

Chapters

  • 0:00 — Introduction
  • 0:34 — Helping protect kids online
  • 2:25 — Declared Age Range
framework
  • 7:00 — Requesting an age range
  • 12:22 — More ways to keep kids safe

Code shown on screen · 2 snippets

Request an age range swift · at 8:03 ↗
// Request an age range

import SwiftUI
import DeclaredAgeRange

struct LandmarkDetail: View {
    // ...
    @State var photoSharingEnabled = false
    @Environment(\.requestAgeRange) var requestAgeRange
    
    var body: some View {
        ScrollView {
            // ...
            Button("Share Photos") {}
                .disabled(!photoSharingEnabled)
        }
        .task {
            await requestAgeRangeHelper()
        }
    }

    func requestAgeRangeHelper() async {
        do {
            // TODO: Check user region
            let ageRangeResponse = try await requestAgeRange(ageGates: 16)
            switch ageRangeResponse {
            case let .sharing(range):
                 // Age range shared
                if let lowerBound = range.lowerBound, lowerBound >= 16 {
                    photoSharingEnabled = true
                }
                // guardianDeclared, selfDeclared
                print(range.ageRangeDeclaration)
            case .declinedSharing:
                // Declined to share
                print("Declined to share")
            }
        } catch AgeRangeService.Error.invalidRequest {
            print("Handle invalid request error")
        } catch AgeRangeService.Error.notAvailable {
            print("Handle not available error")
        } catch {
            print("Unhandled error: \(error)")
        }
    }
}
Communication Limits swift · at 11:49 ↗
// Request an age range

func requestAgeRangeHelper() async {
    do {
        // TODO: Check user region
        let ageRangeResponse = try await requestAgeRange(ageGates: 16)
        switch ageRangeResponse {
        case let .sharing(range):
            if range.activeParentalControls.contains(.communicationLimits) {
                print("Communication Limits enabled")
            }
            // ...
        case .declinedSharing:
            // Declined to share
            print("Declined to share")
        }
    } catch {
        // ...
    }
}

Resources