4 Commits
4.1.1 ... 4.1.2

Author SHA1 Message Date
StefanoMagrassi
096fada588 version 4.1.2 2016-12-15 08:54:21 +01:00
StefanoMagrassi
f2d7364e2f dependencies updated 2016-12-15 08:52:39 +01:00
StefanoMagrassi
a4b9af06be Merge pull request #15 from romankisil/master
Fixed iOS Error handling
2016-12-14 20:37:42 +01:00
Romans Kisils
a7167e2271 If permissions were declined the iOS code would still call the success callback, now the error is handled and a fail callback is called 2016-12-13 11:30:14 +00:00
3 changed files with 15 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-base64-to-gallery",
"version": "4.1.1",
"version": "4.1.2",
"description": "Cordova plugin to save base64 data as a png image into the device",
"license": "MIT",
"scripts": {
@@ -57,7 +57,7 @@
}
],
"devDependencies": {
"eslint": "1.10.3",
"nodemsg": "1.0.0"
"eslint": "3.12.2",
"nodemsg": "1.1.0"
}
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns:android="http://schemas.android.com/apk/res/android" xmlns="http://www.phonegap.com/ns/plugins/1.0" id="cordova-base64-to-gallery" version="4.1.1">
<plugin xmlns:android="http://schemas.android.com/apk/res/android" xmlns="http://www.phonegap.com/ns/plugins/1.0" id="cordova-base64-to-gallery" version="4.1.2">
<engines>
<engine name="cordova-ios" version=">=3.8.0" />

View File

@@ -62,12 +62,9 @@
if(cameraRoll){
// add the image to camera roll
UIImage * savedImage = [UIImage imageWithContentsOfFile:imagePath];
UIImageWriteToSavedPhotosAlbum(savedImage, nil, nil, nil);
UIImageWriteToSavedPhotosAlbum(savedImage, self, @selector(thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:), nil);
}
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: imagePath];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
}else{
imagePath = [imagePath stringByAppendingString: @" - error writing image to documents folder"];
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:imagePath];
@@ -82,4 +79,14 @@
}];
}
-(void)thisImage:(UIImage *)image hasBeenSavedInPhotoAlbumWithError:(NSError *)error usingContextInfo:(void*)ctxInfo{
if (error) {
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error saving Image to Gallery, check Permissions"];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
} else {
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @"Image Saved to Gallery"];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
}
}
@end