|
| 1 | +# event.ageRange |
| 2 | + |
| 3 | +> --------------------- ------------------------------------------------------------------------------------------ |
| 4 | +> __Type__ [Event][api.type.Event] |
| 5 | +> __Revision__ [REVISION_LABEL](__REVISION_URL__) |
| 6 | +> __Keywords__ age range, age verification, parental controls, ageRangeEvent |
| 7 | +> __See also__ [plugin.ageRange.requestAgeRange()][plugin.ageRange.requestAgeRange] |
| 8 | +> [plugin.ageRange.*][plugin.ageRange] |
| 9 | +> --------------------- ------------------------------------------------------------------------------------------ |
| 10 | +
|
| 11 | +## Overview |
| 12 | + |
| 13 | +Age range event dispatched in response to [plugin.ageRange.requestAgeRange()][plugin.ageRange.requestAgeRange]. |
| 14 | + |
| 15 | +## Properties |
| 16 | + |
| 17 | +#### [event.name][plugin.ageRange.event.ageRange.name] |
| 18 | +#### [event.isError][plugin.ageRange.event.ageRange.isError] |
| 19 | +#### [event.isAvailable][plugin.ageRange.event.ageRange.isAvailable] |
| 20 | +#### [event.declined][plugin.ageRange.event.ageRange.declined] |
| 21 | +#### [event.lowerBound][plugin.ageRange.event.ageRange.lowerBound] |
| 22 | +#### [event.upperBound][plugin.ageRange.event.ageRange.upperBound] |
| 23 | +#### [event.userStatus][plugin.ageRange.event.ageRange.userStatus] |
| 24 | +#### [event.hasParentalControls][plugin.ageRange.event.ageRange.hasParentalControls] |
| 25 | +#### [event.errorMessage][plugin.ageRange.event.ageRange.errorMessage] |
| 26 | +#### [event.errorCode][plugin.ageRange.event.ageRange.errorCode] |
| 27 | +#### [event.installId][plugin.ageRange.event.ageRange.installId] |
| 28 | +#### [event.mostRecentApprovalDate][plugin.ageRange.event.ageRange.mostRecentApprovalDate] |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Property Details |
| 33 | + |
| 34 | +### event.name |
| 35 | + |
| 36 | +_[String][api.type.String]._ The string `"ageRangeEvent"`. |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +### event.isError |
| 41 | + |
| 42 | +_[Boolean][api.type.Boolean]._ `true` if an error occurred, `false` otherwise. |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +### event.isAvailable |
| 47 | + |
| 48 | +_[Boolean][api.type.Boolean]._ `true` if age range service is available on this device, `false` otherwise. |
| 49 | + |
| 50 | +**Platform Notes:** |
| 51 | +- **iOS:** Available on iOS 26.0+ devices |
| 52 | +- **Android:** Available if Google Play Services is installed and up-to-date |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +### event.declined |
| 57 | + |
| 58 | +_[Boolean][api.type.Boolean]._ `true` if user declined to share age range, `false` otherwise. |
| 59 | + |
| 60 | +**iOS Only:** User explicitly chose not to share their age range through the system dialog. |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +### event.lowerBound |
| 65 | + |
| 66 | +_[Number][api.type.Number]._ Minimum age in the user's age range. May be `nil`. |
| 67 | + |
| 68 | +**Examples:** |
| 69 | +- `13` - User is at least 13 years old |
| 70 | +- `18` - User is at least 18 years old (verified adult) |
| 71 | +- `nil` - No age range provided or user is under minimum age gate |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +### event.upperBound |
| 76 | + |
| 77 | +_[Number][api.type.Number]._ Maximum age in the user's age range. May be `nil`. |
| 78 | + |
| 79 | +**Examples:** |
| 80 | +- `17` - User is between lowerBound and 17 years old |
| 81 | +- `nil` - No upper limit (typically for verified adults 18+) |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +### event.userStatus |
| 86 | + |
| 87 | +_[String][api.type.String]._ User verification status. Possible values: |
| 88 | + |
| 89 | +**iOS & Android:** |
| 90 | +- `"verified"` - Verified adult (18+), no parental controls |
| 91 | +- `"supervised"` - User with active parental controls (iOS) or Family Link supervision (Android) |
| 92 | +- `"declined"` - User declined to share age range (iOS) |
| 93 | +- `"notAvailable"` - Age range service not available |
| 94 | +- `"error"` - Error occurred |
| 95 | + |
| 96 | +**Android Only:** |
| 97 | +- `"approvalPending"` - Waiting for parental approval |
| 98 | +- `"approvalDenied"` - Parental approval was denied |
| 99 | +- `"unknown"` - Age status unknown, user needs to verify in Play Store |
| 100 | +- `"empty"` - No age data available |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +### event.hasParentalControls |
| 105 | + |
| 106 | +_[Boolean][api.type.Boolean]._ `true` if user has active parental controls or supervision. |
| 107 | + |
| 108 | +**Platform Details:** |
| 109 | +- **iOS:** Screen Time restrictions are active |
| 110 | +- **Android:** Family Link supervision is enabled |
| 111 | + |
| 112 | +--- |
| 113 | + |
| 114 | +### event.errorMessage |
| 115 | + |
| 116 | +_[String][api.type.String]._ Human-readable error message if `isError` is `true`. |
| 117 | + |
| 118 | +**Common Error Messages:** |
| 119 | + |
| 120 | +**iOS:** |
| 121 | +- `"Age range service not available"` - Device doesn't support the API |
| 122 | +- `"User declined to share age range"` - User chose not to share |
| 123 | + |
| 124 | +**Android:** |
| 125 | +- `"Age Signals API not available. Please update Play Store."` |
| 126 | +- `"Play Store not found. Please install or enable Play Store."` |
| 127 | +- `"Network error. Please check connection."` |
| 128 | +- `"User age status unknown. Please verify in Play Store."` |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +### event.errorCode |
| 133 | + |
| 134 | +_[Number][api.type.Number]._ Numeric error code. **Android only.** |
| 135 | + |
| 136 | +Error codes: |
| 137 | +- `-1` - API not available (Play Services outdated) |
| 138 | +- `-2` - Play Store not found or disabled |
| 139 | +- `-3` - Network error |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +### event.installId |
| 144 | + |
| 145 | +_[String][api.type.String]._ Unique install identifier for supervised users. **Android only.** |
| 146 | + |
| 147 | +Used to track individual app installations under Family Link supervision. Useful for: |
| 148 | +- Tracking approval requests across app reinstalls |
| 149 | +- Associating permissions with specific device installations |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +### event.mostRecentApprovalDate |
| 154 | + |
| 155 | +_[Number][api.type.Number]._ Timestamp (milliseconds since Unix epoch) of most recent parental approval. **Android only.** |
| 156 | + |
| 157 | +Convert to readable date: |
| 158 | +``````lua |
| 159 | +if event.mostRecentApprovalDate then |
| 160 | + local dateStr = os.date("%c", event.mostRecentApprovalDate/1000) |
| 161 | + print("Last approved:", dateStr) |
| 162 | +end |
| 163 | +`````` |
| 164 | + |
| 165 | +--- |
| 166 | + |
| 167 | +## Example |
| 168 | +``````lua |
| 169 | +local function ageRangeListener(event) |
| 170 | + if event.name == "ageRangeEvent" then |
| 171 | + print("Event name:", event.name) |
| 172 | + print("Is error:", event.isError) |
| 173 | + print("Is available:", event.isAvailable) |
| 174 | + print("Declined:", event.declined) |
| 175 | + |
| 176 | + if event.lowerBound then |
| 177 | + print("Lower bound:", event.lowerBound) |
| 178 | + end |
| 179 | + |
| 180 | + if event.upperBound then |
| 181 | + print("Upper bound:", event.upperBound) |
| 182 | + end |
| 183 | + |
| 184 | + print("User status:", event.userStatus) |
| 185 | + print("Has parental controls:", event.hasParentalControls) |
| 186 | + |
| 187 | + -- Android-specific |
| 188 | + if event.installId then |
| 189 | + print("Install ID:", event.installId) |
| 190 | + end |
| 191 | + |
| 192 | + if event.mostRecentApprovalDate then |
| 193 | + local date = os.date("%c", event.mostRecentApprovalDate/1000) |
| 194 | + print("Last approval:", date) |
| 195 | + end |
| 196 | + |
| 197 | + if event.errorCode then |
| 198 | + print("Error code:", event.errorCode) |
| 199 | + end |
| 200 | + end |
| 201 | +end |
| 202 | +`````` |
0 commit comments