AgeSafety

Use iOS and Android age signals to verify user age and supervision status

🚧

Beta API Notice

The underlying platform APIs are currently in beta. During the beta period, Play Age Signals may return API_NOT_AVAILABLE or throw exceptions on some devices. Always handle these cases gracefully and provide conservative fallbacks for age-gated flows.

AgeSafety exposes system-provided age signals and supervision state so you can determine whether a user is a minor, whether their account is supervised (Family Link / Screen Time), and whether parental approval is required for significant app changes or feature enablement.

The plugin intentionally passes through platform signals (it does not collect or send identifiable data itself). Use the plugin to gate UI, require parental confirmation, or disable features for underage users.

👍

Developer Demo

Test your implementation using our developer demo page at https://median.dev/age-safety

Why use AgeSafety?

  • Compliance made simple: Meet platform requirements for age-appropriate content
  • User safety first: Protect minors with proper age verification
  • Parental controls: Respect existing family supervision settings
  • Unified approach: One API works across both Android and iOS platforms

Key terms

The following terms will help you implement AgeSafety:

Age bounds: Platforms return age ranges (like 13–17) rather than exact ages. Both bounds are inclusive, meaning a user with bounds 13–17 could be 13, 17, or anywhere in between.

Strong verification: High-confidence signals from payment verification or government ID checks.

Weak verification: Self-declared ages or other lower-confidence methods.

Supervised account: The user's device or account is under parental supervision (Family Link on Android, Screen Time on iOS).

Supervisor approval required: The platform indicates that significant app changes need parent/guardian approval.

Privacy and security

  • The plugin surfaces system-provided signals only. It does not log or transmit personally-identifying information.
  • Follow platform rules: you may only use information from the Play Age Signals API to provide age-appropriate content and experiences in compliance with laws. You may not use the Play Age Signals API for any other purpose including, but not limited to, advertising, marketing, user profiling, or analytics.

Implementation guide

App Setup

Enable the AgeSafety plugin in your Median dashboard before calling any JavaScript bridge functions. Navigate to your app's plugin settings and toggle AgeSafety on.

JavaScript Bridge guide

Core methods

getAgeSignals

Retrieve age and supervision signals from the platform.

// Using promises
const resp = await median.ageSafety.getAgeSignals({ ageGates: [13, 17, 21] });
console.log('Age signals:', resp);

// Using callback methods
median.ageSafety.getAgeSignals({ ageGates: [13, 17] }, function (resp) {
        console.log('Age signals callback:', resp);
}, function (err) {
        console.error('AgeSafety error (callback)', err);
});

Return value (resolved Promise/success callback) is an AgeSignalsResponse.

requireMinimumAge

A convenience helper that checks whether the user meets a numeric minimum age.

async function checkMinimumAge(requiredAge) {
    // Async/await style
  try {
    const resp = await median.ageSafety.requireMinimumAge(requiredAge);
    if (resp.allowed) {
      // show content
    } else {
      // show age-gated message
    }
  } catch (err) {
    console.error('Age safety check failed', err);
  }
}

checkMinimumAge(13);

// Callback style
median.ageSafety.requireMinimumAge(18, function (resp) {
  console.log('requireMinimumAge', resp.allowed);
}, function (err) {
  console.error(err);
});

AgeRequirementResponse.allowed is computed as ageLowerBound >= requiredAge when age bounds are available. If bounds are missing, allowed may be false, and an app-level conservative policy should apply.


Implementation example - Gate a purchase flow

This example verifies a user's age before allowing a purchase, routes supervised accounts to a parental-approval flow, and falls back conservatively when signals are unavailable.

async function attemptPurchase() {
        try {
                const resp = await median.ageSafety.getAgeSignals({ ageGates: [18] });
                if (resp.ageLowerBound >= 18) {
                        // proceed with purchase
                } else if (resp.supervisorApprovalRequired) {
                        // show parent approval flow
                } else {
                        // block purchase and show message
                }
        } catch (err) {
                // fallback: conservative block or soft-check
                console.error('Age check failed', err);
        }
}

For more on JavaScript Bridge fundamentals used above, see Basic Usage and Using Listeners.

Error handling

Error codeDescriptionCommon causesResolution
NOT_SUPPORTEDDevice or OS does not support age signalsPlay Age Signals entitlement missing or unsupported OSProvide a conservative fallback; do not block the entire flow
API_ERRORUnderlying platform API threw an exceptionSystem-level error during age signal retrievalCatch the error and apply a conservative default
USER_DENIEDUser denied permission or signal is unavailableiOS system prompt declinedDesign your UI to apply a conservative default when verification is not available
UNKNOWNPlatform returned signals, but age bounds could not be determinedAge signal exists but is inconclusiveTreat identically to a missing signal — apply your conservative default

Testing Checklist

Use this checklist to confirm AgeSafety is working correctly in your app:

  • getAgeSignals returns a valid response object on a supported device
  • requireMinimumAge returns allowed: true for users above the threshold
  • requireMinimumAge returns allowed: false for users below the threshold
  • Age signals return correctly on Android devices
  • Age signals return correctly on iOS devices
  • verificationMethod is present on iOS responses
  • Supervised-account detection works correctly on Family Link / Screen Time devices
  • NOT_SUPPORTED is handled gracefully with a conservative fallback
  • API_ERROR is caught and the app applies a conservative default
  • Missing ageLowerBound / ageUpperBound is handled gracefully when signals return UNKNOWN

Troubleshooting

AgeSafety functions are undefined or not working

Ensure the JavaScript Bridge is enabled in Median App Studio and that you're calling the functions after the deviceready event. Also verify that the plugin is enabled in your app configuration.

getAgeSignals always throws an error on some Android devices

During the beta period, Play Age Signals may return API_NOT_AVAILABLE or throw exceptions on some devices. Always wrap calls in a try/catch block and provide a conservative fallback for age-gated flows when signals are unavailable.

requireMinimumAge returns allowed: false even for adult users

If ageLowerBound is missing from the response (signals returned UNKNOWN), allowed will be false. This is expected behavior. Design your UI to apply a conservative default when verification is not available, and provide an alternative flow if needed.