React Native wrapper for Buglife iOS and Buglife Android.
npm install react-native-buglife --save
react-native link
to link the native libraries to the react wrappers.
If you intend to ship with Buglife to TestFlight or the iOS App Store, you'll need to add
NSPhotoLibraryUsageDescription
to your Info.plist. See this article.
-
Open your app's
build.gradle
, and make sure thecompileSdkVersion
is at least 26, andminSdkVersion
is at least 16. -
If you are not prompted to do so by Android Studio, add the following maven repository to your project's build.gradle
buildscript
section:maven { url 'https://maven.google.com/' name 'Google' }
eg.
buildscript { repositories { jcenter() maven { url 'https://maven.google.com/' name 'Google' } } ... }
-
Add the following lines to the end of the
onCreate()
method in your mainApplication
subclass. (If your app doesn't have one already, create an Application subclass and declare it inAndroidManifest.xml
.)Buglife.initWithEmail(this, "[email protected]"); Buglife.setInvocationMethod(InvocationMethod.SCREENSHOT);
Be sure to replace
[email protected]
with your own email address, as bug reports will be sent to this address.
-
Open
AppDelegate.m
and add the following import statement below the others:#import "Buglife.h"
-
Add the following to the end of the
application:didFinishLaunchingWithOptions:
method inAppDelegate.m
:[[Buglife sharedBuglife] startWithEmail:@"[email protected]"]; [[Buglife sharedBuglife] setInvocationOptions:LIFEInvocationOptionsScreenshot];
-
Add the
NSPhotoLibraryUsageDescription
key to your iOS app's Info.plist if it doesn't have it already. See the Buglife iOS App Store documentation.
Import & initialize Buglife within App.js
:
var Buglife = require('react-native-buglife');
Build & run on a device, then take a screenshot to invoke the bug reporter! Submit your first bug report, and it'll show up in your email.
You may want to add the reporter's email address or other account identifier to your bug reports. You can do this with
// Set an email address
Buglife.setUserEmail("[email protected]");
// Set a user identifier
Buglife.setUserIdentifier("account name");
Your application can include custom JSON attachments with each bug report. For example, to add an attachment solely to the next invocation of the bug reporter:
var myData = { }; // This should be a JSON object with your data
Buglife.addAttachmentWithJSON(myData, "MyData.json");
It’s also possible to add a String attachment:
var myText = "great detailed log"; // This should be a String object with your data
Buglife.addAttachmentWithString(myText, "MyText.text");
In some cases, you may wish to add an attachment on every invocation of the bug reporter; You can do so by subscribing to the BuglifeAttachmentRequest
event:
import { NativeModules, NativeEventEmitter } from 'react-native';
const eventEmitter = new NativeEventEmitter(NativeModules.RNBuglife);
eventEmitter.addListener(Buglife.BuglifeAttachmentRequest, () => {
var appState = {"awesomeness": "Insanely awesome", "volume": 11};
Buglife.addAttachmentWithJSON(appState, "AppState.json");
});
For advanced usage & features (customization, user identification, etc), check out the official Buglife documentation.