Gradle
Add this line to your build.gradle file.
implementation 'com.softnoesis.shakebug:ShakeBug:1.2.37'
Note: Latest version of 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 sdkVersion to 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 which given by ShakeBug website.
Optional Settings
1. If you want add event to any screen or activity use 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. Add the following for enabling/disabling 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 set forcefully any language for the bug reporting screen then use 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 defualt language.
4. Developer can also set custome theme color in Shakebug SDK screens:
Java
ShakeBug.sharedInstance().setShakebugThemeColor(134,235,52);
Kotlin
ShakeBug.sharedInstance().setShakebugThemeColor(134,235,52)
5. Developer can also set custom title for Shakebug annotate and feedback input screen:
Java
ShakeBug.sharedInstance().changeSDKScreenTitle("Annotate your Bug", "Feedback");
Kotlin
ShakeBug.sharedInstance().changeSDKScreenTitle("Annotate your Bug", "Feedback")
6. Set custom error message for any error alert screen from SDK.
Java
ShakeBug.sharedInstance().changeSDKErrorAlertMessage("Something wrong...");
Kotlin
ShakeBug.sharedInstance().changeSDKErrorAlertMessage("Something wrong...")
7. If you have on-premise hosting plan then following method will be used.
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 bug reporting screen without shaking then you can call following method in any button action of any screen.
Java
ShakeBug.sharedInstance().triggerBugReporting();
Kotlin
ShakeBug.sharedInstance().triggerBugReporting()
9. Add the following to allow report bug by shaking mobile
Java
ShakeBug.sharedInstance().allowToReportBugByShakingMobile(true);
Kotlin
ShakeBug.sharedInstance().allowToReportBugByShakingMobile(true)
10. Add the following to allow report bug by screenshot capture event
Java
ShakeBug.sharedInstance().allowToReportBugByScreenCapture(true)
Kotlin
ShakeBug.sharedInstance().allowToReportBugByShakingMobile(true)
Supported following type of iOS projects
- 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, specify it in your Podfile:
pod 'ShakeBug'
Then, run the following command:
$ pod install
Note: Latest version of Shakebug iOS SDK is 1.0.34. 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 header into your app delegate.
Swift
import ShakeBug
Objective-C
#import <ShakeBug/ShakeBug.h>
#import <ShakeBug/ShakeBug-Swift.h>
2. Add the following to your app delegate'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 in 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
If you want add event to any screen or activity use 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 & run your app. Once your app is running, shake your device (^⌘Z in the simulator) to report a bug! Bug/Crash reports are sent directly to login panel of Shakebug.com and also notify on 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
Or 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 required You can change it in android/build.gradle
buildscript {
...
ext {
...
minSdkVersion = 24 or later
...
}
...
}
Usage
you Need to import ShakebugView in root file of 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/root file (where you import ShakebugView) then you need to pass independent as 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 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 Shake Bug with the default invocation event. Be sure to pass your application key which given by ShakeBug website. | |
iOS_appkey | String(required) | This initializes Shake Bug with the default invocation event. Be sure to pass your application key which given by ShakeBug website. | |
showTutorialScreenFirstTime | boolean | Add the following for enabling/disabling first time tutorial screen. | true |
ShakebugThemeColor | String | Developer can also set custome theme color in Shakebug SDK screens. | |
changeSDKScreenTitle | Array | Developer can also set custom title for Shakebug annotate and feedback input screen. | ["Annotate your bug", "Add Details"] |
allowToReportBugByShakingMobiles | boolean | Add the following to allow report bug by shaking mobile. | true |
allowToReportBugByScreenCapture | boolean | Add the following to allow report bug by screenshot capture event. | false |
ShakebugLanguage | String | If you want to set forcefully any language for the bug reporting screen then use following prop. | Your Device's language |
allowCrashReport | boolean | If you want to allow report crash while app get crashed then use following prop. | true |
makeLogEnabled | boolean | If you want to show any logs on console then use following prop. | false |
setShakebugSDKEndPointURL | Array | If you have on-premise hosting plan then following prop will be used. |
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. Add the following for enabling/disabling 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.
WebCopy following code after the