Gradle
Add this line to your build.gradle file.
implementation 'com.softnoesis.shakebug:ShakeBug:1.2.37'
Note: The latest version of the Shakebug Android SDK is 1.2.37 . Open Detail
Usage
In your Application class or Launching activity add this line to your onCreate method.
You may also need to add the following to your project/build.gradle file:
buildscript { repositories { mavenCentral() maven { url 'https://jitpack.io' } } }
Then, update the following SDK version in your app's build.gradle file:
android { compileSdk 33 defaultConfig { ... targetSdk 33 ... } ... }
For a seamless experience with our SDK, include maven { url 'https://jitpack.io' } in your build.gradle file under allprojects > repositories . Avoid potential issues and enjoy smooth integration.
allprojects { repositories { google() mavenCentral() maven { url 'https://jitpack.io' } } }
Code
1. In your Launching activity add this line to your onCreate method. This initializes Shake Bug with the default invocation event, Shake.
Java
ShakeBug.sharedInstance().initiateWithKey(this, "<Your Key>");
Kotlin
ShakeBug.sharedInstance().initiateWithKey(this,"<Your Key>")
Be sure to replace <Your Key> with your application key provided by the ShakeBug website.
Optional Settings
1. If you want to add an event to any screen or activity, use the following methods:
Java
ShakeBug.sharedInstance().addEventKey(this,"<Key>","<Key Value>"); //pass any key or value
Kotlin
ShakeBug.sharedInstance().addEventKey(this,","<Key>","<Key Value>") // pass any key or value
2. Use the following to enable or disable the first-time tutorial screen:
Java
ShakeBug.sharedInstance().showTutorialScreenFirstTime(true); // Default value True
Kotlin
ShakeBug.sharedInstance().showTutorialScreenFirstTime(true) // Default value True
3. If you want to forcefully set a specific language for the bug reporting screen, use the following code:
Java
ShakeBug.sharedInstance().setShakebugLanguage(ShakebugLanguage.FRENCH, this);
Kotlin
ShakeBug.sharedInstance().setShakebugLanguage(ShakebugLanguage.FRENCH, this)
Note:
Just mind that here, by default it will take device language as default language.
4. Developers can also set a custom theme color in Shakebug SDK screens:
Java
ShakeBug.sharedInstance().setShakebugThemeColor(134,235,52);
Kotlin
ShakeBug.sharedInstance().setShakebugThemeColor(134,235,52)
5. Developers can also set a custom title for the Shakebug annotation and feedback input screens:
Java
ShakeBug.sharedInstance().changeSDKScreenTitle("Annotate your Bug", "Feedback");
Kotlin
ShakeBug.sharedInstance().changeSDKScreenTitle("Annotate your Bug", "Feedback")
6. Set a custom error message for any error alert screen from the SDK.
Java
ShakeBug.sharedInstance().changeSDKErrorAlertMessage("Something wrong...");
Kotlin
ShakeBug.sharedInstance().changeSDKErrorAlertMessage("Something wrong...")
7. If you have an on-premise hosting plan, use the following method:
Java
ShakeBug.sharedInstance().setShakebugSDKEndPointURL("","","");
Kotlin
ShakeBug.sharedInstance().setShakebugSDKEndPointURL("","","")
Note:
New endpoint URL, its header key, and SSL public key (optional).
8. If you want to trigger the bug reporting screen without shaking, you can call the following method in any button action of any screen:
Java
ShakeBug.sharedInstance().triggerBugReporting();
Kotlin
ShakeBug.sharedInstance().triggerBugReporting()
9. Add the following to allow reporting bugs by shaking the mobile device:
Java
ShakeBug.sharedInstance().allowToReportBugByShakingMobile(true);
Kotlin
ShakeBug.sharedInstance().allowToReportBugByShakingMobile(true)
10. Add the following to allow reporting bugs by screenshot capture event:
Java
ShakeBug.sharedInstance().allowToReportBugByScreenCapture(true)
Kotlin
ShakeBug.sharedInstance().allowToReportBugByShakingMobile(true)
The following types of iOS projects are supported:
- Swift
- Objective-C
- SwiftUI
- Project with and without SceneDeleage
Compatibility
- Minimum iOS deployment 13.0
- Minimum Mac OS deployment 10.15
- Carthage release for Swift is built with Xcode 13.0 or later
- CocoaPods: 1.10 or later.
Installation
CocoaPods
To integrate ShakeBug into your Xcode project using CocoaPods, add the following line to your Podfile:
pod 'ShakeBug'
Then, run the following command:
$ pod install
Note: Latest version of Shakebug iOS SDK is 1.0.35. Open Detail
Carthage
Add following line to your Xcode project's Cartfile
github "softnoesis/ShakeBug"
Then, run the following command:
$ carthage update
Then drag Shakebug.xcframework from Carthage folder to your Xcode project's settings.
Swift Package Manager
Navigate to the SPM section in your project, add a new package, point it to
https://github.com/softnoesis/ShakeBug/
and select the latest version.
Code
1. Import the ShakeBug framework into your AppDelegate.
Swift
import ShakeBug
Objective-C
#import <ShakeBug/ShakeBug.h>
#import <ShakeBug/ShakeBug-Swift.h>
2. Add the following line to your AppDelegate's application:didFinishLaunchingWithOptions: method:
Swift
ShakeBugSDK.sharedInstance.initiateWithKey(“<Your Key>")
Objective-C
[[ShakeBugSDK sharedInstance] initiateWithKey:@"<Your Key>"];
Be sure to replace
3. Add the following to your Info.plist to request permission to access the Photo Library.
<dict>
<key>NSPhotoLibraryUsageDescription</key>
<string>Require access for reporting bugs.</string>
</dict>
Be sure to replace
Note:
NSPhotoLibraryUsageDescription must be added to your Info.plist.
Optional Settings
1. Add the following to your app delegate's application:didFinishLaunchingWithOptions: method for showing or not showing first time tutorial screen
Swift
ShakeBugSDK.sharedInstance.showTutorialScreenFirstTime(false) // Default value True
Objective-C
[[ShakeBugSDK sharedInstance] showTutorialScreenFirstTime:NO];// Default value YES
2. If you want to show bug or crash from Simulator then use following code
application:didFinishLaunchingWithOptions:
Swift
ShakeBugSDK.sharedInstance.allowBugCrashFromSimulator(true) // Default value false
Objective-C
[[ShakebugSDK sharedInstance] allowCrashFromSimulator:YES];// Default value NO
3. If you dont want to show any logs on console then use following code
application:didFinishLaunchingWithOptions:
Swift
ShakeBugSDK.sharedInstance.makeLogEnabled(false)// Default value false
Objective-C
[[ShakeBugSDK sharedInstance] makeLogEnabled:NO];// Default value NO
4. If you want to set forcefully any language for the bug reporting screen then use following code
application:didFinishLaunchingWithOptions:
Swift
ShakeBugSDK.sharedInstance.setShakebugSDKLanguage(ShakebugLanguage.french)
Objective-C
[[ShakeBugSDK sharedInstance] setShakebugSDKLanguage:ShakebugLanguage.french];
Note:
Just mind that here, by default it will take device language as defualt language.
5. Developer can also set custome theme color in Shakebug SDK screens:
Swift
ShakeBugSDK.sharedInstance.setShakebugThemeColor(UIColor.green)
Objective-C
[[ShakeBugSDK sharedInstance] setShakebugThemeColor:[UIColor greenColor]];
6. Developer can also set custom title for Shakebug annotate and feedback input screen:
Swift
ShakeBugSDK.sharedInstance.changeSDKScreenTitle("Annotate your Bug", "Feedback")
Objective-C
[[ShakeBugSDK sharedInstance] changeSDKScreenTitle:@"Annotate your bug" :@"Add detail"];
7. Set custom error message for any error alert screen from SDK.
Swift
ShakeBugSDK.sharedInstance.changeSDKErrorAlertMessage("This Error")
Objective-C
[[ShakeBugSDK sharedInstance] changeSDKErrorAlertMessage:@"Something wrong.."];
8. If you have on-premise hosting plan then following method will be used.
Swift
ShakeBugSDK.sharedInstance.setShakebugSDKEndPointURL(url: "", headerKey: "", sslPublicKey: "")
Objective-C
[[ShakeBugSDK sharedInstance] setShakebugSDKEndPointURLWithUrl:@"" headerKey:@"" sslPublicKey:@""];
Note:
New endpoint url, its header key and SSL public key(Optional)
9. User can report bug either by shaking phone or by triggering default screen capture event. This method can be used to manage "screen capture" event should trigger bug reporting or not.
Swift
ShakeBugSDK.sharedInstance.allowToReportBugByScreenCapture(false) // Default value true
Objective-C
[[ShakeBugSDK sharedInstance] allowToReportBugByScreenCapture:NO]; // Default value YES
10. User can report bug either by shaking phone or by triggering default screen capture event. This method can be used to manage "shaking mobile" should trigger bug reporting or not.
Swift
ShakeBugSDK.sharedInstance.allowToReportBugByShakingMobile(true) // Default value true
Objective-C
[[ShakeBugSDK sharedInstance] allowToReportBugByShakingMobile:YES]; // Default value YES
Events
To add an event to any screen or activity, use the following methods:
Swift
ShakeBugSDK.sharedInstance.addEventKey(key:"App_open", eventValue: "Started app")//pass any key or value
Objective-C
[[ShakeBugSDK sharedInstance] addEventKey:@"App_open" eventValue:@"Started app"];// pass any key or value
Usage
Build and run your app. Once it's running, shake your device (or press ^⌘Z in the simulator) to report a bug! Bug and crash reports are sent directly to the ShakeBug.com dashboard and also notify you via your registered email address.
If you want to trigger bug reporting screen without shaking then you can call following method in any button action of any screen.
Swift
ShakeBugSDK.sharedInstance.triggerBugReporting()
Objective-C
[[ShakeBugSDK sharedInstance] triggerBugReporting];
Be sure to replace
npm
Installation
Navigate to your React Native project directory and install shakebug-react-native.
npm install shakebug-react-native
Alternatively, if you prefer to use Yarn instead of npm:
yarn add shakebug-react-native
IOS
1. You need to provide permissions inside ios/YourProjectName/Info.plist:
<key>NSCameraUsageDescription</key>
<string></string>
<key>NSMicrophoneUsageDescription</key>
<string></string>
<key>NSPhotoLibraryUsageDescription</key>
<string></string>
2. CocoaPods installation:
cd ios && pod install && cd ..
Android
Android minSdkVersion 24 is required. You can change it in android/build.gradle:
buildscript {
...
ext {
...
minSdkVersion = 24 or later
...
}
...
}
Usage
You need to import ShakebugView in the root file of your application (App.js):
Import ShakebugView from 'shakebug-react-native';
export default App = () => {
return(
<ShakebugView
Android_appkey="your android app key"
iOS_appkey="your ios app key"
other options...
>
//Your code...
</ShakebugView>
)
}
If you use NavigationContainer in App.js (where you import ShakebugView), then you need to pass independent as a parameter in NavigationContainer:
Import ShakebugView from 'shakebug-react-native';
export default App = () => {
return(
<ShakebugView
Android_appkey="your android app key"
iOS_appkey="your ios app key"
other options…
>
<NavigationContainer independent>
//Your code...
</NavigationContainer>
</ShakebugView>
)
}
You can add an event on click:
import { Button } from 'react-native';
import ShakebugView, { addEventKey } from 'react-native-shakebug';
export default App = () => {
return(
<Button
title='Press'
onPress={() => {
addEventKey("key_name", value)
}}
/>
)
}
import { Button } from 'react-native';
import { ShakebugSdkProtectedView } from 'react-native-shakebug';
export default App = () => {
return(
<ShakebugSdkProtectedView>
<View>
<Text>This is sensitive information!</Text>
</View>
</ShakebugSdkProtectedView>
)
}
Properties
Key Name | Type | Description | Default Value |
---|---|---|---|
Android_appkey | String(required) | This initializes ShakeBug with the default invocation event. Be sure to pass your application key provided by the ShakeBug website. | - |
iOS_appkey | String(required) | This initializes ShakeBug with the default invocation event. Be sure to pass your application key provided by the ShakeBug website. | class="text-center"- |
showTutorialScreenFirstTime | boolean | Enable or disable the first-time tutorial screen. | true |
ShakebugThemeColor | String | Developers can also set a custom theme color in ShakeBug SDK screens. | - |
changeSDKScreenTitle | Array | Developers can also set custom titles for the ShakeBug annotation and feedback input screens. | ["Annotate your bug", "Add Details"] |
allowToReportBugByShakingMobiles | boolean | Allow bug reporting by shaking the mobile device. | true |
allowToReportBugByScreenCapture | boolean | Allow bug reporting by screenshot capture event. | false |
ShakebugLanguage | String | To forcefully set a specific language for the bug reporting screen, use the following prop. | Your Device's language |
allowCrashReport | boolean | To allow crash reporting when the app crashes, use the following prop. | true |
makeLogEnabled | boolean | To display logs in the console, use the following prop. | false |
setShakebugSDKEndPointURL | Array | If you have an on-premise hosting plan, use the following prop. | - |
Methods
Name | Description | Usage |
---|---|---|
addEventKey | If you want add event to any screen or activity use following method | addEventKey("Key_name", value) Documentation |
Native
Native-IOS
For iOS project, developer must need to install Shakebug in xCode project using pod.
To install Shakebug SDK in xCode project. Please follow above For iOS guide.
Native-Android
Gradle
Add this line to your build.gradle file.
implementation 'com.softnoesis.shakebug:ShakeBug:1.2.37'
Open package having MainActivity.java file and add following 2 lines in "onCreate" method.
ShakeBug.sharedInstance().initiateWithFlutterKey(this, "");
initializeShakeDetection();
Below the "onCreate" method, write all the following methods.
//Manages the registration and unregistration of the sensor listener.
@Override
protected void onResume() {
super.onResume();
if (mSensorManager != null && mSensorListener != null) {
Sensor accelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (accelerometer != null) {
mSensorManager.registerListener(mSensorListener, accelerometer, SensorManager.SENSOR_DELAY_UI);
}
}
}
@Override
protected void onPause() {
super.onPause();
if (mSensorManager != null && mSensorListener != null) {
mSensorManager.unregisterListener(mSensorListener);
}
}
// Sets up the shake event listener.
private void initializeShakeDetection() {
mSensorManager = (SensorManager) this.getSystemService(Context.SENSOR_SERVICE);
mSensorListener = new ShakeBugShakeEventListener();
mSensorListener.setOnShakeListener(this::captureScreenshot);
}
//Captures a screenshot of the Flutter view using PixelCopy.
private void captureScreenshot() {
FrameLayout content = findViewById(android.R.id.content);
FlutterView flutterView = (FlutterView) content.getChildAt(0);
if (flutterView == null) {
Log.e("ShakeBug", "FlutterView not found");
return;
}
SurfaceView surfaceView = (SurfaceView) flutterView.getChildAt(0);
surfaceView.post(() -> {
Bitmap screenshot = Bitmap.createBitmap(surfaceView.getWidth(), surfaceView.getHeight(),Bitmap.Config.ARGB_8888);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
PixelCopy.request(surfaceView, screenshot, result -> {
if (result == PixelCopy.SUCCESS) {
ShakeBug.sharedInstance().flutterScreenshot(screenshot, this);
} else {
Log.e("ShakeBug", "Screenshot failed");
}
}, new Handler());
} else {
Log.e("ShakeBug", "PixelCopy requires Android Nougat or higher.");
}
});
}
Optional Settings
1. If you want add event to any screen or activity use following methods.
Java
ShakeBug.getInstance().addEventKey(this,"<Key>","<Key Value>"); //pass any key or value
Kotlin
ShakeBug.getInstance().addEventKey(this,"<Key>","<Key Value>") // pass any key or value
2. Use the following method to enable or disable the first-time tutorial screen:
Java
ShakeBug.getInstance().showTutorialScreenFirstTime(true); // Default value True
Kotlin
ShakeBug.getInstance().showTutorialScreenFirstTime(true) // Default value True
Usage
Build & run your app. Once your app is running, shake your device to report a bug! Bug/Crash reports are sent directly to login panel of Shakebug.com and also notify on your registered email address.
WebGoogle Chrome Extension:
You can seamlessly integrate Shakebug into your web project using our Google Chrome Extension:
First, ensure that the URL of your website is added to your Shakebug account. Log in to your Shakebug account and navigate to the project page to add your website URL.
Next, install the Shakebug Chrome Extension from the Chrome Web Store.
After installation, click on the Shakebug Extension icon in your browser's toolbar.the extension will allow you to report bugs directly from your browser.
Java Script
Copy the following code before the closing