react-native-screen-time-api
v0.2.1
Published
React Native for accessing the iOS Screen Time and Android Digital Wellbeing (coming soon) APIs.
Downloads
112
Maintainers
Readme
React Native Screen Time API
Access the Screen Time API for iOS and Wellbeing API for Android (coming soon). This is far from complete and needs more work. Please don't hesitate to request specific screen time features
Table of Contents
Installation
npm install react-native-screen-time-api
or
yarn add react-native-screen-time-api
Then run npx pod-install
.
Usage
import { ScreenTime } from 'react-native-screen-time-api';
React.useEffect(() => {
ScreenTime.requestAuthorization('individual').then(async () => {
const status = await ScreenTime.getAuthorizationStatus();
console.log('Authorization status:', status); // 'approved', 'denied', or 'notDetermined'
if (status !== 'approved') {
throw new Error('user denied screen time access');
}
await selection = await ScreenTime.displayFamilyActivityPicker();
console.log('Family activity selection:', selection);
// selection will be `null` if user presses cancel
if (selection) {
await ScreenTime.setActivitySelection(selection); // sets the shields
}
});
}, []);