Home

Awesome

react-native-fabric

A React Native library for Fabric, Crashlytics and Answers

NPM

Versioning

For Twitter Kit support, see react-native-fabric-twitterkit

Installation

1. Add Fabric / Crashlytics to your project

2. Add react-native-fabric

Automatically

react-native install react-native-fabric, or with rnpm: rnpm install react-native-fabric

React Native / rnpm will automatically link all the necessary libraries for both iOS and Android.

If the installation goes off without a hitch, you can now skip to the Crashlytics Usage section or the Answers Usage section.

Manually

npm install react-native-fabric --save

Manually iOS With CocoaPods support

pod 'ReactNativeFabric', :path => '../node_modules/react-native-fabric'

Manually iOS Without CocoaPods support

Download the Crashlytics SDK and place the two frameworks in a directory called Crashlytics in the ios directory. You may want to add this directory to your .gitignore as they take up a decent amount of space and will slow down Git.

You will also need to modify the Run Script Phase that you likely added to Build Phases so that it points to the correct location for the Fabric framework. If you placed the framework directly under ios/Crashlytics as specified above,t the contents of the script will then be:

"${SRCROOT}/Crashlytics/Fabric.framework/run" API_KEY API_SECRET

Then do the following:

<a name="android"></a>

Android

*Note: Android support requires React Native 0.16 or later

<a name="no_android_studio"></a>

Android without Android Studio

Make sure you also follow the steps described in Android.

Crashlytics Usage

Note: logging will not be registered on Android to the Fabric dashboard until the app is bundled for release.

To see all available methods take a look at Crashlytics.js

var Fabric = require('react-native-fabric');

var { Crashlytics } = Fabric;

Crashlytics.setUserName('megaman');

Crashlytics.setUserEmail('user@email.com');

Crashlytics.setUserIdentifier('1234');

Crashlytics.setBool('has_posted', true);

Crashlytics.setString('organization', 'Acme. Corp');

// Forces a native crash for testing
Crashlytics.crash();

// Due to differences in primitive types between iOS and Android I've exposed a setNumber function vs. setInt, setFloat, setDouble, setLong, etc                                        
Crashlytics.setNumber('post_count', 5);

// Record a non-fatal JS error only on Android
Crashlytics.logException('');

// Record a non-fatal JS error only on iOS
Crashlytics.recordError('something went wrong!');

Answers Usage

To see all available function take a look at Answers.js

var Fabric = require('react-native-fabric');

var { Answers } = Fabric;

// All log functions take an optional object of custom attributes as the last parameter
Answers.logCustom('Performed a custom event', { bigData: true });

Answers.logContentView('To-Do Edit', 'To-Do', 'to-do-42', { userId: 93 });

Answers.logAddToCart(24.50, 'USD', 'Air Jordans', 'shoes', '987654', {color: 'red'});

Answers.logInvite('Facebook');

Answers.logLogin('Twitter', true);

Answers.logSearch('React Native');

Answers.logShare('Twitter', 'Big news article', 'post', '1234');

Answers.logSignUp('Twitter', true);

Answers.logPurchase(24.99,'USD',true, 'Air Jordans', 'shoes', '987654');


License

MIT © Cory Smith 2016