Invocation

This section covers how to change the event done by the user to invoke the SDK, as well as the default feature to be used once the SDK is invoked.

By default, Instabug is invoked when the device is shaken. This can be customized to several other out-of-the-box modes to show the SDK. You can also show the SDK manually from a custom gesture or a button you add to your app.

Invocation Events

You can set the SDK to be shown using one of the following modes:

  • Shake device
  • Take a screenshot
  • Tap on a floating button shown above your app's UI
  • Do a 2-finger swipe from right to left

To customize the invocation event, pass one of the values of the Instabug.invocationEvent enum when starting the SDK.

// Open index.ios.js
Instabug.startWithToken('YOUR_TOKEN', [Instabug.invocationEvent.floatingButton]);

//Second argument takes an array of invocation events
// Open android/app/src/main/java/[...]/MainApplication.java
// Shange the invocation event
@Override
protected List<ReactPackage> getPackages() {
	return Arrays.<ReactPackage>asList(
	new MainReactPackage(),
	new RNInstabugReactnativePackage.Builder("TOKEN",MainApplication.this)
							.setInvocationEvent("shake", "button", "screenshot")
							.setPrimaryColor("#1D82DC")
							.setFloatingEdge("left")
							.setFloatingButtonOffsetFromTop(250)
							.build()
}

Here are the possible invocation events.

Instabug.invocationEvent.none
Instabug.invocationEvent.shake
Instabug.invocationEvent.screenshot
Instabug.invocationEvent.twoFingersSwipe
Instabug.invocationEvent.floatingButton
"none"
"shake"
"screenshot"
"swipe"
"button"

Shaking Threshold

If you are using the shaking gesture as your invocation event you can set how sensitive your device is to the shaking. The default value is 350. The higher the value the less sensitive the device will be to shaking.

//iPhone
BugReporting.setShakingThresholdForiPhone(iPhoneShakingThreshold);

//iPad
BugReporting.setShakingThresholdForiPad(iPadShakingThreshold);
BugReporting.setShakingThresholdForAndroid(androidThreshold);

Manual Invocation

If you want to invoke the SDK manually, use the invoke method.

BugReporting.invoke();

Normally when the SDK is invoked the users are shown a window from which they can select what exactly they want to do.

Alternatively, you could show the SDK with a specific feature.

//First argument is the mode of the invocation while the second takes an array of invocation options
BugReporting.invokeWithInvocationModeAndOptions(invocationMode, invocationOptions);

Here are the possible modes and options.

//Modes
BugReporting.invocationMode.NA;
BugReporting.invocationMode.newBug;
BugReporting.invocationMode.newFeedback;
BugReporting.invocationMode.newChat;
BugReporting.invocationMode.chatsList;

//Options
BugReporting.invocationOptions.emailFieldHidden;
BugReporting.invocationOptions.emailFieldOptional;
BugReporting.invocationOptions.commentFieldRequired;
BugReporting.invocationOptions.disablePostSendingDialog;