HomeDocumentationAPI Reference
Getting StartedAPI ReferenceBug ReportingCrash ReportingAPMHelp Center
These docs are for v9.0. Click to read the latest docs for v12.0.0.

Integrating Instabug

This page covers how to install the Instabug SDK in your Flutter application.

Installation

First, add Instabug to your pubspec.yaml file.

dependencies:
    instabug_flutter:

Then install the package by running the following command.

flutter packages get

Using Instabug

  1. To start using Instabug, import it into your Flutter application.
import Instabug, { BugReporting, Surveys, FeatureRequests } from 'instabug-reactnative';
  1. Initialize the SDK in initState(). This line enables the SDK with the default behavior and sets it to be shown when the devices is shaken. You can customize this behavior through APIs (you can skip this step if you are building an Android app only).
//Make sure to replace APP_TOKEN with your application token.
Instabug.start('APP_TOKEN', [InvocationEvent.shake]);
  1. If your app supports Android, create a new Java class that extends FlutterApplication and add it to your AndroidManifest.xml.
<application
    android:name=".CustomFlutterApplication"
    ...
</application>

In your newly created CustomFlutterApplication class, override onCreate() and add the following code.

ArrayList<String> invocationEvents = new ArrayList<>();
invocationEvents.add(InstabugFlutterPlugin.INVOCATION_EVENT_SHAKE);
new InstabugFlutterPlugin().start(CustomFlutterApplication.this, "APP_TOKEN", invocationEvents);

You can find your app token by selecting SDK Integration in the Settings menu from your Instabug dashboard.

Managing Permissions (iOS Only)

Instabug needs access to the device microphone and photo library to be able to let users add audio, image, and video attachments. Starting from iOS 10, apps that don’t provide a usage description for those two permissions will be rejected when submitted to the App Store.

To prevent your app from being rejected, you’ll need to add the following two keys to your app’s info.plist file with text that explains to your app users why those permissions are needed:

  • NSMicrophoneUsageDescription
  • NSPhotoLibraryUsageDescription

If your app doesn’t already access the microphone or photo library, we recommend usage descriptions like:

  • " needs access to your microphone so you can attach voice notes."
  • " needs access to your photo library so you can attach images."

The permission alert for accessing the microphone/photo library will NOT appear unless users attempt to attach a voice note/photo while using Instabug.

🚧

Permissions Are Required

The above permissions are required in order for you to receive attachments from your users through the Instabug SDK.


What’s Next

Now that you've successfully integrated Instabug, check out how to show Instabug using different methods, how to identify your users, or how to customize your SDK.