Skip to content

Commit

Permalink
Add installFeedbackHandler API
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysharm committed Sep 2, 2020
1 parent 0310d63 commit 7f241f9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/android/CDVTestFairy.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
String appToken = args.optString(0);
boolean takeScreenshot = args.optBoolean(1);
TestFairy.showFeedbackForm(cordova.getActivity(), appToken, takeScreenshot);
} else if ("installFeedbackHandler".equals(action)) {
String appToken = args.optString(0);
TestFairy.installFeedbackHandler(cordova.getActivity(), appToken);
} else {
Log.d("TestFairy", "Action " + action + " is not supported on Android.");
return false;
Expand Down
1 change: 1 addition & 0 deletions src/ios/CDVTestFairy.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
- (void)setMaxSessionLength:(CDVInvokedUrlCommand*)command;
- (void)logException:(CDVInvokedUrlCommand*)command;
- (void)showFeedbackForm:(CDVInvokedUrlCommand*)command;
- (void)installFeedbackHandler:(CDVInvokedUrlCommand*)command;
@end
15 changes: 15 additions & 0 deletions src/ios/CDVTestFairy.m
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,19 @@ - (void)showFeedbackForm:(CDVInvokedUrlCommand*)command {
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void)installFeedbackHandler:(CDVInvokedUrlCommand*)command {
NSArray* arguments = command.arguments;
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];

if ([arguments count] > 0) {
NSString *appToken = [arguments objectAtIndex:0];
[TestFairy installFeedbackHandler:appToken method:@"shake|screenshot"];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"arguments are missing"];
}

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

@end
4 changes: 4 additions & 0 deletions www/testfairy.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ TestFairy.prototype.begin = function(appToken) {
}
};

TestFairy.prototype.installFeedbackHandler = function(appToken) {
exec(function(){}, function(){}, this.serviceName, "installFeedbackHandler", [ appToken ]);
};

/**
* (Optional) Push the feedback view controller. Hook a button
* to this method to allow users to provide feedback about the current
Expand Down

0 comments on commit 7f241f9

Please sign in to comment.