I have a plugin class which is extending CDVPlugin. This plugin will invoked from a button click from HTML side. After that I am using UIImagePickerController to take two photos. Then I am trying to send those images to javascript callback function using pluginresult.
Here, as I am trying to send two images in one go, the UI is being stuck for some time. So, I want to send the result in a background thread. And also I should be receive that from javascript callback function.
Has someone done this before? Is there any way to achieve this so that UI navigation will be smoother....
Something like this:
- (void)myPluginMethod:(CDVInvokedUrlCommand*)command
{
// Check command.arguments here.
[self.commandDelegate runInBackground:^{
NSString* payload = nil;
// Some blocking logic...
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:payload];
// The sendPluginResult method is thread-safe.
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With