|
| 1 | +<a href="https://gauthamvijay.com"> |
| 2 | + <picture> |
| 3 | + <img alt="react-native-play-age-signals" src="./docs/img/banner.png" /> |
| 4 | + </picture> |
| 5 | +</a> |
| 6 | + |
1 | 7 | # react-native-play-age-signals |
2 | 8 |
|
3 | | -React Native Wrapper to Play Age Signals API |
| 9 | +A **React Native TurboModule** that provides a bridge to the **Google Play Age Signals API**, enabling Android apps to query **user supervision and age verification status** when available via Play Services. |
| 10 | + |
| 11 | +[!IMPORTANT] |
| 12 | +- The Play Age Signals SDK (`com.google.android.play:age-signals`) is currently in **beta** and **not yet fully implemented** by Google. |
| 13 | +- Calling `checkAgeSignals()` will currently throw: java.lang.UnsupportedOperationException: Not yet implemented |
| 14 | +- This library is ready and production-safe — it will begin returning real data **automatically** once Google enables the API in upcoming Play Services updates. |
4 | 15 |
|
5 | | -## Installation |
| 16 | +--- |
6 | 17 |
|
| 18 | +## 📦 Installation |
7 | 19 |
|
8 | | -```sh |
| 20 | +```tsx |
9 | 21 | npm install react-native-play-age-signals |
10 | 22 | ``` |
11 | 23 |
|
| 24 | +### 🚀 Zero Config Setup |
| 25 | + |
| 26 | +* **No manual native setup required.** |
| 27 | + This library uses **React Native TurboModules**, so it works out of the box with autolinking — even inside **Expo apps (custom dev clients)**. |
| 28 | +* Supports **React Native 0.72+**. |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## 🔗 Reference Links |
| 33 | + |
| 34 | +* 📘 Google Developer Docs: [Play Age Signals](https://developer.android.com/google/play/age-signals/use-age-signals-api) |
| 35 | +* 🧾 Google Support: [Age-Appropriate Ads Requirements](https://support.google.com/googleplay/android-developer/answer/16569691) |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## 🇺🇸 Why this library exists |
| 40 | + |
| 41 | +This module was built for **production use** in my work app (US-based), where new **state-level legislation** requires mobile apps to verify the user’s age before displaying certain content or ads. |
| 42 | + |
| 43 | +To help other developers comply with these same laws, I’ve **open-sourced** it here. |
| 44 | + |
| 45 | +> The **Google Play Age Signals API** will be the official, privacy-safe method to determine user supervision and age verification status across Android devices in the United States. |
| 46 | +
|
| 47 | +--- |
| 48 | + |
| 49 | +<a href="https://gauthamvijay.com"> |
| 50 | + <picture> |
| 51 | + <img alt="Age Verification Bills in US States" src="./docs/img/bills-in-us.png" /> |
| 52 | + </picture> |
| 53 | +</a> |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## 🧠 What It Does |
| 58 | + |
| 59 | +Once the Play Services feature is live, the module will expose the following fields via `getPlayAgeSignals()`: |
| 60 | + |
| 61 | +``` |
| 62 | +{ |
| 63 | + installId: string | null; |
| 64 | + userStatus: string | null; |
| 65 | + error?: string | null; |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +Example (future API result): |
12 | 70 |
|
13 | | -## Usage |
| 71 | +``` |
| 72 | +{ |
| 73 | + "installId": "123e4567-e89b-12d3-a456-426614174000", |
| 74 | + "userStatus": "VERIFIED" |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +--- |
14 | 79 |
|
| 80 | +## ⚙️ Usage |
| 81 | + |
| 82 | +``` |
| 83 | +import { getPlayAgeSignals } from 'react-native-play-age-signals'; |
| 84 | +import { useEffect } from 'react'; |
| 85 | +import { Text, View } from 'react-native'; |
| 86 | +
|
| 87 | +export default function App() { |
| 88 | + useEffect(() => { |
| 89 | + const fetchSignals = async () => { |
| 90 | + try { |
| 91 | + const result = await getPlayAgeSignals(); |
| 92 | + console.log('Play Age Signals:', result); |
| 93 | + } catch (error) { |
| 94 | + console.error('Failed to fetch Play Age Signals:', error); |
| 95 | + } |
| 96 | + }; |
| 97 | +
|
| 98 | + fetchSignals(); |
| 99 | + }, []); |
| 100 | +
|
| 101 | + return ( |
| 102 | + <View> |
| 103 | + <Text>Check your logs for Play Age Signals output</Text> |
| 104 | + </View> |
| 105 | + ); |
| 106 | +} |
| 107 | +``` |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +## 🧩 Supported Platforms |
| 112 | + |
| 113 | +| Platform | Status | |
| 114 | +| --------------------------------- | ------------------------------------ | |
| 115 | +| **Android** | ✅ Supported (pending SDK activation) | |
| 116 | +| **iOS** | 🚫 Not applicable (returns `null`) | |
| 117 | +| **Expo (Custom Dev Client)** | ✅ Works out of the box | |
| 118 | +| **AOSP Emulator (no Play Store)** | ⚠️ Not supported | |
| 119 | + |
| 120 | +--- |
15 | 121 |
|
16 | | -```js |
17 | | -import { multiply } from 'react-native-play-age-signals'; |
| 122 | +## 🛠️ Under the Hood |
18 | 123 |
|
19 | | -// ... |
| 124 | +This library uses: |
20 | 125 |
|
21 | | -const result = multiply(3, 7); |
22 | 126 | ``` |
| 127 | +AgeSignalsManagerFactory.create(context) |
| 128 | + .checkAgeSignals(AgeSignalsRequest.builder().build()) |
| 129 | +``` |
| 130 | + |
| 131 | +to connect to the Play Services API through a native Kotlin TurboModule and forward results to JavaScript with full error propagation and stack traces. |
| 132 | + |
| 133 | +--- |
| 134 | + |
| 135 | +## 📅 Roadmap |
| 136 | + |
| 137 | +* ✅ TurboModule bridge implementation |
| 138 | +* ✅ Error handling with full Java → JS stack propagation |
| 139 | +* 🚧 Awaiting Play Services rollout of working backend |
| 140 | +* 🔔 Auto-watch for new SDK versions via Dependabot and GitHub Actions |
23 | 141 |
|
| 142 | +--- |
| 143 | + |
| 144 | +## 🤝 Contributing |
| 145 | + |
| 146 | +Pull requests are welcome — especially once Google enables this API! |
24 | 147 |
|
25 | | -## Contributing |
| 148 | +* [Development workflow](CONTRIBUTING.md#development-workflow) |
| 149 | +* [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request) |
| 150 | +* [Code of conduct](CODE_OF_CONDUCT.md) |
26 | 151 |
|
27 | | -- [Development workflow](CONTRIBUTING.md#development-workflow) |
28 | | -- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request) |
29 | | -- [Code of conduct](CODE_OF_CONDUCT.md) |
| 152 | +--- |
30 | 153 |
|
31 | | -## License |
| 154 | +## 🪪 License |
32 | 155 |
|
33 | | -MIT |
| 156 | +MIT © [Gautham Vijayan](https://gauthamvijay.com) |
34 | 157 |
|
35 | 158 | --- |
36 | 159 |
|
37 | 160 | Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob) |
| 161 | + |
| 162 | +--- |
0 commit comments