From 5493c652fd299d9142c6c3534a15f8df38421c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Fri, 12 Sep 2014 10:53:44 +0200 Subject: [PATCH] `isAvailable` does not block the main thread anymore --- CHANGELOG.md | 3 ++- README.md | 1 + src/ios/APPPrinter.m | 14 ++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44e3705..787a77c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,4 +5,5 @@ - [__change__:] Renamed `isServiceAvailable` to `isAvailable` - [enhancement:] New print options like `name`, `landscape` or `duplex` - [enhancement:] Ability to print remote content via URI -- [enhancement:] Callback support \ No newline at end of file +- [enhancement:] Callback support +- [bugfix:] `isAvailable` does not block the main thread anymore. \ No newline at end of file diff --git a/README.md b/README.md index 049193f..1589c11 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ cordova plugin rm de.appplant.cordova.plugin.printer - [enhancement:] New print options like `name`, `landscape` or `duplex` - [enhancement:] Ability to print remote content via URI - [enhancement:] Callback support +- [bugfix:] `isAvailable` does not block the main thread anymore. #### Further informations - See [CHANGELOG.md][changelog] to get the full changelog for the plugin. diff --git a/src/ios/APPPrinter.m b/src/ios/APPPrinter.m index 9056a66..80ab2ef 100755 --- a/src/ios/APPPrinter.m +++ b/src/ios/APPPrinter.m @@ -38,14 +38,16 @@ */ - (void) isAvailable:(CDVInvokedUrlCommand*)command { - CDVPluginResult* pluginResult; - BOOL isAvailable = [self isPrintingAvailable]; + [self.commandDelegate runInBackground:^{ + CDVPluginResult* pluginResult; + BOOL isAvailable = [self isPrintingAvailable]; - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK - messageAsBool:isAvailable]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK + messageAsBool:isAvailable]; - [self.commandDelegate sendPluginResult:pluginResult - callbackId:command.callbackId]; + [self.commandDelegate sendPluginResult:pluginResult + callbackId:command.callbackId]; + }]; } /**