BS
BleepingSwift
Published on

> Reading Your App's Age Rating with StoreKit's ageRatingCode

Authors
  • avatar
    Name
    Mick MacCallum
    Twitter
    @0x7fs

Apple expanded their age rating system in 2025 to include more granular options: 4+, 9+, 13+, 16+, and 18+. With new regulations in various regions requiring apps to verify age or obtain parental consent when content ratings change, Apple added a simple StoreKit API to help developers stay compliant.

The AppStore.ageRatingCode property lets you read your app's current age rating directly from StoreKit. This is useful when you need to detect rating changes and potentially request parental consent before continuing.

Reading the Age Rating

The API is refreshingly simple. Import StoreKit and access the static property:

import StoreKit

func checkAgeRating() async {
    let rating = await AppStore.ageRatingCode

    switch rating {
    case .fourPlus:
        print("Suitable for all ages")
    case .ninePlus:
        print("Ages 9 and up")
    case .thirteenPlus:
        print("Ages 13 and up")
    case .sixteenPlus:
        print("Ages 16 and up")
    case .eighteenPlus:
        print("Ages 18 and up")
    @unknown default:
        print("Unknown rating")
    }
}

The property is async because it may need to fetch the current rating from the App Store. The returned AgeRatingCode enum includes all five rating tiers.

Detecting Rating Changes

A more practical use case is detecting when your app's rating changes between sessions. You might store the previous rating and compare:

import StoreKit
import SwiftUI

class AgeRatingMonitor: ObservableObject {
    @Published var currentRating: AppStore.AgeRatingCode?
    @Published var ratingDidChange = false

    private let previousRatingKey = "previousAgeRating"

    func checkForRatingChange() async {
        let rating = await AppStore.ageRatingCode
        currentRating = rating

        let previousRawValue = UserDefaults.standard.integer(forKey: previousRatingKey)

        if previousRawValue != 0 && previousRawValue != rating.rawValue {
            ratingDidChange = true
        }

        UserDefaults.standard.set(rating.rawValue, forKey: previousRatingKey)
    }
}

Responding to Significant Changes

When a rating change requires parental consent in certain jurisdictions, you can use StoreKit's Significant Change API to request approval. This displays a system-provided consent flow:

import StoreKit

func handleRatingChange() async {
    let rating = await AppStore.ageRatingCode

    do {
        // Request parental consent for the rating change
        try await AppStore.requestSignificantChangeConsent()
        print("Consent granted, continue with rated content")
    } catch {
        print("Consent denied or failed: \(error)")
        // Restrict content accordingly
    }
}

The consent request presents a system UI that asks a parent or guardian to approve the new content rating. If consent is denied or the request fails, your app should restrict content to match the previously approved rating.

Practical Integration

Here's how you might integrate age rating checks into your app's launch flow:

import SwiftUI
import StoreKit

@main
struct MyApp: App {
    @StateObject private var ratingMonitor = AgeRatingMonitor()

    var body: some Scene {
        WindowGroup {
            ContentView()
                .environmentObject(ratingMonitor)
                .task {
                    await ratingMonitor.checkForRatingChange()
                }
                .alert("Content Rating Changed", isPresented: $ratingMonitor.ratingDidChange) {
                    Button("Continue") {
                        Task {
                            await handleRatingChange()
                        }
                    }
                    Button("Cancel", role: .cancel) { }
                } message: {
                    Text("This app's content rating has been updated. Parental consent may be required to continue.")
                }
        }
    }

    func handleRatingChange() async {
        do {
            try await AppStore.requestSignificantChangeConsent()
        } catch {
            // Handle denial - perhaps limit features
        }
    }
}

When You Need This

The ageRatingCode API is particularly relevant if your app operates in regions with strict age verification requirements. Apple introduced this alongside the expanded age rating system to help developers comply with laws like Texas SB2420, which requires parental consent for minors accessing certain content.

Even if your app doesn't currently need consent flows, reading the age rating can be useful for analytics or for conditionally showing age-appropriate content variations.

Key Points

The API is only available on iOS 26 and later, so you'll need to check availability if supporting older versions. The property returns the rating as assigned in App Store Connect, which may vary by region based on local content guidelines. If you haven't updated your app's age rating questionnaire by the January 31, 2026 deadline, you may encounter issues submitting updates.

For more details on the expanded rating system and how to update your app's questionnaire, see Apple's age rating documentation.

subscribe.sh

// Stay Updated

Get notified when I publish new tutorials on Swift, SwiftUI, and iOS development. No spam, unsubscribe anytime.

>

By subscribing, you agree to our Privacy Policy.