Getting Started
-
Install the package
Terminal window npm i @capgo/capacitor-age-rangeTerminal window pnpm add @capgo/capacitor-age-rangeTerminal window yarn add @capgo/capacitor-age-rangeTerminal window bun add @capgo/capacitor-age-range -
Sync with native projects
Terminal window npx cap syncTerminal window pnpm cap syncTerminal window yarn cap syncTerminal window bunx cap sync
iOS Setup
Section titled âiOS SetupâRequirements
Section titled âRequirementsâ- iOS 15+ (plugin compiles and runs, returns
NOT_AVAILABLEon older versions) - iOS 26+ for actual age range functionality (DeclaredAgeRange framework)
- Xcode 26+
Entitlement
Section titled âEntitlementâAdd the com.apple.developer.declared-age-range entitlement to your app:
- In Xcode, select your target â Signing & Capabilities
- Click + Capability â search for Declared Age Range
- Enable it
Or add manually to your *.entitlements file:
<key>com.apple.developer.declared-age-range</key><true/>How it works on iOS
Section titled âHow it works on iOSârequestAgeRange() presents a system dialog where the user (or their guardian via Family Sharing) declares their age range. The ageGates option controls the age boundaries shown (default: [13, 16, 18]).
Android Setup
Section titled âAndroid SetupâRequirements
Section titled âRequirementsâ- Android API 24+ (minSdk)
- Google Play Store installed and up to date
How it works on Android
Section titled âHow it works on AndroidâThe plugin queries Google Play Age Signals API in the background â no user prompt is shown. The Play Store determines the userâs age verification status from their Google account.
No additional permissions or manifest changes are needed.
Import the plugin and request the userâs age range:
import { AgeRange } from '@capgo/capacitor-age-range';
const result = await AgeRange.requestAgeRange();
switch (result.status) { case 'SHARING': console.log('Age range:', result.ageLower, '-', result.ageUpper); console.log('Source:', result.declarationSource); break; case 'DECLINED_SHARING': console.log('User declined to share age'); break; case 'NOT_AVAILABLE': console.log('Age range API not available on this device'); break; case 'ERROR': console.log('Error requesting age range'); break;}API Reference
Section titled âAPI ReferenceârequestAgeRange(options?)
Section titled ârequestAgeRange(options?)âRequests the userâs age range from the platform.
const result = await AgeRange.requestAgeRange({ ageGates: [13, 16, 18] // iOS only, ignored on Android});Options
Section titled âOptionsâ| Option | Type | Default | Description |
|---|---|---|---|
ageGates | number[] | [13, 16, 18] | Age thresholds for the iOS system dialog. Ignored on Android. |
| Property | Type | Description |
|---|---|---|
status | string | SHARING, DECLINED_SHARING, NOT_AVAILABLE, or ERROR |
ageLower | number? | Lower bound of the age range |
ageUpper | number? | Upper bound (absent for highest bracket, e.g. 18+) |
declarationSource | string? | SELF_DECLARED, GUARDIAN_DECLARED, VERIFIED, or UNKNOWN |
androidUserStatus | string? | Android-only. Google Play user status |
mostRecentApprovalDate | string? | Android-only. Date of most recent guardian approval |
installId | string? | Android-only. Supervised install identifier |
getPluginVersion()
Section titled âgetPluginVersion()âReturns the native plugin version.
const { version } = await AgeRange.getPluginVersion();console.log('Plugin version:', version);Complete Example
Section titled âComplete Exampleâimport { AgeRange } from '@capgo/capacitor-age-range';
export class AgeVerificationService { async checkAgeRange(): Promise<{ isAdult: boolean; ageRange?: string }> { const result = await AgeRange.requestAgeRange({ ageGates: [13, 16, 18] });
if (result.status === 'SHARING') { const isAdult = (result.ageLower ?? 0) >= 18; const upper = result.ageUpper ? `-${result.ageUpper}` : '+'; const ageRange = `${result.ageLower}${upper}`;
return { isAdult, ageRange }; }
// User declined or API not available return { isAdult: false }; }
async isAgeRangeAvailable(): Promise<boolean> { const result = await AgeRange.requestAgeRange(); return result.status !== 'NOT_AVAILABLE'; }}Platform Response Mapping
Section titled âPlatform Response MappingâAndroid (Google Play Age Signals)
Section titled âAndroid (Google Play Age Signals)â| Android UserStatus | â status | â declarationSource |
|---|---|---|
| VERIFIED | SHARING | VERIFIED |
| SUPERVISED | SHARING | GUARDIAN_DECLARED |
| SUPERVISED_APPROVAL_PENDING | SHARING | GUARDIAN_DECLARED |
| SUPERVISED_APPROVAL_DENIED | SHARING | GUARDIAN_DECLARED |
| UNKNOWN / EMPTY | DECLINED_SHARING | â |
iOS (DeclaredAgeRange)
Section titled âiOS (DeclaredAgeRange)â| iOS Response | â status | â declarationSource |
|---|---|---|
| .sharing (selfDeclared) | SHARING | SELF_DECLARED |
| .sharing (guardianDeclared) | SHARING | GUARDIAN_DECLARED |
| .declinedSharing | DECLINED_SHARING | â |
Platform Notes
Section titled âPlatform Notesâ- Requires iOS 26+ for the DeclaredAgeRange framework
- On older iOS versions, returns
NOT_AVAILABLE - Requires
com.apple.developer.declared-age-rangeentitlement - Shows a system dialog to the user
Android
Section titled âAndroidâ- Uses Google Play Age Signals API (background check, no dialog)
- Requires Google Play Store to be installed and up to date
- Returns detailed error codes if Play Store is unavailable
- Not supported. Throws
'AgeRange does not have web implementation'
Best Practices
Section titled âBest Practicesâ-
Handle all statuses Always check the
statusfield before reading age data. TheageLowerandageUpperfields are only present whenstatusisSHARING. -
Provide fallbacks When the API returns
NOT_AVAILABLEorERROR, implement a fallback (e.g., self-declaration form or feature gating). -
Use appropriate age gates Choose age gates that match your appâs requirements. Common values:
[13]for COPPA,[13, 18]for adult content,[13, 16, 18]for EU Digital Services Act.