@deventer/react-native-usage-stats-manager
v0.1.1
Published
React Native Library for Accessing Android Usage Stats/Events (Updated for New Architecture)
Maintainers
Readme
@deventer/react-native-usage-stats-manager
The goal of this fork is to provide a simple bridge between Android UsageStats and React Native, without any custom aggregation. Instead, the raw usage stats and events are made available directly in React Native.
This library has been updated for the New Architecture of React Native, ensuring better compatibility with recent changes in the framework. With support for Fabric, TurboModules, and JSI (JavaScript Interface), it enhances performance, scalability, and development flexibility.
Installation
npm install react-native-usage-stats-managerAndroid
Permission need to be added on AndroidManifest.xml
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
Usage
import {
EventFrequency,
checkForPermission,
queryUsageStats,
showUsageAccessSettings,
} from '@deventer/react-native-usage-stats';
Time needs to be in millisecond for function queryUsageStats
const startDateString = '2023-06-11T12:34:56';
const endDateString = '2023-07-11T12:34:56';
const startMilliseconds = new Date(startDateString).getTime();
const endMilliseconds = new Date(endDateString).getTime();
const result = await queryUsageStats(
EventFrequency.INTERVAL_DAILY,
startMilliseconds,
endMilliseconds
)Contributing
License
MIT
Made with create-react-native-library
