|
| 1 | +# ageRange.requestAgeRange() |
| 2 | + |
| 3 | +> --------------------- ------------------------------------------------------------------------------------------ |
| 4 | +> __Type__ [Function][api.type.Function] |
| 5 | +> __Library__ [plugin.ageRange.*][plugin.ageRange] |
| 6 | +> __Return value__ none |
| 7 | +> __Revision__ [REVISION_LABEL](REVISION_URL) |
| 8 | +> __Keywords__ age range, age verification, parental controls, Screen Time, iOS 18 |
| 9 | +> __See also__ [plugin.ageRange.init()][plugin.ageRange.init] |
| 10 | +> |
| 11 | +> [ageRange][plugin.ageRange.event.ageRange] |
| 12 | +> --------------------- ------------------------------------------------------------------------------------------ |
| 13 | +
|
| 14 | + |
| 15 | +## Overview |
| 16 | + |
| 17 | +Requests the user's age range with custom age gates. The user will be prompted to share their age range through the iOS Screen Time system. Results are returned through the listener function set in [plugin.ageRange.init()][plugin.ageRange.init]. |
| 18 | + |
| 19 | +This feature requires iOS 26.0 or later. |
| 20 | + |
| 21 | + |
| 22 | +## Syntax |
| 23 | + |
| 24 | + plugin.ageRange.requestAgeRange( ) |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +## Example |
| 29 | + |
| 30 | +``````lua |
| 31 | +local ageRange = require( "plugin.ageRange" ) |
| 32 | + |
| 33 | +local function ageRangeListener( event ) |
| 34 | + if event.isError then |
| 35 | + print( "Error:", event.errorMessage ) |
| 36 | + elseif not event.isAvailable then |
| 37 | + print( "Age range not available" ) |
| 38 | + elseif event.declined then |
| 39 | + print( "User declined to share age range" ) |
| 40 | + else |
| 41 | + print( "Lower bound:", event.lowerBound ) |
| 42 | + print( "Upper bound:", event.upperBound ) |
| 43 | + print( "User status:", event.userStatus ) |
| 44 | + |
| 45 | + -- Check user status |
| 46 | + if event.userStatus == "verified" then |
| 47 | + print( "User is a verified adult (18+)" ) |
| 48 | + elseif event.userStatus == "supervised" then |
| 49 | + print( "User has parental controls active" ) |
| 50 | + end |
| 51 | + end |
| 52 | +end |
| 53 | + |
| 54 | +-- Initialize the plugin |
| 55 | +ageRange.init( ageRangeListener ) |
| 56 | + |
| 57 | +-- Request age range with custom gates |
| 58 | +ageRange.requestAgeRange( ) |
| 59 | +`````` |
0 commit comments