1.0.1 • Published 3 years ago
react-native-uptime v1.0.1
react-native-uptime
Getting started
$ npm install react-native-uptime --save
Installation
iOS
In XCode, in the project navigator:
1. Right click Libraries ➜ Add Files to [your project's name], go to node_modules ➜ react-native-uptime and add RNUptime.xcodeproj
2. Add libRNUptime.a to your project's Build Phases ➜ Link Binary With Libraries
3. Add $(SRCROOT)/../node_modules/react-native-uptime/ios to your project's Build Settings ➜ Header Search Paths entry
4. In your AppDelegate.m file, add the following code after the RN bridge initialization:
```objective-c
#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);1.0.1
3 years ago