How to save an image to iOS photos library

This was adapted from another user's code, but moved to be in your photos view model rather than editing the image-source module itself.

  •         
     viewModel.saveToAlbum = function(instance, format, quality) {
        var res = false;
        if (!instance) {
            return res;
        }
        var result = true;
        var CompletionTarget = NSObject.extend({
            "thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:": function(
                image, error, context) {
                if (error) {
                    result = false;
                }
            }
        }, {
            exposedMethods: {
                "thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:": {
                    returns: interop.types.void,
                    params: [UIImage, NSError, interop.Pointer]
                }
            }
        });
        var completionTarget = CompletionTarget.new();
        UIImageWriteToSavedPhotosAlbum(instance, completionTarget,
            "thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:",
            null);
        return result;
    };
    
    // and in your view js code
    photosModel.saveToAlbum(imageSource.ios, enums.ImageFormat.jpeg);