https://github.com/robinpowered/react-native-vitals
Memory and resource information Native Module for React Native
https://github.com/robinpowered/react-native-vitals
Last synced: about 1 year ago
JSON representation
Memory and resource information Native Module for React Native
- Host: GitHub
- URL: https://github.com/robinpowered/react-native-vitals
- Owner: robinpowered
- License: mit
- Created: 2017-10-27T18:00:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-12-06T21:22:53.000Z (over 6 years ago)
- Last Synced: 2025-03-24T04:43:39.759Z (about 1 year ago)
- Language: Objective-C
- Homepage:
- Size: 60.5 KB
- Stars: 56
- Watchers: 9
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-vitals
React Native package that provides memory/storage usage info of a device.
## Usage
```javascript
import Vitals from 'react-native-vitals';
Vitals.getMemory().then(memory => {
var {
appUsed,
systemTotal,
systemFree,
systemUsed
} = memory;
});
Vitals.getStorage().then(storage => {
var {
total,
free,
used
} = storage;
});
Vitals.addLowMemoryListener(memory => {
console.log('Low memory warning triggered');
var {
appUsed,
systemTotal,
systemFree,
systemUsed
} = memory;
})
```
## Getting started
`$ npm install react-native-vitals --save`
### Mostly automatic installation
`$ react-native link react-native-vitals`
### Manual installation
#### iOS
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
2. Go to `node_modules` ➜ `react-native-vitals` and add `RNVitals.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNVitals.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`)
#### iOS (using [CocoaPods](https://cocoapods.org/))
Alternatively, you can use CocoaPods to manage your native dependencies, just add this inside your `Podfile`:
```
pod 'react-native-vitals', :path => '../node_modules/react-native-vitals'
```
After adding this, you need to run `pod install` inside the `ios`-folder of your RN application.
#### Android
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
- Add `import com.robinpowered.react.vitals.RNVitalsPackage;` to the imports at the top of the file
- Add `new RNVitalsPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
```
include ':react-native-vitals'
project(':react-native-vitals').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vitals/android')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
compile project(':react-native-vitals')
```