This page covers how to install the Instabug SDK in your Flutter application.
First, add Instabug to your
Then install the package by running the following command.
flutter packages get
- To start using Instabug, import it into your Flutter application.
- Initialize the SDK in
initState(). This line enables the SDK with the default behavior and sets it to be shown when the device is shaken.
//Make sure to replace APP_TOKEN with your application token. Instabug.init( token: 'APP_TOKEN', invocationEvents: [InvocationEvent.shake], );
You can find your app token by selecting SDK Integration in the Settings menu from your Instabug dashboard.
Permissions Are Required
The below permissions are required in order for you to receive attachments from your users through the Instabug SDK.
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:
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 automatically added to your
AndroidManifest.xml file. Some of them are required to be able to fetch information like network and WiFi connection. Others are used to allow your users to attach images, videos, and audio recordings. In general, permission requests don't appear unless your user attempts to use a feature requiring a permission.
The only exception is if you set the invocation event to be a Screenshot. In that case, the storage permission will be requested when your application launches. The screenshot invocation is a special case because there is no native event that tells the SDK that a screenshot has been captured. The only way to know is to monitor the screenshots directory. The SDK is invoked when a screenshot is added to the directory while your application is active.
<uses-permission android:name=“android.permission.ACCESS_NETWORK_STATE” /> <uses-permission android:name=“android.permission.WRITE_EXTERNAL_STORAGE” /> <uses-permission android:name=“android.permission.READ_EXTERNAL_STORAGE” /> <uses-permission android:name=“android.permission.ACCESS_WIFI_STATE” /> <uses-permission android:name=“android.permission.RECORD_AUDIO” /> <uses-permission android:name=“android.permission.MODIFY_AUDIO_SETTINGS” /> <uses-permission android:name=“android.permission.INTERNET” /> <uses-permission android:name=“android.permission.WAKE_LOCK” />
You can remove any of the permissions if you will not be using the feature associated with it, as in the following example.
<uses-permission android:name=“android.permission.WRITE_EXTERNAL_STORAGE” tools:node=“remove”/>
Updated about 1 month ago
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.