I was going through the iOS 27 changes one evening when I noticed three new errors on the age range API: declinedOnboarding, invalidAccount, and network. The names are easy enough to read. What bothered me was that my own code had not decided, even in a single line, what to do when any of them showed up.
It turned out someone had just filed this exact problem as Expo issue #53549 on November 16. expo-age-range does not give the three iOS 27 cases their own error codes, so JavaScript cannot tell them apart. The issue was closed almost as soon as it was opened, and when I read the source on main on November 17, the three cases were still not mapped.
The first thing I want to say is that you don't have to wait for those codes. If you decide where each kind of error should go, the current version is already enough to ship something that holds up in review.
What reaches JavaScript today
Reading the iOS side of expo-age-range (AgeRangeModule.swift and AgeRangeExceptions.swift), here is what requestAgeRangeAsync can hand you. One more detail worth keeping in mind: on iOS earlier than 26, no prompt is shown at all, and the call resolves with lowerBound: 18, the same as an adult.
| What you get | code | Meaning |
|---|---|---|
| User declined to share | ERR_AGE_RANGE_USER_DECLINED | The person chose not to share on the system prompt |
| Service not available | ERR_AGE_RANGE_NOT_AVAILABLE | For example, not signed in to iCloud on the device or simulator |
| Invalid request | ERR_AGE_RANGE_INVALID_REQUEST | For example, age gates less than 2 years apart |
| Three new iOS 27 cases | none | Onboarding not finished, ineligible account, network failure |
| No view controller / unknown response | none | No screen to present on, or a response shape the module doesn't know |
The issue author splits the new cases into two meanings. network is temporary, so try again a little later. declinedOnboarding and invalidAccount mean no age signal is available for that account, so they belong on the same path as ERR_AGE_RANGE_NOT_AVAILABLE. I agree with that reading.
I started matching message strings, then stopped
If there's no code, match on the message — that was the line I started writing, checking whether message contained "network". But that text is just the Swift error turned into a string. Expo doesn't promise it, and nothing guarantees it stays the same across OS versions or device languages.
So I flipped the approach. Route the codes you know by name, and send everything without a code to "wait once and retry, then continue without a signal." Of the three new cases, only network can be rescued by a retry; for the other two, a retry just returns the same answer, so one extra attempt costs very little.
Sort what you can name; let what you can't name fall toward not blocking the person. That was the line I cared about most here.
A first version that routes each error
This function turns the result into one of four outcomes: proceed, retry after a wait, no age signal, or fix your code. In an app built with Rork (Expo), you can drop it next to the screen that triggers the age check.
import { requestAgeRangeAsync } from 'expo-age-range';
type AgeGateResult =
| { kind: 'ok'; lowerBound: number | null; upperBound: number | null }
| { kind: 'declined' } // the person chose not to share
| { kind: 'noSignal' } // no age signal for this account or service state
| { kind: 'bug'; code: string }; // malformed request; the developer fixes it
const NO_SIGNAL_CODES = new Set(['ERR_AGE_RANGE_NOT_AVAILABLE']);
function codeOf(e: unknown): string | null {
// Native errors may carry a code, but the three iOS 27 cases do not
const c = (e as { code?: unknown } | null)?.code;
return typeof c === 'string' && c.startsWith('ERR_AGE_RANGE_') ? c : null;
}
const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));
export async function checkAgeRange(threshold: number): Promise<AgeGateResult> {
for (let attempt = 0; attempt < 2; attempt++) {
try {
const res = await requestAgeRangeAsync({ threshold1: threshold });
return { kind: 'ok', lowerBound: res.lowerBound, upperBound: res.upperBound };
} catch (e) {
const code = codeOf(e);
if (code === 'ERR_AGE_RANGE_USER_DECLINED') return { kind: 'declined' };
if (code === 'ERR_AGE_RANGE_INVALID_REQUEST') return { kind: 'bug', code };
if (code && NO_SIGNAL_CODES.has(code)) return { kind: 'noSignal' };
// Uncoded errors land here (iOS 27 network / declinedOnboarding / invalidAccount, and others)
if (attempt === 0) {
await wait(3000); // a network failure often clears after a few seconds
continue;
}
return { kind: 'noSignal' };
}
}
return { kind: 'noSignal' };
}Three notes on why it's written this way:
- It never reads
message. When Expo eventually adds codes for the three cases, you add them toNO_SIGNAL_CODESor narrow the retry by name, and nothing else changes. - One retry, a 3-second wait. Age checks tend to appear right after launch or just before a purchase, and looping makes someone stare at a spinner.
bugis not a path for users. It's a sign that your age gates need fixing, so send it to logs or a notification only you see during development.
One line of copy per destination
Once the destinations exist, the wording stops being hard. These are the three I put in my draft:
- Retrying (before the second attempt fails): "Checking your age is taking a moment. You can try again."
- No age signal: "We couldn't confirm your age, so we'll start with some features limited. You can check again any time in Settings."
- Declined to share: no blame; continue the same way as no signal, and don't keep re-showing the prompt
What you limit when there's no signal depends on your app and on what the regions you ship to require. As an indie developer, I chose to guarantee first that the app can start in a limited state, and to work out the exact limits afterward. An app that freezes in front of a person hurts far more, both in review and in ratings.
How store age ratings themselves are decided connects to what I wrote in A share button alone is not a social media capability.
When you ask Rork, give it the destinations first
If you ask Rork's chat to add the age check, writing the destinations up front keeps the generated code from drifting. Here is the skeleton of the request I drafted:
Call the age check (requestAgeRangeAsync from expo-age-range) from a "Check my age" item in Settings.
Split the result four ways.
1. Success: save lowerBound and go to the normal screen
2. ERR_AGE_RANGE_USER_DECLINED: continue in limited mode; don't re-show the prompt automatically
3. ERR_AGE_RANGE_INVALID_REQUEST: don't show anything to the user; console.warn only
4. Anything else (including errors with no code): wait 3 seconds, retry once, then continue in limited mode
Do not branch on the error.message string.That last line is insurance against the generated code taking the same "match the text" road I almost took myself. Saying what not to branch on, at request time, has been the cheapest way I know to avoid rework.
Two things to check on your machine before review
- Call it on a simulator that is not signed in to iCloud. You should get
ERR_AGE_RANGE_NOT_AVAILABLE, and the app should move to the no-signal copy and limited mode. - Set the age gates one year apart on purpose (for example,
threshold1: 16, threshold2: 17). ConfirmERR_AGE_RANGE_INVALID_REQUESTstays out of the user's view and only shows up in your logs.
To be honest about the limits: I haven't reproduced the three new iOS 27 cases on a real device yet. The issue author says the same thing — their fix is based on Apple's documentation, not on observed errors. That's exactly why it helps to route uncoded errors toward not blocking anyone.
For the full set of steps before you publish, see What you have to do on Apple's side before publishing a Rork app. If review does push back, What to do when a Rork app is rejected on the App Store is a good place to start.
If you do one thing today, open the catch around your age check and look for any line that reads message. If you find one, you're already halfway done.