1.0.1 • Published 1 year ago

react-native-uptime v1.0.1

Weekly downloads
-
License
private
Repository
-
Last release
1 year ago

react-native-uptime

Getting started

$ npm install react-native-uptime --save

Installation

iOS

In XCode, in the project navigator: 1. Right click LibrariesAdd Files to [your project's name], go to node_modulesreact-native-uptime and add RNUptime.xcodeproj 2. Add libRNUptime.a to your project's Build PhasesLink Binary With Libraries 3. Add $(SRCROOT)/../node_modules/react-native-uptime/ios to your project's Build SettingsHeader 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];

...

```
  1. Run your project (Cmd+R)

Android

  1. 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 the getPackages() method
    • Add RNUptimeModule.start(); to the onCreate() method.
  1. 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')
  2. 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

1 year ago