diff --git a/src/ios/Canvas2ImagePlugin.m b/src/ios/Canvas2ImagePlugin.m index 734ee00..ad063ae 100644 --- a/src/ios/Canvas2ImagePlugin.m +++ b/src/ios/Canvas2ImagePlugin.m @@ -22,7 +22,7 @@ @implementation Canvas2ImagePlugin - (void)saveImageDataToLibrary:(CDVInvokedUrlCommand*)command { self.callbackId = command.callbackId; - NSData* imageData = [NSData dataFromBase64String:[command.arguments objectAtIndex:0]]; + NSData* imageData = [[NSData alloc] initWithBase64EncodedString:[command.arguments objectAtIndex:0] options:0]; UIImage* image = [[[UIImage alloc] initWithData:imageData] autorelease]; UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); @@ -37,14 +37,14 @@ - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error context // Show error message... NSLog(@"ERROR: %@",error); CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_ERROR messageAsString:error.description]; - [self.webView stringByEvaluatingJavaScriptFromString:[result toErrorCallbackString: self.callbackId]]; + [self.commandDelegate sendPluginResult:result callbackId:self.callbackId]; } else // No errors { // Show message image successfully saved NSLog(@"IMAGE SAVED!"); CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString:@"Image saved"]; - [self.webView stringByEvaluatingJavaScriptFromString:[result toSuccessCallbackString: self.callbackId]]; + [self.commandDelegate sendPluginResult:result callbackId:self.callbackId]; } }