react-native-uptime
v1.0.1
Published
Expose React Native initialization performances metrics to JavaScript code
Downloads
5
Readme
react-native-uptime
Getting started
$ npm install react-native-uptime --save
Installation
iOS
In XCode, in the project navigator:
- Right click
Libraries➜Add Files to [your project's name], go tonode_modules➜react-native-uptimeand addRNUptime.xcodeproj - Add
libRNUptime.ato your project'sBuild Phases➜Link Binary With Libraries - Add
$(SRCROOT)/../node_modules/react-native-uptime/iosto your project'sBuild Settings➜Header Search Pathsentry - In your
AppDelegate.mfile, add the following code after the RN bridge initialization:#import "RNUptime.h" ... RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; [RNUptime initializeWithBridge:bridge]; ... - Run your project (
Cmd+R)
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add to the imports at the top of the file:
import com.rnuptime.RNUptimeModule; import com.rnuptime.RNUptimePackage; - Add
new RNUptimePackage(),to the list returned by thegetPackages()method- Add
RNUptimeModule.start();to theonCreate()method.
- Add
- Append the following lines to
android/settings.gradle:include ':react-native-uptime' project(':react-native-uptime').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-uptime/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':react-native-uptime')
Usage
import * as RNUptime from 'react-native-uptime';
const perfData = RNUptime.getPerfData();
console.log('App finished launching with metrics:', perfData);