Merge pull request #15 from romankisil/master

Fixed iOS Error handling
This commit is contained in:
StefanoMagrassi
2016-12-14 20:37:42 +01:00
committed by GitHub
+11 -4
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