@@ -62,7 +62,13 @@ - (void)saveImageDataToLibrary:(CDVInvokedUrlCommand*)command
62
62
if (cameraRoll){
63
63
// add the image to camera roll
64
64
UIImage * savedImage = [UIImage imageWithContentsOfFile: imagePath];
65
- UIImageWriteToSavedPhotosAlbum (savedImage, self, @selector (thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo: ), nil );
65
+ UIImageWriteToSavedPhotosAlbum (savedImage, self,
66
+ @selector (thisImage:hasBeenSavedInPhotoAlbumWithError:onImagePath: ),
67
+ (void *) CFBridgingRetain (imagePath));
68
+ } else {
69
+ // send back the image path of the saved image
70
+ CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: imagePath];
71
+ [self .commandDelegate sendPluginResult: pluginResult callbackId: self .callbackId];
66
72
}
67
73
68
74
}else {
@@ -79,14 +85,18 @@ - (void)saveImageDataToLibrary:(CDVInvokedUrlCommand*)command
79
85
}];
80
86
}
81
87
82
- -(void )thisImage : (UIImage *)image hasBeenSavedInPhotoAlbumWithError : (NSError *)error usingContextInfo : (void *)ctxInfo {
83
- if (error) {
84
- CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_ERROR messageAsString: @" Error saving Image to Gallery, check Permissions" ];
85
- [self .commandDelegate sendPluginResult: pluginResult callbackId: self .callbackId];
86
- } else {
87
- CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: @" Image Saved to Gallery" ];
88
- [self .commandDelegate sendPluginResult: pluginResult callbackId: self .callbackId];
88
+ -(void )thisImage:(UIImage *)image hasBeenSavedInPhotoAlbumWithError:(NSError *)error onImagePath:(void *)bridgedImagePath{
89
+ if (error) {
90
+ CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_ERROR messageAsString: @" Error saving Image to Gallery, check Permissions" ];
91
+ [self .commandDelegate sendPluginResult: pluginResult callbackId: self .callbackId];
92
+ } else {
93
+ // retrieve bridged image path and release it to get the image path
94
+ NSString *imagePath = (NSString *) CFBridgingRelease (bridgedImagePath);
95
+
96
+ // send the image path back to the js callback
97
+ CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: imagePath];
98
+ [self .commandDelegate sendPluginResult: pluginResult callbackId: self .callbackId];
99
+ }
89
100
}
90
- }
91
101
92
102
@end
0 commit comments