Newline Pending Merge

    This package has been deprecated

    Author message:

    Package no longer supported. Use at your own risk.

    react-native-crash-reporter

    0.5.0 • Public • Published

    react-native-crash-reporter

    react-native-crash-reporter is a small library that hooks into the JavaScript error system and reports the unrolled stack trace to the native side. On the native side a callback will be called where the error information can be forwarded to a crash reporting system of choice. To be able to unroll the error it uses the sourcemap, which is automatically created while the React Native bundle is generated

    Getting started

    $ npm install react-native-crash-reporter --save

    Mostly automatic installation

    $ react-native link react-native-crash-reporter

    Manual installation

    iOS

    1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
    2. Go to node_modulesreact-native-crash-reporter and add MSRCrashReporter.xcodeproj
    3. In XCode, in the project navigator, select your project. Add libMSRCrashReporter.a to your project's Build PhasesLink Binary With Libraries
    4. Run your project (Cmd+R)<

    Android

    1. Open up android/app/src/main/java/[...]/MainApplication.java
    • Add import net.mischneider.MSRCrashReporterPackage; to the imports at the top of the file
    • Add new MSRCrashReporterPackage() to the list returned by the getPackages() method
    1. Append the following lines to android/settings.gradle:
      include ':react-native-crash-reporter'
      project(':react-native-crash-reporter').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-crash-reporter/android')
      
    2. Insert the following lines inside the dependencies block in android/app/build.gradle:
        compile project(':react-native-crash-reporter')
      

    Usage

    First is to define how the native part should handle crash reports. On Android register a listener on the MSRCrashReporterModule:

    MSRCrashReporterModule.getInstance().setOnRecordCustomExceptionCallback(new MSRCrashReporterModule.OnCrashReporterRecordCustomExceptionCallback() {
        @Override
        public void recordCustomException(Exception e) {
            // TODO: Handle the exception 
        }
    });

    On iOS register a listener block on the MSRCrashReporter singleton:

    [MSRCrashReporter sharedReporter].recordCustomExceptionHandler = ^(NSString * _Nonnull name, NSString * _Nonnull reason, NSArray<MSRCrashReporterStackFrame *> * _Nonnull frameArray) {
        // TODO: Handle crash
    };

    Initialize the crash reporter usually in your index.js of your app:

    import { init as initCrashReporting } from 'react-native-crash-reporter';
     
    initCrashReporting({ captureOnDebugMode: false });

    Install

    npm i react-native-crash-reporter

    DownloadsWeekly Downloads

    2

    Version

    0.5.0

    License

    Apache-2.0

    Unpacked Size

    150 kB

    Total Files

    16

    Last publish

    Collaborators

    • maicki