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 ↗Chapters
Code shown on screen · 2 snippets
Request an age range
// Request an age range
import SwiftUI
import DeclaredAgeRange
struct LandmarkDetail: View {
// ...
var photoSharingEnabled = false
(\.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
// 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
Related sessions
-
12 min