Skip to content

Commit 22b91f3

Browse files
committed
✨ setAutoScreenRecordingEnabled and setAutoScreenRecordingMaxDuration APIs
1 parent 883bbef commit 22b91f3

File tree

4 files changed

+98
-2
lines changed

4 files changed

+98
-2
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ android {
2121
}
2222

2323
dependencies {
24-
compile 'com.instabug.library:instabug:4.10.0'
24+
compile 'com.instabug.library:instabug:4.10.1'
2525
compile 'com.android.support:multidex:1.0.0'
2626
}

src/android/IBGPlugin.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ public boolean execute(final String action, JSONArray args, final CallbackContex
163163
} else if ("setViewHierarchyEnabled".equals(action)) {
164164
setViewHierarchyEnabled(callbackContext, args.optBoolean(0));
165165

166-
} else {
166+
} else if ("setAutoScreenRecordingEnabled".equals(action)) {
167+
setAutoScreenRecordingEnabled(callbackContext, args.optBoolean(0));
168+
169+
} else if ("setAutoScreenRecordingMaxDuration".equals(action)) {
170+
setAutoScreenRecordingMaxDuration(callbackContext, args.optInt(0));
171+
172+
} else {
167173
// Method not found.
168174
return false;
169175
}
@@ -557,6 +563,42 @@ private void setViewHierarchyEnabled(final CallbackContext callbackContext, bool
557563
}
558564
}
559565

566+
/**
567+
* Sets whether the SDK is recording the screen or not.
568+
*
569+
* @param isEnabled A boolean to set auto screen recording to being enabled or disabled.
570+
*
571+
* @param callbackContext
572+
* Used when calling back into JavaScript
573+
*/
574+
private void setAutoScreenRecordingEnabled(final CallbackContext callbackContext, boolean isEnabled) {
575+
try {
576+
Instabug.setAutoScreenRecordingEnabled(isEnabled);
577+
callbackContext.success();
578+
} catch (IllegalStateException e) {
579+
callbackContext.error(errorMsg);
580+
}
581+
}
582+
583+
/**
584+
* Sets maximum auto screen recording video duration.
585+
*
586+
* @param duration maximum duration of the screen recording video seconds
587+
* The maximum duration is 30 seconds
588+
*
589+
* @param callbackContext
590+
* Used when calling back into JavaScript
591+
*/
592+
private void setAutoScreenRecordingMaxDuration(final CallbackContext callbackContext, int duration) {
593+
try {
594+
int durationInMilli = duration * 1000;
595+
Instabug.setAutoScreenRecordingMaxDuration(durationInMilli);
596+
callbackContext.success();
597+
} catch (IllegalStateException e) {
598+
callbackContext.error(errorMsg);
599+
}
600+
}
601+
560602
/**
561603
* Sets user attribute to overwrite it's value or create a new one if it doesn't exist.
562604
*

src/ios/IBGPlugin.m

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,52 @@ - (void) setViewHierarchyEnabled:(CDVInvokedUrlCommand*)command
483483
[self.commandDelegate sendPluginResult:result callbackId:[command callbackId]];
484484
}
485485

486+
/**
487+
* Sets whether the SDK is recording the screen or not.
488+
*
489+
* @param {CDVInvokedUrlCommand*} command
490+
* The command sent from JavaScript
491+
*/
492+
- (void) setAutoScreenRecordingEnabled:(CDVInvokedUrlCommand*)command
493+
{
494+
CDVPluginResult* result;
495+
496+
BOOL isEnabled = [command argumentAtIndex:0];
497+
498+
if (isEnabled) {
499+
[Instabug setAutoScreenRecordingEnabled:isEnabled];
500+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
501+
} else {
502+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
503+
messageAsString:@"A boolean value must be provided."];
504+
}
505+
506+
[self.commandDelegate sendPluginResult:result callbackId:[command callbackId]];
507+
}
508+
509+
/**
510+
* Sets maximum auto screen recording video duration.
511+
*
512+
* @param {CDVInvokedUrlCommand*} command
513+
* The command sent from JavaScript
514+
*/
515+
- (void) setAutoScreenRecordingMaxDuration:(CDVInvokedUrlCommand*)command
516+
{
517+
CDVPluginResult* result;
518+
519+
CGFloat duration = [[command argumentAtIndex:0] floatValue];
520+
521+
if (duration) {
522+
[Instabug setAutoScreenRecordingDuration:duration];
523+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
524+
} else {
525+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
526+
messageAsString:@"A duration must be provided."];
527+
}
528+
529+
[self.commandDelegate sendPluginResult:result callbackId:[command callbackId]];
530+
}
531+
486532
/**
487533
* Convenience method for setting the threshold value
488534
* of the shake gesture for iPhone/iPod touch and iPad.

www/instabug.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ Instabug.setViewHierarchyEnabled = function (enabled, success, error) {
8585
exec(success, error, 'IBGPlugin', 'setViewHierarchyEnabled', [enabled]);
8686
};
8787

88+
Instabug.setAutoScreenRecordingEnabled = function (enabled, success, error) {
89+
exec(success, error, 'IBGPlugin', 'setAutoScreenRecordingEnabled', [enabled]);
90+
};
91+
92+
Instabug.setAutoScreenRecordingMaxDuration = function (duration, success, error) {
93+
exec(success, error, 'IBGPlugin', 'setAutoScreenRecordingMaxDuration', [duration]);
94+
};
95+
8896
Instabug.setUserEmail = function (email, success, error) {
8997
exec(success, error, 'IBGPlugin', 'setUserEmail', [email]);
9098
};

0 commit comments

Comments
 (0)