Skip to content

Commit 3da4f5e

Browse files
authored
Feature - Add shaking threshold APIs (#133)
1 parent 25905e1 commit 3da4f5e

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## master
22

3+
* Adds setShakingThresholdForiPhone, setShakingThresholdForiPad and setShakingThresholdForAndroid APIs
34
* Added Proguard rules to protect Flutter bridge class and method names from getting obfuscated when the minifyEnabled flag is set to true.
45

56
## v9.1.0 (2020-03-19)

android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,4 +861,15 @@ public void networkLog(HashMap<String, Object> jsonObject) throws JSONException
861861
networkLog.insert();
862862
}
863863

864+
/**
865+
* Sets the threshold value of the shake gesture for android devices.
866+
* Default for android is an integer value equals 350.
867+
* you could increase the shaking difficulty level by
868+
* increasing the `350` value and vice versa
869+
* @param androidThreshold Threshold for android devices.
870+
*/
871+
public void setShakingThresholdForAndroid(int androidThreshold) {
872+
BugReporting.setShakingThreshold(androidThreshold);
873+
}
874+
864875
}

ios/Classes/InstabugFlutterPlugin.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,28 @@ + (void)setChatNotificationEnabled:(NSNumber *)isEnabled {
693693
IBGReplies.inAppNotificationsEnabled = boolValue;
694694
}
695695

696+
697+
/**
698+
* Sets the threshold value of the shake gesture for iPhone/iPod Touch
699+
* Default for iPhone is 2.5.
700+
* @param iPhoneShakingThreshold Threshold for iPhone.
701+
*/
702+
+ (void)setShakingThresholdForiPhone:(NSNumber *)iPhoneShakingThreshold {
703+
double threshold = [iPhoneShakingThreshold doubleValue];
704+
IBGBugReporting.shakingThresholdForiPhone = threshold;
705+
706+
}
707+
708+
/**
709+
* Sets the threshold value of the shake gesture for iPad.
710+
* Default for iPad is 0.6.
711+
* @param iPadShakingThreshold Threshold for iPad.
712+
*/
713+
+ (void)setShakingThresholdForiPad:(NSNumber *)iPadShakingThreshold {
714+
double threshold = [iPadShakingThreshold doubleValue];
715+
IBGBugReporting.shakingThresholdForiPad = threshold;
716+
}
717+
696718
/**
697719
* Extracts HTTP connection properties. Request method, Headers, Date, Url and Response code
698720
*

lib/BugReporting.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'dart:io' show Platform;
23
import 'package:flutter/services.dart';
34
import 'package:instabug_flutter/Instabug.dart';
45

@@ -188,4 +189,40 @@ class BugReporting {
188189
await _channel.invokeMethod<Object>(
189190
'showBugReportingWithReportTypeAndOptions:options:', params);
190191
}
192+
193+
/// Sets the threshold value of the shake gesture for iPhone/iPod Touch
194+
/// Default for iPhone is 2.5.
195+
/// [iPhoneShakingThreshold] iPhoneShakingThreshold double
196+
static void setShakingThresholdForiPhone(
197+
double iPhoneShakingThreshold) async {
198+
if (Platform.isIOS) {
199+
final List<dynamic> params = <dynamic>[iPhoneShakingThreshold];
200+
await _channel.invokeMethod<Object>(
201+
'setShakingThresholdForiPhone:', params);
202+
}
203+
}
204+
205+
/// Sets the threshold value of the shake gesture for iPad
206+
/// Default for iPhone is 0.6.
207+
/// [iPadShakingThreshold] iPhoneShakingThreshold double
208+
static void setShakingThresholdForiPad(double iPadShakingThreshold) async {
209+
if (Platform.isIOS) {
210+
final List<dynamic> params = <dynamic>[iPadShakingThreshold];
211+
await _channel.invokeMethod<Object>(
212+
'setShakingThresholdForiPad:', params);
213+
}
214+
}
215+
216+
/// Sets the threshold value of the shake gesture for android devices.
217+
/// Default for android is an integer value equals 350.
218+
/// you could increase the shaking difficulty level by
219+
/// increasing the `350` value and vice versa
220+
/// [androidThreshold] iPhoneShakingThreshold int
221+
static void setShakingThresholdForAndroid(int androidThreshold) async {
222+
if (Platform.isAndroid) {
223+
final List<dynamic> params = <dynamic>[androidThreshold];
224+
await _channel.invokeMethod<Object>(
225+
'setShakingThresholdForAndroid:', params);
226+
}
227+
}
191228
}

0 commit comments

Comments
 (0)