0.2.1 • Published 7 years ago
react-native-crasheye v0.2.1
react-native-crasheye
Introduction
Crasheye react native module.
Base on:
- Crasheye Android SDK 2.2.1
- Crasheye iOS SDK 2.5.1
More infomation: http://www.crasheye.cn/sdk
Getting started
$ npm install react-native-crasheye --save
Mostly automatic installation
$ react-native link react-native-crasheye
You should add crasheye SDK to your iOS project. Official tutorial is here.
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-crasheye
and addRNCrasheye.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNCrasheye.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Add crasheye SDK to your iOS project. Official tutorial is here.
- Run your project (
Cmd+R
)
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.cooclsee.crasheye.RNCrasheyePackage;
to the imports at the top of the file - Add
new RNCrasheyePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-crasheye' project(':react-native-crasheye').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-crasheye/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-crasheye')
Usage
Import
import Crasheye from 'react-native-crasheye';
Initialize SDK
Crasheye.init({
appKey: 'your appKey', // required
channelID: '', // option
appVersion: '', // option
flushOnlyOverWiFi: false, // default false
userIdentifier: '', // option
logging: {
lines: 1000, // option, less than 1000
filter: '', // option
}
});
Get SDK Version
Crasheye.getSDKVersion()
.then(ver => console.log(ver));
// or
let ver = await Crasheye.getSDKVersion();
Get Device ID
Crasheye.getDeviceId()
.then(deviceId => console.log(deviceId));
// or
let deviceId = await Crasheye.getDeviceId();
Add Breadcrumb
Crasheye.leaveBreadcrumb('the breadcrumb content');
Send Exception
Crasheye.sendScriptException('errorTitle', 'exception content');
Add Extra Data
Crasheye.addExtraData('key', 'value');