react-native-vitals
v2.0.1
Published
Memory and resource information Native Module for React Native
Downloads
3,110
Readme
react-native-vitals
React Native package that provides memory/storage usage info of a device.
Usage
import Vitals from 'react-native-vitals';
Vitals.getMemory(memory => {
var {
appUsed,
systemTotal,
systemFree,
systemUsed
} = memory;
});
Vitals.getStorage(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
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-vitals
and addRNVitals.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNVitals.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)
iOS (using CocoaPods)
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
- 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 thegetPackages()
method
- 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')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-vitals')