react-native-crashlytics-answers
v0.2.1
Published
React native wrapper for Fabric's Crashlytics and Answers
Downloads
4
Maintainers
Readme
React Native Crashlytics Answers
Crashlytics and Answers wrapper module for React native Android and iOS
Getting Started
Installation
npm install react-native-crashlytics-answers --save
Setup iOS
See React Native documentation on Linking Libraries
- Open your project in XCode
- Right click on
Libraries
and clickAdd Files to "YOUR_PROJECT _NAME"
- Add
libRNCrashlyticsAnswers.a
toBuild Phases -> Link Binary With Libraries
Setup Android
In settings.gradle
Add to bottom:
include ':CrashlyticsAnswers'
project(':CrashlyticsAnswers').projectDir = new File(rootProject.projectDir, '../../../zinuzoid/react-native-crashlytics-answers/android')
In android/build.gradle
allprojects {
repositories {
mavenLocal()
jcenter()
maven { url 'https://maven.fabric.io/public' } <--- ADD THIS
}
}
In android/app/build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.facebook.react:react-native:0.14.+'
compile project(':CrashlyticsAnswers') <--- ADD THIS
}
In MainApplication.java
import com.zinuzoid.reactnativecrashlyticsanswers.CrashlyticsAnswersPackage; <--- ADD THIS
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new CrashlyticsAnswersPackage()); <--- ADD THIS
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
In AndroidManifest.xml
Add this inside the application
tag.
<meta-data
android:name="io.fabric.ApiKey"
android:value="YOUR_API_KEY" />
Usage
import Fabric from 'react-native-crashlytics-answers'
Fabric.Crashlytics.crash()
Fabric.Crashlytics.setUserIdentify('LEET')
Fabric.Crashlytics.setUserName('Jimmy Fab')
Fabric.Crashlytics.setUserEmail('[email protected]')
Fabric.Crashlytics.logError('error: API response 500')
Fabric.Answers.logEvent('login.success')