A unified API for implementing age-appropriate experiences across iOS and Android platforms. This library provides easy access to platform-specific age verification and parental control APIs.
π Complete Documentation Index | π Quick Reference | π API Docs | π― Implementation Guide
- β Android Play Age Signals - Access Google Play's Age Range Declaration API
- β iOS Declared Age Range - Access iOS 18+ Declared Age Range API
- π Type-safe - Full TypeScript support with comprehensive type definitions
- β‘ Promise-based - Modern async/await API
- π― Cross-platform - Unified API for both iOS and Android
- π± React Native - Built on React Native's Turbo Module architecture
npm install react-native-store-age-declarationor with yarn:
yarn add react-native-store-age-declarationThe library automatically includes the Google Play Age Signals dependency. No additional setup required.
Minimum Requirements:
- minSdkVersion: 21
- compileSdkVersion: 33+
The library automatically includes iOS Declared Age Range support. No additional setup required.
Minimum Requirements:
- iOS 18.0+ (for Declared Age Range API)
- Xcode 16+
Note: The iOS Declared Age Range API is available starting with iOS 18. On older iOS versions, the method will return an error indicating the version requirement.
Retrieves the age range declaration status from Google Play Age Signals API. This method checks the user's age status as determined by Google Play's parental controls and family settings.
Platform: Android only
Returns: Promise<PlayAgeRangeStatusResult>
interface PlayAgeRangeStatusResult {
installId: string | null; // Unique identifier for this app installation
userStatus: string | null; // Age status: 'UNDER_AGE', 'OVER_AGE', or 'UNKNOWN'
error: string | null; // Error message if the operation failed
}| Status | Description |
|---|---|
UNDER_AGE |
User is below the age threshold set by the app |
OVER_AGE |
User is at or above the age threshold |
UNKNOWN |
Age information is not available or could not be determined |
import { getAndroidPlayAgeRangeStatus } from 'react-native-store-age-declaration';
async function checkUserAge() {
const result = await getAndroidPlayAgeRangeStatus();
if (result.error) {
console.error('Error:', result.error);
return;
}
console.log('Install ID:', result.installId);
console.log('User Status:', result.userStatus);
}import React, { useState, useEffect } from 'react';
import { View, Text, ActivityIndicator } from 'react-native';
import { getAndroidPlayAgeRangeStatus } from 'react-native-store-age-declaration';
function AgeGateComponent() {
const [loading, setLoading] = useState(true);
const [isAgeAppropriate, setIsAgeAppropriate] = useState(false);
useEffect(() => {
checkAge();
}, []);
async function checkAge() {
try {
const result = await getAndroidPlayAgeRangeStatus();
if (!result.error && result.userStatus === 'OVER_AGE') {
setIsAgeAppropriate(true);
}
} catch (error) {
console.error('Age check failed:', error);
} finally {
setLoading(false);
}
}
if (loading) {
return <ActivityIndicator />;
}
return (
<View>
{isAgeAppropriate ? (
<Text>Welcome! You can access all features.</Text>
) : (
<Text>Some features are restricted based on age.</Text>
)}
</View>
);
}import { getAndroidPlayAgeRangeStatus } from 'react-native-store-age-declaration';
async function shouldShowMatureContent(): Promise<boolean> {
const result = await getAndroidPlayAgeRangeStatus();
// Show mature content only if user is confirmed over age
return result.userStatus === 'OVER_AGE';
}
// Usage in your app
async function loadContent() {
const canShowMature = await shouldShowMatureContent();
if (canShowMature) {
// Load all content
loadAllGames();
} else {
// Load age-appropriate content only
loadKidFriendlyGames();
}
}Requests age range declaration from iOS Declared Age Range API. This method prompts the user to share their age range information using iOS 18+'s system dialog.
Platform: iOS 18+ only
Parameters:
firstThresholdAge(number): First age threshold (e.g., 13)secondThresholdAge(number): Second age threshold (e.g., 17)thirdThresholdAge(number): Third age threshold (e.g., 21)
Returns: Promise<DeclaredAgeRangeResult>
interface DeclaredAgeRangeResult {
status: string | null; // 'sharing', 'declined', or specific age range
parentControls: string | null; // Parental control status
lowerBound: number | null; // Lower bound of age range
upperBound: number | null; // Upper bound of age range
}| Status | Description |
|---|---|
sharing |
User agreed to share age information |
declined |
User declined to share age information |
import { requestIOSDeclaredAgeRange } from 'react-native-store-age-declaration';
async function checkIOSAge() {
try {
// Request age with thresholds: 13, 17, 21
const result = await requestIOSDeclaredAgeRange(13, 17, 21);
if (result.status === 'sharing') {
console.log('Age range:', result.lowerBound, '-', result.upperBound);
console.log('Parental controls:', result.parentControls);
// Check if user is over 17
if (result.lowerBound && result.lowerBound >= 17) {
showAllContent();
} else {
showAgeAppropriateContent();
}
} else if (result.status === 'declined') {
console.log('User declined to share age');
showDefaultContent();
}
} catch (error) {
console.error('Error:', error);
}
}import { Platform } from 'react-native';
import {
getAndroidPlayAgeRangeStatus,
requestIOSDeclaredAgeRange,
} from 'react-native-store-age-declaration';
async function checkAge() {
if (Platform.OS === 'android') {
const result = await getAndroidPlayAgeRangeStatus();
return result.userStatus === 'OVER_AGE';
} else if (Platform.OS === 'ios') {
const result = await requestIOSDeclaredAgeRange(13, 17, 21);
return result.status === 'sharing' &&
result.lowerBound !== null &&
result.lowerBound >= 18;
}
return false;
}The library provides detailed error messages to help you debug issues:
const result = await getAndroidPlayAgeRangeStatus();
if (result.error) {
if (result.error.includes('AGE_SIGNALS_INIT_ERROR')) {
// Google Play Services might not be available
console.log('Age signals service unavailable');
} else {
// Other errors
console.log('Error:', result.error);
}
}| Error | Possible Cause | Solution |
|---|---|---|
AGE_SIGNALS_INIT_ERROR |
Google Play Services unavailable | Check if device has Google Play Services |
| Network errors | No internet connection | Retry when connection is restored |
UNKNOWN status |
User hasn't set up Family Link | Use default age-neutral content |
| Error | Possible Cause | Solution |
|---|---|---|
IOS_VERSION_ERROR |
iOS version below 18.0 | Check iOS version before calling |
NO_VIEW_CONTROLLER |
Unable to present UI | Ensure app is in foreground |
| User declined | User chose not to share | Use default age-appropriate content |
Always handle cases where age information is unavailable:
const result = await getAndroidPlayAgeRangeStatus();
if (result.error || result.userStatus === 'UNKNOWN') {
// Default to safe, age-appropriate content
showSafeContent();
} else if (result.userStatus === 'OVER_AGE') {
showAllContent();
} else {
showKidsContent();
}Age status rarely changes during an app session. Cache the result:
let cachedAgeStatus: PlayAgeRangeStatusResult | null = null;
async function getAgeStatus() {
if (!cachedAgeStatus) {
cachedAgeStatus = await getAndroidPlayAgeRangeStatus();
}
return cachedAgeStatus;
}Use platform checks to call the appropriate API:
import { Platform } from 'react-native';
import {
getAndroidPlayAgeRangeStatus,
requestIOSDeclaredAgeRange,
} from 'react-native-store-age-declaration';
async function checkAgeStatus() {
if (Platform.OS === 'android') {
const result = await getAndroidPlayAgeRangeStatus();
return result.userStatus === 'OVER_AGE';
} else if (Platform.OS === 'ios') {
const result = await requestIOSDeclaredAgeRange(13, 17, 21);
return result.status === 'sharing' && result.lowerBound >= 18;
}
return false;
}- Only use age signals for age-appropriate content filtering
- Don't use
installIdfor tracking purposes without user consent - Follow COPPA, GDPR, and other privacy regulations
- Provide clear privacy disclosures in your app
Google Play Age Signals helps developers provide age-appropriate experiences by accessing age information from:
- Family Link accounts - Parental controls set up by parents
- Play Store age declarations - User-provided age information
- Account settings - Google account age data
The API respects user privacy and only provides:
- Whether the user is above/below your app's age threshold
- A unique installation ID (not linked to personal information)
Possible causes:
- User doesn't have Family Link set up
- User hasn't declared age in Play Store
- Device doesn't have Google Play Services
- App not installed from Google Play Store
Solution: Implement fallback logic for UNKNOWN status
Cause: Google Play Services unavailable or outdated
Solution:
// Check if device supports age signals
const result = await getAndroidPlayAgeRangeStatus();
if (result.error?.includes('INIT_ERROR')) {
// Fall back to manual age verification
showManualAgeGate();
}- React Native >= 0.71
- Android API Level >= 21 (Android 5.0)
- Google Play Services installed on device
- App distributed through Google Play Store (for full functionality)
- React Native >= 0.71
- iOS 18.0+ (for Declared Age Range API)
- Xcode 16+
This library is written in TypeScript and includes complete type definitions. All types are exported for your convenience:
import type {
PlayAgeRangeStatusResult,
DeclaredAgeRangeResult,
} from 'react-native-store-age-declaration';- π API Reference - Complete API documentation with detailed method descriptions and type definitions
- π Implementation Guide - Step-by-step guide with real-world examples and best practices
- π Code Examples - Working example app demonstrating library usage
- Google Play Age Signals Documentation
- Apple Declared Age Range Documentation
- COPPA Compliance Guide
- React Native Documentation
We welcome contributions! Please see:
- π Report a Bug
- π¬ Ask a Question
- π§ Contact: Create an issue
MIT
Made with create-react-native-library