From 43c325317ab60177cdd8b544f1f3aee3877794e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Sat, 23 Jul 2016 13:18:24 +0200 Subject: [PATCH] `print` returns boolean to inform about the result --- CHANGELOG.md | 1 + src/android/Printer.java | 5 ++++- src/ios/APPPrinter.m | 9 ++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd0962..373ab7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [__change__:] Plugin requires Android KitKat or newer - [__change__:] `isAvailable` returns false if no enabled print services can be found (Android) - [enhancement:] `isAvailable` returns additional list of available print services (Android) +- [enhancement:] `print` returns bool value to indicate the result - [enhancement:] Support `duplex` attribute (Android) diff --git a/src/android/Printer.java b/src/android/Printer.java index fb4d646..8a5aaa4 100644 --- a/src/android/Printer.java +++ b/src/android/Printer.java @@ -229,7 +229,10 @@ public class Printer extends CordovaPlugin { public void run() { for (;;) { if (job.isCancelled() || job.isCompleted() || job.isFailed()) { - command.success(); + PluginResult res = new PluginResult( + PluginResult.Status.OK, job.isCompleted()); + + command.sendPluginResult(res); break; } } diff --git a/src/ios/APPPrinter.m b/src/ios/APPPrinter.m index 88b193b..b3f10c1 100755 --- a/src/ios/APPPrinter.m +++ b/src/ios/APPPrinter.m @@ -206,7 +206,8 @@ [controller presentFromRect:rect inView:self.webView animated:YES completionHandler: ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) { CDVPluginResult* pluginResult = - [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [CDVPluginResult resultWithStatus:CDVCommandStatus_OK + messageAsBool:ok]; [self.commandDelegate sendPluginResult:pluginResult callbackId:_callbackId]; @@ -216,7 +217,8 @@ [controller presentAnimated:YES completionHandler: ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) { CDVPluginResult* pluginResult = - [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [CDVPluginResult resultWithStatus:CDVCommandStatus_OK + messageAsBool:ok]; [self.commandDelegate sendPluginResult:pluginResult callbackId:_callbackId]; @@ -241,7 +243,8 @@ [controller printToPrinter:printer completionHandler: ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) { CDVPluginResult* pluginResult = - [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + [CDVPluginResult resultWithStatus:CDVCommandStatus_OK + messageAsBool:ok]; [self.commandDelegate sendPluginResult:pluginResult callbackId:_callbackId];